Skip to content

Instantly share code, notes, and snippets.

@babeuloula
Created October 20, 2023 03:44
Show Gist options
  • Save babeuloula/47137f181544206a0a2af6bd2975c061 to your computer and use it in GitHub Desktop.
Save babeuloula/47137f181544206a0a2af6bd2975c061 to your computer and use it in GitHub Desktop.
NGINX site enable/disable
#!/bin/bash
set -e
readonly RESET='\033[0;0m'
readonly RED='\033[0;31m'
readonly GREEN='\033[0;32m'
if [[ -z "$1" ]]; then
echo -e "${RED}You must provide configuration name.${RESET}"
exit 1
fi
if [[ ! -f /etc/nginx/sites-enabled/$1 ]]; then
echo -e "${RED}Unable to find configuration file $1.${RESET}"
exit 1
fi
rm -f /etc/nginx/sites-enabled/$1
echo -e "${GREEN}Configuration $1 disabled with success.${RESET}"
systemctl restart nginx
#!/bin/bash
set -e
readonly RESET='\033[0;0m'
readonly RED='\033[0;31m'
readonly GREEN='\033[0;32m'
if [[ -z "$1" ]]; then
echo -e "${RED}You must provide configuration name.${RESET}"
exit 1
fi
if [[ ! -f /etc/nginx/sites-available/$1 ]]; then
echo -e "${RED}Unable to find configuration file $1.${RESET}"
exit 1
fi
ln -s /etc/nginx/sites-available/$1 /etc/nginx/sites-enabled/
echo -e "${GREEN}Configuration $1 enabled with success.${RESET}"
systemctl restart nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment