Created
June 10, 2013 15:14
-
-
Save NickWoodhams/5749563 to your computer and use it in GitHub Desktop.
Nginx and Uwsgi helpers for enabling sites/apps by automatically creating symlinks
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/bash | |
if [ "$1" ]; then | |
#site argument is set | |
if [ -L /etc/nginx/sites-enabled/$1 ]; then | |
#symbolic link does not exist, enable the site | |
echo "Disabling nginx site $1!" | |
sudo rm /etc/nginx/sites-enabled/$1 | |
sudo service nginx restart | |
else | |
#symbolic link exists, give the user a message | |
if [ -f /etc/nginx/sites-available/$1 ]; then | |
#site exists in sites-available | |
echo "-> Site already disabled! <-" | |
else | |
#site does not exist in sites-available | |
echo "-> Site not found! <-" | |
fi | |
fi | |
else | |
#echo -e allows literal translation for tab character | |
echo -e "Avail |\tEnabled" | |
#list sites available and sites enabled in two columns | |
comm -2 <(ls /etc/nginx/sites-available) <(ls /etc/nginx/sites-enabled) | |
#prompt the user to enter a sitename from the enabled sites list | |
read -p "Which site would you like to disable? " site | |
#re-run the script with the site argument | |
ndissite $site | |
fi |
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/bash | |
if [ "$1" ]; then | |
#site argument is set | |
if [ -f /etc/nginx/sites-available/$1 ]; then | |
#site exists | |
if [ -L /etc/nginx/sites-enabled/$1 ]; then | |
#symlink exists | |
echo "-> Site is already enabled! <-" | |
else | |
echo "Enabling nginx site $1!" | |
sudo ln -s /etc/nginx/sites-available/$1 /etc/nginx/sites-enabled/$1 | |
sudo service nginx restart | |
fi | |
else | |
echo "-> Site not found! <-" | |
fi | |
else | |
#echo -e allows literal translation for tab character | |
echo -e "Avail |\tEnabled" | |
#list sites available and sites enabled in two columns | |
comm -2 <(ls /etc/nginx/sites-available) <(ls /etc/nginx/sites-enabled) | |
read -p "Which site would you like to enable? " site | |
nensite $site | |
fi |
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/bash | |
if [ "$1" ]; then | |
#app argument is set | |
if [ -L /etc/uwsgi/apps-enabled/$1 ]; then | |
#symbolic link does not exist, enable the app | |
echo "Disabling uwsgi app $1!" | |
sudo rm /etc/uwsgi/apps-enabled/$1 | |
sudo service uwsgi restart | |
else | |
#symbolic link exists, give the user a message | |
if [ -f /etc/uwsgi/apps-available/$1 ]; then | |
#app exists in apps-available | |
echo "-> App already disabled! <-" | |
else | |
#app does not exist in apps-available | |
echo "-> App not found! <-" | |
fi | |
fi | |
else | |
#echo -e allows literal translation for tab character | |
echo -e "Avail |\tEnabled" | |
#list apps available and apps enabled in two columns | |
comm -2 <(ls /etc/uwsgi/apps-available) <(ls /etc/uwsgi/apps-enabled) | |
#prompt the user to enter a appname from the enabled apps list | |
read -p "Which app would you like to disable? " app | |
#re-run the script with the app argument | |
udisapp $app | |
fi |
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/bash | |
if [ "$1" ]; then | |
#app argument is set | |
if [ -f /etc/uwsgi/apps-available/$1 ]; then | |
#app exists | |
if [ -L /etc/uwsgi/apps-enabled/$1 ]; then | |
#symlink exists | |
echo "-> App is already enabled! <-" | |
else | |
echo "Enabling uwsgi app $1!" | |
sudo ln -s /etc/uwsgi/apps-available/$1 /etc/uwsgi/apps-enabled/$1 | |
sudo service uwsgi restart | |
fi | |
else | |
echo "-> App not found! <-" | |
fi | |
else | |
#echo -e allows literal translation for tab character | |
echo -e "Avail |\tEnabled" | |
#list apps available and apps enabled in two columns | |
comm -2 <(ls /etc/uwsgi/apps-available) <(ls /etc/uwsgi/apps-enabled) | |
read -p "Which app would you like to enable? " app | |
uenapp $app | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment