-
-
Save Sharaf5/85754a87796862f9631709459f5e5f27 to your computer and use it in GitHub Desktop.
a2enmod and a2dismod for Alpine
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/sh | |
# Usage: | |
# ./a2manage.sh e|d mod1 mod2 mod3 | |
# e: enable | |
# d: disable | |
MODS_A_CONF_PATH="/etc/apache2/*.conf" | |
MODS_B_CONF_PATH="/etc/apache2/conf.d/*.conf" | |
function a2enmod { | |
while test $# -gt 0; do | |
MODULE="$1" | |
echo "Enabling module ${MODULE}_module" | |
sed -i "/^#LoadModule ${MODULE}_module/s/^#//g" $MODS_A_CONF_PATH | |
sed -i "/^#LoadModule ${MODULE}_module/s/^#//g" $MODS_B_CONF_PATH | |
shift | |
done | |
} | |
function a2dismod { | |
while test $# -gt 0; do | |
MODULE="$1" | |
echo "Disabling module ${MODULE}_module" | |
sed -i "/^LoadModule ${MODULE}_module/s/^/#/g" $MODS_A_CONF_PATH | |
sed -i "/^LoadModule ${MODULE}_module/s/^/#/g" $MODS_B_CONF_PATH | |
shift | |
done | |
} | |
if [ "$1" == "e" ]; then | |
a2enmod "${@:2}" | |
exit 0 | |
fi | |
if [ "$1" == "d" ]; then | |
a2dismod "${@:2}" | |
exit 0 | |
fi | |
echo "a2manage: Unknown command $1" | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment