2023-12-13 21:25:13 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2023-12-14 11:50:23 +01:00
|
|
|
secret=$(ynh_string_random --length=50)
|
|
|
|
email=$(ynh_user_get_info --username=$admin --key=mail)
|
|
|
|
timezone="$(cat /etc/timezone)"
|
|
|
|
|
2023-12-13 21:25:13 +01:00
|
|
|
#=================================================
|
|
|
|
# STOP SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2024-06-23 21:23:05 +02:00
|
|
|
ynh_script_progression "Stopping $app's systemd service..."
|
2023-12-13 21:25:13 +01:00
|
|
|
|
2024-06-23 21:23:05 +02:00
|
|
|
ynh_systemctl --service=$app --action="stop" --log_path="systemd"
|
2023-12-13 21:25:13 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...)
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2024-06-23 21:23:05 +02:00
|
|
|
ynh_script_progression "Upgrading source files..."
|
2023-12-13 21:25:13 +01:00
|
|
|
|
2024-03-19 12:34:08 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir" --keep=".env"
|
2023-12-13 21:25:13 +01:00
|
|
|
|
2023-12-13 23:01:52 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
2023-12-13 21:25:13 +01:00
|
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
|
|
|
#=================================================
|
2024-06-23 21:23:05 +02:00
|
|
|
ynh_script_progression "Upgrading system configurations related to $app..."
|
2023-12-13 21:25:13 +01:00
|
|
|
|
2024-06-23 21:23:05 +02:00
|
|
|
ynh_config_add_nginx
|
2023-12-13 21:25:13 +01:00
|
|
|
|
2024-06-23 21:23:05 +02:00
|
|
|
ynh_nodejs_install
|
2023-12-13 21:25:13 +01:00
|
|
|
|
2024-06-23 21:23:05 +02:00
|
|
|
ynh_config_add_systemd
|
2023-12-13 21:25:13 +01:00
|
|
|
|
|
|
|
yunohost service add $app --description="Realtime kanban board for workgroups" --log="/var/log/$app/$app.log"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
|
|
|
|
#=================================================
|
|
|
|
# UPDATE A CONFIG FILE
|
|
|
|
#=================================================
|
2024-06-23 21:23:05 +02:00
|
|
|
ynh_script_progression "Updating configuration..."
|
2023-12-13 21:25:13 +01:00
|
|
|
|
2024-06-23 21:23:05 +02:00
|
|
|
ynh_config_add --template=".env" --destination="$install_dir/.env"
|
2023-12-13 21:25:13 +01:00
|
|
|
|
|
|
|
chmod 400 "$install_dir/.env"
|
|
|
|
chown $app:$app "$install_dir/.env"
|
|
|
|
|
2023-12-15 14:24:23 +01:00
|
|
|
#=================================================
|
|
|
|
# INSTALL PLANKA
|
|
|
|
#=================================================
|
2024-06-23 21:23:05 +02:00
|
|
|
ynh_script_progression "Installing $app..."
|
2023-12-15 14:24:23 +01:00
|
|
|
|
|
|
|
pushd $install_dir
|
2024-06-23 21:23:05 +02:00
|
|
|
|
|
|
|
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
|
2023-12-15 14:24:23 +01:00
|
|
|
popd
|
|
|
|
|
2023-12-13 21:25:13 +01:00
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2024-06-23 21:23:05 +02:00
|
|
|
ynh_script_progression "Starting $app's systemd service..."
|
2023-12-13 21:25:13 +01:00
|
|
|
|
2024-06-23 21:23:05 +02:00
|
|
|
ynh_systemctl --service=$app --action="start" --log_path="systemd"
|
2023-12-13 21:25:13 +01:00
|
|
|
|
2023-12-15 15:08:46 +01:00
|
|
|
#=================================================
|
|
|
|
# ADD FAIL2BAN
|
|
|
|
#=================================================
|
|
|
|
|
2024-06-23 21:23:05 +02:00
|
|
|
ynh_config_add_fail2ban --logpath="$install_dir/logs/planka.log" --failregex="^(.*) Invalid (email or username:|password!) (\"(.*)\"!)? ?\(IP: <ADDR>\)$"
|
2023-12-15 15:08:46 +01:00
|
|
|
|
2023-12-13 21:25:13 +01:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2024-06-23 21:23:05 +02:00
|
|
|
ynh_script_progression "Upgrade of $app completed"
|