Skip to content

Instantly share code, notes, and snippets.

@LinuxDragon57
Last active January 7, 2022 08:21
Show Gist options
  • Save LinuxDragon57/f7b631312f717cdc9f2db2c53e2ee413 to your computer and use it in GitHub Desktop.
Save LinuxDragon57/f7b631312f717cdc9f2db2c53e2ee413 to your computer and use it in GitHub Desktop.
Simple little bash scripts to work like a2ensite and a2dissite for Nginx
# 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
# 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