7
4
Is there any or command to check whether NGINX is already installed on UBUNTU Linux using a bash command/script?
I was trying something like this
echo "BEGINNING INSTALLATION OF NGINX WEB SERVER"
echo
echo
echo "CHECKING TO SEE IF NGINX IS ALREADY INSTALLED"
service nginx > temp.install 2> temperr.install
echo 111
grep -c unrecognized temperr.install > temp2.install
echo 222
status = `cat temp2.install`
echo "NGINX STATUS $status"
Am new to bash scripting and hence not sure if this is teh best possible way to approach this. I need to write a script that checks if NGINX is already installed or not. If it is not installed it simply installs NGINX otherwise it first deletes NGINX and then re-installs it.
5How about
dpkg -l | grep nginx
– None – 2013-09-18T08:32:20.577I tried this but it just returns back to the bash prompt without giving me any output. – None – 2013-09-18T08:34:55.283
3@op Check return status with
echo $?
right after issuing thedpkg
command. – None – 2013-09-18T08:35:48.4174Well... did not check return status but I just modified your command a bit and it works for me. This is what I did dpkg -l | grep -c nginx . If nginx is installed it returns the count of the nginx packages and if it is not installed it simply returns 0 – None – 2013-09-18T08:42:56.500