1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/weblate_ynh.git synced 2024-10-01 13:35:04 +02:00

add new helper ynh_check_if_checksum_is_different

This commit is contained in:
Jean-Baptiste Holcroft 2017-10-19 11:01:39 +02:00
parent 3736c4deca
commit 8b51355bce
2 changed files with 53 additions and 28 deletions

View file

@ -24,6 +24,20 @@ weblate_fill_settings() {
fi fi
} }
ynh_check_if_checksum_is_different() {
local file=$1
local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_'
local checksum_value=$(ynh_app_setting_get $app $checksum_setting_name)
local check=0
if ! echo "$checksum_value $file" | sudo md5sum -c --status
then # If the checksum is now different
check=1
fi
return "$check"
}
ynh_psql_test_if_first_run() { ynh_psql_test_if_first_run() {
if [ -f /etc/yunohost/psql ]; if [ -f /etc/yunohost/psql ];
then then

View file

@ -131,45 +131,56 @@ fi
"${final_path}/venv/bin/pip" install django_sendmail_backend "${final_path}/venv/bin/pip" install django_sendmail_backend
) )
# generate previous defaults settings check=$(ynh_check_if_checksum_is_different "$settings")
cp "$previous_version_file" "$old_settings"
weblate_fill_settings "$old_settings"
# store diff between defaults and local settings if [[ "$check" -eq 1 ]]
diff --unified "$old_settings" "$settings" > "$settings_diff" then
echo "Settings.py was modified localy, running diff before using the new default file for $current_version."
# generate previous defaults settings
cp "$previous_version_file" "$old_settings"
weblate_fill_settings "$old_settings"
# generate new defaults settings # store diff between defaults and local settings
cp ../conf/settings.py "$settings" diff --unified "$old_settings" "$settings" > "$settings_diff"
weblate_fill_settings "$settings"
# send diff to the server administrator # generate new defaults settings
mail_subject="'$app' settings diff from $previous_version to $current_version" cp ../conf/settings.py "$settings"
mail_message=" weblate_fill_settings "$settings"
Weblate was updated from version $previous_version to $current_version
A new settings.py has been created in: # send diff to the server administrator
$settings mail_subject="'$app' settings diff from $previous_version to $current_version"
mail_message="
Weblate was updated from version $previous_version to $current_version
You may have changed your defaults settings. A new settings.py has been created in:
To help you to apply it again, here is a diff file with every changes you did. $settings
Please note secret key is updated, this is normal. You may have changed your defaults settings.
To help you to apply it again, here is a diff file with every changes you did.
For any issue, please file a bug in: https://github.com/YunoHost-Apps/weblate_ynh Please note secret key is updated, this is normal.
"
echo "$mail_message" | mail -s "$mail_subject" root -u root -a "$settings_diff" For any issue, please file a bug in: https://github.com/YunoHost-Apps/weblate_ynh
"
# inform weblate's admin echo "$mail_message" | mail -s "$mail_subject" root -u root -a "$settings_diff"
mail_subject="'$app' was updated from $previous_version to $current_version"
mail_message="
Weblate was updated from version $previous_version to $current_version
A new settings.py has been created and a diff has been sent to root user. # inform weblate's admin
Your administrator may have to update your settings.py to have a fully working installation. mail_subject="'$app' was updated from $previous_version to $current_version"
" mail_message="
Weblate was updated from version $previous_version to $current_version
echo "$mail_subject" | mail -s "$mail_subject" "$admin_mail" A new settings.py has been created and a diff has been sent to root user.
Your administrator may have to update your settings.py to have a fully working installation.
"
echo "$mail_subject" | mail -s "$mail_subject" "$admin_mail"
else
echo "Settings.py was not modified, using the new default file for $current_version."
# generate new defaults settings
cp ../conf/settings.py "$settings"
weblate_fill_settings "$settings"
fi
#================================================= #=================================================
# Run migration scripts # Run migration scripts