From 3a6febe098b1867edd1a51502c4dd5f466b1c78a Mon Sep 17 00:00:00 2001 From: Brice Waegeneire Date: Mon, 1 Feb 2021 16:58:20 +0100 Subject: [PATCH] add migration verifications --- migrate.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) mode change 100644 => 100755 migrate.sh diff --git a/migrate.sh b/migrate.sh old mode 100644 new mode 100755 index 2e8abbd..9e8ee1f --- a/migrate.sh +++ b/migrate.sh @@ -15,6 +15,25 @@ backup() { cp "$file" "$file".apreq.bak } +verify_migration() { + if apache2ctl -t; then + echo "the migration produced valid config" + else + echo "the migration went wrong, try doing it manually" + exit 1 + fi +} + +try_disabling_access_compat() { + if a2dismod access_compat && apache2ctl -t; then + echo "access_compat disabled succesfully!" + else + echo "access_compat can't be disabled, \ + some config is still using it" + a2enmod access_compat + fi +} + awk '{ print $1 }' "$inventory" > "$to_convert" while IFS= read -r file; do @@ -22,3 +41,5 @@ while IFS= read -r file; do backup "$file" perl -i ~bwaegeneire/convert.pl "$file" done < "$to_convert" + +verify_migration && try_disabling_access_compat