123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- #!/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)
- phpversion=$(ynh_app_setting_get $app phpversion)
- #=================================================
- # SPECIAL UPGRADE FOR VERSIONS < 1.2.0
- #=================================================
- # Apply renaming that occured in v1.2.0 ("vpnadmin" -> "${app}")
- if [ -f /etc/nginx/conf.d/${domain}.d/vpnadmin.conf ]; then
- ynh_replace_string "/var/www/vpnadmin/" "/var/www/${app}/" "/etc/nginx/conf.d/${domain}.d/vpnadmin.conf"
- ynh_replace_string "vpnadmin.sock" "${app}.sock" "/etc/nginx/conf.d/${domain}.d/vpnadmin.conf"
- mv /etc/nginx/conf.d/${domain}.d/vpnadmin.conf /etc/nginx/conf.d/${domain}.d/${app}.conf
- fi
- if [ -f /etc/php/$phpversion/fpm/pool.d/vpnadmin.conf ]; then
- ynh_replace_string "/var/www/vpnadmin/" "/var/www/${app}/" /etc/php/$phpversion/fpm/pool.d/vpnadmin.conf
- ynh_replace_string "vpnadmin.sock" "${app}.sock" /etc/php/$phpversion/fpm/pool.d/vpnadmin.conf
- mv /etc/php/$phpversion/fpm/pool.d/vpnadmin.conf /etc/php/$phpversion/fpm/pool.d/${app}.conf
- fi
- 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
- # 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"
|