install 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. # @@ todo need to create a couchdb user and set the files to be readable/executable by it
  36. chmod 750 "$install_dir"
  37. chmod -R o-rwx "$install_dir"
  38. chown -R "$app:$app" "$install_dir"
  39. # get flohmarkt
  40. ynh_setup_source --dest_dir="$install_dir/$app/"
  41. # setup python environment for flohmarkt
  42. ynh_secure_remove "$install_dir/venv"
  43. python3 -m venv --without-pip "$install_dir/venv"
  44. # install python dependencies
  45. (
  46. set +o nounset
  47. source "$install_dir/venv/bin/activate"
  48. set -o nounset
  49. set -x
  50. $install_dir/venv/bin/python3 -m ensurepip
  51. $install_dir/venv/bin/pip3 install -r "$install_dir/$app/requirements.txt"
  52. )
  53. # @@ configure
  54. ynh_add_config --template="../conf/flohmarkt.ini" --destination="$install_dir/$app/flohmarkt.ini"
  55. # SETUP LOGROTATE
  56. ynh_script_progression --message="Configuring log rotation..." --weight=2
  57. # Use logrotate to manage application logfile(s)
  58. # @@ how does this know where the logfiles are?
  59. ynh_use_logrotate
  60. # NGINX CONFIGURATION
  61. ynh_script_progression --message="Configuring NGINX web server..." --weight=3
  62. # Create a dedicated NGINX config
  63. ynh_add_nginx_config
  64. # INTEGRATE SERVICE IN YUNOHOST
  65. ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
  66. yunohost service add $app --description="Open-source document-oriented NoSQL database" --log="/var/log/$app/$app.log" --needs_exposed_ports "$port"
  67. # SETUP FAIL2BAN
  68. # no need for couchdb, because it will not listen externally
  69. # ynh_script_progression --message="Configuring Fail2Ban..." --weight=3
  70. #
  71. # # Create a dedicated Fail2Ban config
  72. # ynh_add_fail2ban_config --logpath="/var/log/couchdb/couchdb.log" --failregex="[warning] .*couch_httpd_auth: Authentication failed for user .+ from <HOST>" --max_retry=5
  73. # qed
  74. ynh_script_progression --message="Installation of $app completed" --last