Created
October 20, 2023 03:44
-
-
Save babeuloula/47137f181544206a0a2af6bd2975c061 to your computer and use it in GitHub Desktop.
NGINX site enable/disable
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 | |
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 |
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 | |
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