apache-require/migrate.sh

48 lines
1,023 B
Bash
Raw Normal View History

2021-01-12 15:01:55 +01:00
#!/bin/sh
2021-01-12 17:31:27 +01:00
set -e
2021-01-12 15:01:55 +01:00
2021-01-12 17:31:27 +01:00
inventory=$1
2021-01-12 15:01:55 +01:00
2021-01-12 17:31:27 +01:00
tmp_dir=/tmp/apache-require
2021-03-23 11:01:04 +01:00
backup_dir=$tmp_dir/backup
2021-01-12 17:31:27 +01:00
inventory=$tmp_dir/inventory
to_convert=$tmp_dir/to_convert
# Create a backup of the FILE specific for this project
backup() {
file=$1
2021-03-23 11:01:04 +01:00
install --preserve-timestamps --preserve-contex \
-D "$file" "$backup_dir/$file"
2021-01-12 17:31:27 +01:00
}
2021-02-01 16:58:20 +01:00
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
}
2021-01-12 17:31:27 +01:00
awk '{ print $1 }' "$inventory" > "$to_convert"
while IFS= read -r file; do
echo $file
backup "$file"
perl -i ~bwaegeneire/convert.pl "$file"
done < "$to_convert"
2021-02-01 16:58:20 +01:00
verify_migration && try_disabling_access_compat