1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- #!/bin/bash
- #=================================================
- # GENERIC STARTING
- #=================================================
- # IMPORT GENERIC HELPERS
- #=================================================
- source _common.sh
- source /usr/share/yunohost/helpers
- #=================================================
- # LOAD 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)
- server_name=$(ynh_app_setting_get $app server_name)
- #=================================================
- # 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
- sed "s|/var/www/vpnadmin/|/var/www/${app}/|g" -i "/etc/nginx/conf.d/${domain}.d/vpnadmin.conf"
- sed "s|vpnadmin.sock|${app}.sock|g" -i "/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/php5/fpm/pool.d/vpnadmin.conf ]; then
- sed "s|/var/www/vpnadmin/|/var/www/${app}/|g" -i /etc/php5/fpm/pool.d/vpnadmin.conf
- sed "s|vpnadmin.sock|${app}.sock|g" -i /etc/php5/fpm/pool.d/vpnadmin.conf
- mv /etc/php5/fpm/pool.d/vpnadmin.conf /etc/php5/fpm/pool.d/${app}.conf
- fi
- test -d /var/www/vpnadmin && mv /var/www/vpnadmin /var/www/${app}
- ## 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_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 "${domain}" "${app}"
- # Restore previously existing config files
- cp -r ${tmpdir}/client* /etc/openvpn/
- ynh_secure_remove ${tmpdir}
- #=================================================
- # RELOAD RELEVANT SERVICES
- #=================================================
- ynh_systemctl reload php5-fpm
- ynh_systemctl reload nginx
- if systemctl is-active ynh-vpnclient >/dev/null;
- then
- ynh_systemctl restart ynh-vpnclient
- fi
|