Last active
January 7, 2022 08:21
-
-
Save LinuxDragon57/f7b631312f717cdc9f2db2c53e2ee413 to your computer and use it in GitHub Desktop.
Simple little bash scripts to work like a2ensite and a2dissite for Nginx
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
# vim: filetype=sh | |
#!/bin/bash | |
file="/etc/nginx/sites-enabled/${1}" | |
if [ -e $file ]; then | |
rm -fv $file | |
read -p "Restart Nginx? Press CTRL-C to Abort." | |
/usr/bin/sudo /usr/sbin/nginx -s reload | |
echo "Restarted Nginx" | |
else | |
1>&2 echo "Error: ${file}: Symbolic link does not exist." | |
fi |
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
# vim: filetype=sh | |
#!/bin/bash | |
file="/etc/nginx/sites-available/${1}" | |
if [ -f $file ] && [ ! -e "/etc/nginx/sites-enabled/${1}" ]; then | |
/usr/bin/ln -sv $file /etc/nginx/sites-enabled | |
/usr/bin/sudo /usr/sbin/nginx -s reload | |
read -p 'Restart Nginx? Press CTRL-C to Abort.' | |
/usr/bin/sudo /usr/sbin/nginx -s reload | |
echo "Restarted Nginx" | |
elif [ ! -f $file ]; then | |
1>&2 echo "Error: ${file}: No such file or directory." | |
else | |
1>&2 echo "Error: ${1}: Symbolic link already exists." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment