install 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/bash
  2. # IMPORT GENERIC HELPERS
  3. source _common.sh
  4. source /usr/share/yunohost/helpers
  5. # INITIALIZE AND STORE SETTINGS
  6. # @@ todo do we need to store the password un-encrypted somewhere on the system?
  7. ynh_app_setting_set --app=$app --key=password_couchdb_admin --value="$password_couchdb_admin"
  8. # INSTALL COUCHDB
  9. # @@ todo
  10. # https://codeberg.org/ChriChri/flohmarkt_ynh/issues/9
  11. # check if couchdb is already installed
  12. # get port, admin_pw for already installed couchdb
  13. # skip the installation steps below
  14. ynh_script_progression --message="Installing CouchDB..." --weight=60
  15. # @@ todo: why is 'cookie string' and 'admin password' below the same?
  16. echo "\
  17. couchdb couchdb/mode select standalone
  18. couchdb couchdb/mode seen true
  19. couchdb couchdb/bindaddress string 127.0.0.1
  20. couchdb couchdb/bindaddress seen true
  21. couchdb couchdb/cookie string $password_couchdb_admin
  22. couchdb couchdb/adminpass password $password_couchdb_admin
  23. couchdb couchdb/adminpass seen true
  24. couchdb couchdb/adminpass_again password $password_couchdb_admin
  25. couchdb couchdb/adminpass_again seen true" | debconf-set-selections
  26. DEBIAN_FRONTEND=noninteractive # apt-get install -y --force-yes couchdb
  27. ynh_install_extra_app_dependencies \
  28. --repo="deb https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -c -s) main" \
  29. --key="https://couchdb.apache.org/repo/keys.asc" \
  30. --package="couchdb"
  31. # add couchdb configuration
  32. ynh_script_progression --message="Adding a configuration file..." --weight=2
  33. # customize couchdb config
  34. ynh_add_config --template="../conf/couch_ynh.ini" --destination="/opt/couchdb/etc/local.d/couch_ynh.ini"
  35. chmod 750 "$install_dir"
  36. chmod -R o-rwx "$install_dir"
  37. chown -R "$app:$app" "$install_dir"
  38. # get flohmarkt
  39. ynh_setup_source --dest_dir="$install_dir"
  40. # setup python environment for flohmarkt
  41. ynh_secure_remove "$install_dir/venv"
  42. python3 -m venv --without-pip "$install_dir/venv"
  43. # install python dependencies
  44. (
  45. set +o nounset
  46. source "$install_dir/venv/bin/activate"
  47. set -o nounset
  48. set -x
  49. ynh_exec_as $app $data_dir/venv/bin/python3 -m ensurepip
  50. ynh_exec_as $app $data_dir/venv/bin/pip3 install -r "$install_dir/flohmarkt/requirements.txt"
  51. )
  52. # @@ configure
  53. # SETUP LOGROTATE
  54. ynh_script_progression --message="Configuring log rotation..." --weight=2
  55. # Use logrotate to manage application logfile(s)
  56. # @@ how does this know where the logfiles are?
  57. ynh_use_logrotate
  58. # NGINX CONFIGURATION
  59. ynh_script_progression --message="Configuring NGINX web server..." --weight=3
  60. # Create a dedicated NGINX config
  61. ynh_add_nginx_config
  62. # INTEGRATE SERVICE IN YUNOHOST
  63. ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
  64. yunohost service add $app --description="Open-source document-oriented NoSQL database" --log="/var/log/$app/$app.log" --needs_exposed_ports "$port"
  65. # SETUP FAIL2BAN
  66. # no need for couchdb, because it will not listen externally
  67. # ynh_script_progression --message="Configuring Fail2Ban..." --weight=3
  68. #
  69. # # Create a dedicated Fail2Ban config
  70. # ynh_add_fail2ban_config --logpath="/var/log/couchdb/couchdb.log" --failregex="[warning] .*couch_httpd_auth: Authentication failed for user .+ from <HOST>" --max_retry=5
  71. # qed
  72. ynh_script_progression --message="Installation of $app completed" --last