#!/bin/bash #================================================= # GENERIC STARTING #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_app_setting_get $app path) is_public=$(ynh_app_setting_get $app is_public) final_path=$(ynh_app_setting_get $app final_path) #================================================= # SPECIAL UPGRADE FOR VERSIONS < 1.2.0 #================================================= # Removing configuration files with naming that occured in versions < 1.2.0 ("vpnadmin" instead off "$app") rm -f /etc/nginx/conf.d/${domain}.d/vpnadmin.conf 2>/dev/null rm -f /etc/php/*/fpm/pool.d/vpnadmin.conf 2>/dev/null if [ -d /var/www/vpnadmin ]; then mv /var/www/vpnadmin /var/www/${app} fi ## Versions known to have a buggy backup script #buggy_versions="1.0.0 1.0.1 1.1.0" #curr_version=$(read_manifest version) #if echo $buggy_versions | grep -w $curr_version > /dev/null; then # echo "Your current version of ${app} is very old: ${curr_version}. Please ignore the next warning." >&2 #fi # ##================================================= ## BACKUP BEFORE UPGRADE THEN ACTIVE TRAP ##================================================= # #ynh_backup_before_upgrade #ynh_clean_setup () { # ynh_restore_upgradebackup #} ## Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # DO UPGRADE #================================================= # INSTALL DEPENDENCIES #================================================= ynh_print_info "Installing dependencies..." ynh_install_app_dependencies "$pkg_dependencies" #================================================= # DEPLOY FILES FROM PACKAGE #================================================= # Keep a copy of existing config files before overwriting them tmpdir=$(mktemp -d /tmp/vpnclient-upgrade-XXX) cp -r /etc/openvpn/client* ${tmpdir} # Deploy files from package vpnclient_deploy_files_and_services # Restore previously existing config files cp -r ${tmpdir}/client* /etc/openvpn/ ynh_secure_remove ${tmpdir} #================================================= # SERVICE INTEGRATION IN YUNOHOST #================================================= ### Make sure that the yunohost services have a description and need-lock enabled # main service yunohost service add $service_name --description "Tunnels the internet traffic through a VPN" --need_lock --test_status="systemctl is-active openvpn@client.service" --log "/var/log/ynh-vpnclient.log" # checker service (this service was previously integrated in yunohost but we do not do this anymore) if ynh_exec_warn_less yunohost service status $service_checker_name >/dev/null then yunohost service remove $service_checker_name fi #================================================= # RESTART RELEVANT SERVICES #================================================= ynh_print_info "Restart services..." # this is meant to propagate the new files and configs systemctl -q is-active $service_name && yunohost service restart $service_name # Not sure if these are really necessary ... systemctl -q is-active $service_checker_name && systemctl restart $service_checker_name systemctl -q is-active $service_checker_name.timer && systemctl restart $service_checker_name.timer #================================================= # END OF SCRIPT #================================================= ynh_print_info "Upgrade of $app completed"