1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/timemachine_ynh.git synced 2024-09-03 20:26:33 +02:00
timemachine_ynh/scripts/upgrade

112 lines
3.7 KiB
Text
Raw Normal View History

2022-06-15 09:54:44 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
2022-07-13 04:01:56 +02:00
ynh_script_progression --message="Loading installation settings..." --weight=1
2022-06-15 09:54:44 +02:00
app=$YNH_APP_INSTANCE_NAME
admin=$(ynh_app_setting_get --app=$app --key=admin)
2022-07-13 04:01:56 +02:00
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
2022-06-15 09:54:44 +02:00
#=================================================
# CHECK VERSION
#=================================================
2022-07-13 04:01:56 +02:00
ynh_script_progression --message="Checking version..."
2022-06-15 09:54:44 +02:00
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
2022-07-13 04:01:56 +02:00
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
2022-06-15 09:54:44 +02:00
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
2022-07-13 04:01:56 +02:00
ynh_clean_check_starting
2022-06-15 09:54:44 +02:00
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
2022-07-13 04:01:56 +02:00
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
2022-06-15 09:54:44 +02:00
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
2022-07-13 04:01:56 +02:00
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
2022-06-15 09:54:44 +02:00
# Create a dedicated user (if not existing)
2022-06-15 15:59:09 +02:00
ynh_system_user_create --username=$app
2022-06-15 09:54:44 +02:00
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
2022-07-13 04:01:56 +02:00
ynh_script_progression --message="Upgrading dependencies..." --weight=1
2022-06-15 09:54:44 +02:00
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPDATE A CONFIG FILE
#=================================================
2022-07-13 04:01:56 +02:00
ynh_script_progression --message="Updating a configuration file..." --weight=1
2022-06-15 09:54:44 +02:00
2022-06-15 15:30:00 +02:00
ynh_add_config --template="../conf/smb.conf" --destination="/etc/smb/smb.d/$app.conf"
ynh_add_config --template="../conf/avahi-samba.service" --destination="/etc/avahi/services/$app.service"
2022-06-15 09:54:44 +02:00
2022-06-15 15:46:21 +02:00
samba_sysadmin_update
samba_sysadmin_add
2022-07-13 04:01:56 +02:00
#=================================================
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add smbd --needs_exposed_ports 445
yunohost service add avahi-daemon
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=smbd --action="reload"
ynh_systemd_action --service_name=avahi-daemon --action="restart"
2022-06-15 09:54:44 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2022-07-13 04:01:56 +02:00
ynh_script_progression --message="Upgrade of $app completed" --last