upgrade 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/bash
  2. #=================================================
  3. # GENERIC START
  4. #=================================================
  5. # IMPORT GENERIC HELPERS
  6. #=================================================
  7. source _common.sh
  8. source /usr/share/yunohost/helpers
  9. upgrade_type=$(ynh_check_app_version_changed)
  10. #=================================================
  11. # NGINX CONFIGURATION
  12. #=================================================
  13. ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
  14. # Create a dedicated NGINX config
  15. ynh_add_nginx_config
  16. #=================================================
  17. # SPECIFIC UPGRADE
  18. #=================================================
  19. # UPGRADING COUCHDB
  20. #=================================================
  21. if [ "$upgrade_type" == "UPGRADE_APP" ]
  22. then
  23. ynh_script_progression --message="Upgrading CouchDB..." --weight=50
  24. echo "\
  25. couchdb couchdb/mode select standalone
  26. couchdb couchdb/mode seen true
  27. couchdb couchdb/bindaddress string 127.0.0.1
  28. couchdb couchdb/bindaddress seen true
  29. couchdb couchdb/cookie string $password
  30. couchdb couchdb/adminpass password $password
  31. couchdb couchdb/adminpass seen true
  32. couchdb couchdb/adminpass_again password $password
  33. couchdb couchdb/adminpass_again seen true" | debconf-set-selections
  34. DEBIAN_FRONTEND=noninteractive # apt-get install -y --force-yes couchdb
  35. ynh_install_extra_app_dependencies \
  36. --repo="deb https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -c -s) main" \
  37. --key="https://couchdb.apache.org/repo/keys.asc" \
  38. --package="couchdb"
  39. fi
  40. #=================================================
  41. # UPDATE A CONFIG FILE
  42. #=================================================
  43. ynh_script_progression --message="Updating a configuration file..." --weight=1
  44. ynh_add_config --template="../conf/05-flohmarkt.ini" --destination="$install_dir/etc/local.d/05-flohmarkt.ini"
  45. chmod 750 "$install_dir"
  46. chmod -R o-rwx "$install_dir"
  47. chown -R "$app:$app" "$install_dir"
  48. #=================================================
  49. # GENERIC FINALIZATION
  50. #=================================================
  51. # SETUP LOGROTATE
  52. #=================================================
  53. ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
  54. # Use logrotate to manage app-specific logfile(s)
  55. ynh_use_logrotate --non-append
  56. #=================================================
  57. # INTEGRATE SERVICE IN YUNOHOST
  58. #=================================================
  59. ynh_script_progression --message="Integrating service in YunoHost..." --weight=2
  60. yunohost service add $app --description="A decentral federated small advertisement platform" --log="/var/log/$app/$app.log"
  61. #=================================================
  62. # UPGRADE FAIL2BAN
  63. #=================================================
  64. ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=3
  65. # Create a dedicated Fail2Ban config
  66. ynh_add_fail2ban_config --logpath="/var/log/couchdb/couchdb.log" --failregex="[warning] .*couch_httpd_auth: Authentication failed for user .+ from <HOST>" --max_retry=5
  67. #=================================================
  68. # END OF SCRIPT
  69. #=================================================
  70. ynh_script_progression --message="Upgrade of $app completed" --last