Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # Enable all config files in /etc/apache2/sites-available directory.
- #
- # Usage: Make this script executable and run as a user with sudo privileges.
- # ==============================================================================
- BASE_DIR="/etc/apache2/sites-available"
- for FILEPATH in $BASE_DIR/*; do
- if [[ -f "$FILEPATH" ]]; then
- CONF=$(basename "$FILEPATH")
- a2ensite ${CONF}
- if [ $? != 0 ]
- then
- echo "a2ensite NOT successful for ${CONF}"
- else
- echo "a2ensite successful for ${CONF}"
- fi
- fi
- done
- # Reload apache
- read -p "Do you want to reload Apache (y/n)?" CONT
- if [ "$CONT" = "y" ]; then
- service apache2 reload
- if [ $? -eq 0 ]
- then
- echo "Apache reloaded - check sites in browser."
- else
- echo "There was a problem reloading Apache."
- fi
- else
- echo "Changes won't take effect until Apache is reloaded or restarted.";
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement