#!/bin/bash source _common.sh source /usr/share/yunohost/helpers secret=$(ynh_string_random --length=50) email=$(ynh_user_get_info --username=$admin --key=mail) timezone="$(cat /etc/timezone)" firstname=$(yunohost user list --fields firstname --output-as json | jq -r .users.$admin.firstname) lastname=$(yunohost user list --fields lastname --output-as json | jq -r .users.$admin.lastname) #================================================= # STORE SETTINGS FROM MANIFEST #================================================= ynh_script_progression "Storing installation settings..." ynh_app_setting_set --key=password --value="$password" ynh_app_setting_set --key=firstname --value=$firstname ynh_app_setting_set --key=lastname --value=$lastname #================================================= # INSTALL DEPENDENCIES #================================================= ynh_script_progression "Installing dependencies..." ynh_nodejs_install #================================================= # APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC) #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression "Setting up source files..." ynh_setup_source --dest_dir="$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= # SYSTEM CONFIGURATION #================================================= ynh_script_progression "Adding system configurations related to $app..." ynh_config_add_nginx ynh_config_add_systemd yunohost service add $app --description="Realtime kanban board for workgroups" --log="/var/log/$app/$app.log" #================================================= # APP INITIAL CONFIGURATION #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression "Adding $app's configuration..." ynh_config_add --template=".env" --destination="$install_dir/.env" chmod 400 "$install_dir/.env" chown $app:$app "$install_dir/.env" #================================================= # INSTALL PLANKA #================================================= ynh_script_progression "Installing $app..." pushd $install_dir ynh_hide_warnings ynh_exec_as_app node_load_PATH npm install ynh_hide_warnings ynh_exec_as_app node_load_PATH npm run db:init popd #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression "Starting $app's systemd service..." ynh_systemctl --service=$app --action="start" --log_path="systemd" #================================================= # ADD FAIL2BAN #================================================= ynh_config_add_fail2ban --logpath="$install_dir/logs/planka.log" --failregex="^(.*) Invalid (email or username:|password!) (\"(.*)\"!)? ?\(IP: \)$" #================================================= # END OF SCRIPT #================================================= ynh_script_progression "Installation of $app completed"