Created
September 21, 2016 02:08
-
-
Save staugur/135019df8e45baa88a8f2851266b21d2 to your computer and use it in GitHub Desktop.
update nginx version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
v=1.8.0 | |
nginx=/usr/local/nginx | |
pid=${nginx}/logs/nginx.pid | |
pidbin=${nginx}/logs/nginx.pid.oldbin | |
exec=`which nginx` | |
[ "$?" = "0" ] || exit 1 | |
$exec -V &> /tmp/nginx_V | |
args=$(awk -F "configure arguments:" '{print $2}' /tmp/nginx_V | grep -v "^$") | |
echo 'If your nginx has third party modules, that is, use the "--add-module" parameter, move the module directory to the same location as the current nginx build!' | |
read -p "Continue yes?(y/n)" NEXT | |
[ "$NEXT" = "n" ] && exit 1 || echo Continue Yes! | |
wget -c http://nginx.org/download/nginx-$v.tar.gz | |
[ -f nginx-$v.tar.gz ] || exit 1 && echo "No version." | |
tar zxf nginx-$v.tar.gz | |
cd nginx-$v | |
./configure $args | |
make | |
mv $exec /tmp | |
cp objs/nginx $exec | |
kill -USR2 `cat $pid` | |
kill -WINCH `cat $pidbin` | |
kill -HUP `cat $pidbin` | |
kill -QUIT `cat $pidbin` | |
s() { | |
echo "Update Successed." && $exec -v | |
[ -x /tmp/nginx ] && rm -f /tmp/nginx | |
} | |
f() { | |
echo "Update failed." | |
mv -f /tmp/nginx $exec && echo "Has rolled back." | |
} | |
$exec -v &> /dev/null && s || f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment