[mod] install and upgrade scripts share some common code.

This commit is contained in:
pitchum
2018-06-08 14:31:46 +02:00
committed by pitchum
parent 8cbe81be03
commit abce6aef00
3 changed files with 128 additions and 97 deletions

View File

@@ -54,6 +54,29 @@ ynh_clean_setup () {
# 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)
sudo cp -r /etc/openvpn/client* ${tmpdir}
# Deploy files from package
vpnclient_deploy_files_and_services
# Restore previously existing config files
sudo cp -r ${tmpdir}/client* /etc/openvpn/
sudo rm -rf ${tmpdir}
#=================================================
# RELOAD RELEVANT SERVICES
#=================================================
@@ -61,4 +84,6 @@ ynh_abort_if_errors
ynh_systemctl reload php5-fpm
ynh_systemctl reload nginx
ynh_systemctl restart ynh-vpnclient
exit 0