optional parameters for setup-web2py-nginx-uwsgi-ubuntu.sh

This commit is contained in:
mdipierro
2016-02-29 11:34:57 -06:00
parent 10f2e4c3ad
commit 3808b1f6ae
+39 -16
View File
@@ -6,9 +6,21 @@ if [[ $EUID -ne 0 ]]; then
echo "You must run the script as root or using sudo" echo "You must run the script as root or using sudo"
exit 1 exit 1
fi fi
# parse command line arguments
nopassword=0
nocertificate=0
while [ "$#" -gt 0 ]; do
case "$1" in
--no-password) nopassword=1; shift 1;;
--no-certificate) nocertificate=1; shift 1;;
esac
done
# Get Web2py Admin Password # Get Web2py Admin Password
echo -e "Web2py Admin Password: \c " if [ "$nopassword" -eq 0 ]
read PW then
echo -e "Web2py Admin Password: \c "
read PW
fi
# Upgrade and install needed software # Upgrade and install needed software
apt-get update apt-get update
apt-get -y upgrade apt-get -y upgrade
@@ -115,13 +127,13 @@ ln -s /etc/nginx/sites-available/web2py /etc/nginx/sites-enabled/web2py
rm /etc/nginx/sites-enabled/default rm /etc/nginx/sites-enabled/default
mkdir /etc/nginx/ssl mkdir /etc/nginx/ssl
cd /etc/nginx/ssl cd /etc/nginx/ssl
if [ "$nocertificate" -eq 0 ]
openssl genrsa 1024 > web2py.key then
chmod 400 web2py.key openssl genrsa 1024 > web2py.key
openssl req -new -x509 -nodes -sha1 -days 1780 -key web2py.key > web2py.crt chmod 400 web2py.key
openssl x509 -noout -fingerprint -text < web2py.crt > web2py.info openssl req -new -x509 -nodes -sha1 -days 1780 -key web2py.key > web2py.crt
openssl x509 -noout -fingerprint -text < web2py.crt > web2py.info
fi
# Prepare folders for uwsgi # Prepare folders for uwsgi
sudo mkdir /etc/uwsgi sudo mkdir /etc/uwsgi
sudo mkdir /var/log/uwsgi sudo mkdir /var/log/uwsgi
@@ -176,13 +188,24 @@ mv web2py/handlers/wsgihandler.py web2py/wsgihandler.py
rm web2py_src.zip rm web2py_src.zip
chown -R www-data:www-data web2py chown -R www-data:www-data web2py
cd /home/www-data/web2py cd /home/www-data/web2py
sudo -u www-data python -c "from gluon.main import save_password; save_password('$PW',443)" if [ "$nopassword" -eq 0 ]
then
sudo -u www-data python -c "from gluon.main import save_password; save_password('$PW',443)"
fi
start uwsgi-emperor start uwsgi-emperor
/etc/init.d/nginx restart /etc/init.d/nginx restart
## you can reload uwsgi with echo <<EOF
# restart uwsgi-emperor you can reload uwsgi with
## and stop it with
# stop uwsgi-emperor restart uwsgi-emperor
## to reload web2py only (without restarting uwsgi)
# touch /etc/uwsgi/web2py.ini and stop it with
stop uwsgi-emperor
to reload web2py only (without restarting uwsgi)
touch /etc/uwsgi/web2py.ini
EOF