Created
March 16, 2017 18:29
-
-
Save tivnet/318a854260b0bb8c1e56959b88a1c5f7 to your computer and use it in GitHub Desktop.
A simplified version of a2ensite/a2dissite. Works under Windows with no symlinking.
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 | |
# A simplified version of a2ensite/a2dissite. Works under Windows with no symlinking. | |
# Author: Gregory Karpinsky (@tivnet) | |
if [ ! -d sites-available ] | |
then | |
echo "Wrong folder!" | |
exit 2; | |
fi | |
# Disable | |
if [ "d" == "${2}" ] && [ -f sites-enabled/${1}.conf ] | |
then | |
rm sites-enabled/${1}.conf | |
echo "${1} disabled" | |
exit 1; | |
fi | |
# Enable | |
if [ "e" == "${2}" ] && [ -f sites-available/${1}.conf ] | |
then | |
rm -f sites-enabled/${1}.conf | |
cp sites-available/${1}.conf sites-enabled/ | |
ls -l sites-enabled/${1}.conf | |
echo "${1} enabled" | |
exit 1; | |
fi | |
# List | |
if [ -z "${1}" ] | |
then | |
declare -r pattern="*" | |
else | |
declare -r pattern=${1} | |
fi | |
cd sites-available | |
for site in `ls -1 ${pattern}.conf | sed s/.conf//g` | |
do | |
if [ -f ../sites-enabled/${site}.conf ] | |
then | |
echo -n "+ " | |
else | |
echo -n "- " | |
fi | |
echo ${site} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment