Last active
November 24, 2016 07:08
-
-
Save wgroenewold/e852df0bd5e509dfb76eecac0e7a90b8 to your computer and use it in GitHub Desktop.
Update your DirectAdmin NGINX mainline server the easy way
This file contains 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/env bash | |
function read_yes_no() | |
{ | |
if [ "$1" = "-y" -o "$1" = "y" ]; then | |
{ | |
yesno="y"; | |
echo "y"; | |
echo "Skipping...as -y was given"; | |
} | |
elif [ "$1" = "-n" -o "$1" = "n" ]; then | |
{ | |
yesno="n"; | |
echo "n"; | |
echo "Terminating...as -n was given"; | |
exit 1; | |
} | |
fi; | |
if [ "$yesno" = "" ]; then | |
{ | |
while read yesno; | |
do | |
{ | |
if [ "$yesno" = "y" ]; then break; | |
elif [ "$yesno" = "n" ]; then echo "Terminating..."; exit 1; | |
else echo -n "${ask_text}"; fi; | |
} | |
done; | |
} | |
fi; | |
} | |
echo "##########################################################################"; | |
echo "# Install the latest version of NGINX mainline in Custombuild2 #"; | |
echo "# Written by: Alex S Grebenschikov (zEitEr) and Wouter Groenewold (GH+O) #"; | |
echo "##########################################################################"; | |
echo ""; | |
cd /usr/local/directadmin/custombuild || exit 1; | |
rm hgtags_nginx_mainline; | |
[ -e "hgtags_nginx_mainline" ] || wget -O hgtags_nginx_mainline https://raw.githubusercontent.com/nginx/nginx/master/.hgtags; | |
NGINX_VER=`tail -1 hgtags_nginx_mainline 2>&1 | cut -d\- -f2`; | |
NGINX_VER_INSTALLED=`nginx -v 2>&1 | grep 'nginx version' | cut -d\/ -f2`; | |
ask_text="Do you want to build NGINX? (y/n): "; | |
echo "Latest version of NGINX mainline: ${NGINX_VER}"; | |
echo "Installed version of NGINX: ${NGINX_VER_INSTALLED}"; | |
echo ""; | |
echo -n "${ask_text}"; | |
cat custom_versions.txt | grep -Ev "^nginx:|^$" > custom_versions.txt.new; | |
mv -f custom_versions.txt.new custom_versions.txt; | |
echo "nginx:${NGINX_VER}:" >> custom_versions.txt; | |
read_yes_no ${1}; | |
[ -e "nginx-${NGINX_VER}.tar.gz" ] || wget http://nginx.org/download/nginx-${NGINX_VER}.tar.gz -O nginx-${NGINX_VER}.tar.gz; | |
./build update > /dev/null 2>&1; | |
./build versions > /dev/null 2>&1; | |
./build update_versions; | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment