1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/archivist_ynh.git synced 2024-09-03 18:15:55 +02:00
archivist_ynh/scripts/upgrade

86 lines
2.5 KiB
Text
Raw Normal View History

2017-11-01 20:57:58 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path)
frequency=$(ynh_app_setting_get $app frequency)
2017-12-16 23:06:00 +01:00
#=================================================
# CHECK VERSION
#=================================================
ynh_abort_if_up_to_date
2017-11-01 20:57:58 +01:00
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPDATE THE CRON FILE
#=================================================
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different "/etc/cron.d/$app"
cp ../conf/cron /etc/cron.d/$app
ynh_replace_string "__FINALPATH__" "$final_path" /etc/cron.d/$app
ynh_replace_string "__APP__" "$app" /etc/cron.d/$app
if [ "$frequency" = "Daily" ]; then
2017-11-03 17:19:04 +01:00
cron_freq="0 2 * * *"
2017-11-01 20:57:58 +01:00
elif [ "$frequency" = "Each 3 days" ]; then
2017-11-03 17:19:04 +01:00
cron_freq="0 2 */3 * *"
2017-11-01 20:57:58 +01:00
elif [ "$frequency" = "Weekly" ]; then
2017-11-03 17:19:04 +01:00
cron_freq="0 2 * * 0"
2017-11-01 20:57:58 +01:00
elif [ "$frequency" = "Biweekly" ]; then
2017-11-03 17:19:04 +01:00
cron_freq="0 2 * * 0/2"
2017-11-01 20:57:58 +01:00
else # Monthly
2017-11-03 17:19:04 +01:00
cron_freq="0 2 1 * *"
2017-11-01 20:57:58 +01:00
fi
ynh_replace_string "__FREQUENCY__" "$cron_freq" /etc/cron.d/$app
# Recalculate and store the config file checksum into the app settings
ynh_store_file_checksum "/etc/cron.d/$app"
#=================================================
# SETUP LOGROTATE
#=================================================
# Use logrotate to manage app-specific logfile(s)
2017-12-16 23:06:00 +01:00
ynh_use_logrotate --non-append
2017-11-01 20:57:58 +01:00
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set right permissions for curl installation
chown -R root: $final_path