install 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. # @@ setup python environment for flohmarkt
  39. ynh_secure_remove "$data_dir/venv"
  40. python3 -m venv --without-pip "$data_dir/venv"
  41. # @@ get git
  42. # @@ install python dependencies
  43. # @@ configure
  44. # SETUP LOGROTATE
  45. ynh_script_progression --message="Configuring log rotation..." --weight=2
  46. # Use logrotate to manage application logfile(s)
  47. # @@ how does this know where the logfiles are?
  48. ynh_use_logrotate
  49. # NGINX CONFIGURATION
  50. ynh_script_progression --message="Configuring NGINX web server..." --weight=3
  51. # Create a dedicated NGINX config
  52. ynh_add_nginx_config
  53. # INTEGRATE SERVICE IN YUNOHOST
  54. ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
  55. yunohost service add $app --description="Open-source document-oriented NoSQL database" --log="/var/log/$app/$app.log" --needs_exposed_ports "$port"
  56. # SETUP FAIL2BAN
  57. # no need for couchdb, because it will not listen externally
  58. # ynh_script_progression --message="Configuring Fail2Ban..." --weight=3
  59. #
  60. # # Create a dedicated Fail2Ban config
  61. # ynh_add_fail2ban_config --logpath="/var/log/couchdb/couchdb.log" --failregex="[warning] .*couch_httpd_auth: Authentication failed for user .+ from <HOST>" --max_retry=5
  62. # qed
  63. ynh_script_progression --message="Installation of $app completed" --last