Created
January 28, 2022 10:19
-
-
Save smuuf/a4e41021b538a6eb69cc4b93a524097e 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 a2dismod proxy.* | |
# ./a2manage.sh a2enmod proxy proxy_fcgi ssl | |
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" | |
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" | |
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" == "a2enmod" ]; then | |
a2enmod "${@:2}" | |
exit 0 | |
fi | |
if [ "$1" == "a2dismod" ]; 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