Skip to content

Instantly share code, notes, and snippets.

@Sharaf5
Forked from smuuf/a2manage.sh
Last active March 24, 2023 07:15
Show Gist options
  • Save Sharaf5/85754a87796862f9631709459f5e5f27 to your computer and use it in GitHub Desktop.
Save Sharaf5/85754a87796862f9631709459f5e5f27 to your computer and use it in GitHub Desktop.
a2enmod and a2dismod for Alpine
#!/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