upgrade 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/bin/bash
  2. #=================================================
  3. # GENERIC STARTING
  4. #=================================================
  5. # IMPORT GENERIC HELPERS
  6. #=================================================
  7. source _common.sh
  8. source /usr/share/yunohost/helpers
  9. #=================================================
  10. # LOAD SETTINGS
  11. #=================================================
  12. app=$YNH_APP_INSTANCE_NAME
  13. domain=$(ynh_app_setting_get $app domain)
  14. path_url=$(ynh_app_setting_get $app path)
  15. is_public=$(ynh_app_setting_get $app is_public)
  16. final_path=$(ynh_app_setting_get $app final_path)
  17. server_name=$(ynh_app_setting_get $app server_name)
  18. #=================================================
  19. # SPECIAL UPGRADE FOR VERSIONS < 1.2.0
  20. #=================================================
  21. # Apply renaming that occured in v1.2.0 ("vpnadmin" -> "${app}")
  22. if [ -f /etc/nginx/conf.d/${domain}.d/vpnadmin.conf ]; then
  23. sed "s|/var/www/vpnadmin/|/var/www/${app}/|g" -i "/etc/nginx/conf.d/${domain}.d/vpnadmin.conf"
  24. sed "s|vpnadmin.sock|${app}.sock|g" -i "/etc/nginx/conf.d/${domain}.d/vpnadmin.conf"
  25. mv /etc/nginx/conf.d/${domain}.d/vpnadmin.conf /etc/nginx/conf.d/${domain}.d/${app}.conf
  26. fi
  27. if [ -f /etc/php5/fpm/pool.d/vpnadmin.conf ]; then
  28. sed "s|/var/www/vpnadmin/|/var/www/${app}/|g" -i /etc/php5/fpm/pool.d/vpnadmin.conf
  29. sed "s|vpnadmin.sock|${app}.sock|g" -i /etc/php5/fpm/pool.d/vpnadmin.conf
  30. mv /etc/php5/fpm/pool.d/vpnadmin.conf /etc/php5/fpm/pool.d/${app}.conf
  31. fi
  32. test -d /var/www/vpnadmin && mv /var/www/vpnadmin /var/www/${app}
  33. ## Versions known to have a buggy backup script
  34. #buggy_versions="1.0.0 1.0.1 1.1.0"
  35. #curr_version=$(read_manifest version)
  36. #if echo $buggy_versions | grep -w $curr_version > /dev/null; then
  37. # echo "Your current version of ${app} is very old: ${curr_version}. Please ignore the next warning." >&2
  38. #fi
  39. #
  40. ##=================================================
  41. ## BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
  42. ##=================================================
  43. #
  44. #ynh_backup_before_upgrade
  45. #ynh_clean_setup () {
  46. # ynh_restore_upgradebackup
  47. #}
  48. ## Exit if an error occurs during the execution of the script
  49. ynh_abort_if_errors
  50. #=================================================
  51. # DO UPGRADE
  52. #=================================================
  53. # INSTALL DEPENDENCIES
  54. #=================================================
  55. ynh_install_app_dependencies "$pkg_dependencies"
  56. #=================================================
  57. # DEPLOY FILES FROM PACKAGE
  58. #=================================================
  59. # Keep a copy of existing config files before overwriting them
  60. tmpdir=$(mktemp -d /tmp/vpnclient-upgrade-XXX)
  61. cp -r /etc/openvpn/client* ${tmpdir}
  62. # Deploy files from package
  63. vpnclient_deploy_files_and_services "${domain}" "${app}"
  64. # Restore previously existing config files
  65. cp -r ${tmpdir}/client* /etc/openvpn/
  66. ynh_secure_remove ${tmpdir}
  67. #=================================================
  68. # RELOAD RELEVANT SERVICES
  69. #=================================================
  70. ynh_systemctl reload php5-fpm
  71. ynh_systemctl reload nginx
  72. if systemctl is-active ynh-vpnclient >/dev/null;
  73. then
  74. ynh_systemctl restart ynh-vpnclient
  75. fi