2023-09-21 15:11:59 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
2023-09-21 16:53:53 +02:00
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
2023-09-21 15:11:59 +02:00
#=================================================
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2024-01-31 16:07:17 +01:00
ynh_script_progression --message="Upgrading source files..." --weight=1
2023-09-21 15:11:59 +02:00
2024-01-31 16:07:17 +01:00
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --source_id=ttyd --dest_dir="$install_dir"
chmod +x "$install_dir/ttyd"
2023-09-21 15:11:59 +02:00
2024-01-31 16:07:17 +01:00
# Get only the ttyd-login script
ynh_setup_source --source_id=httpsh --dest_dir="$install_dir/httpsh"
mv "$install_dir/httpsh/usr/local/bin/ttyd-login" "$install_dir/httpsh-ttyd-login"
ynh_secure_remove --file="$installdir/httpsh"
ynh_add_config --template="../conf/ttyd_httpsh.conf" --destination="$install_dir/ttyd_httpsh.conf"
2023-09-21 15:11:59 +02:00
2024-01-31 16:01:32 +01:00
chown -R "$app:$app" "$install_dir"
chmod 750 "$install_dir"
2023-09-21 15:11:59 +02:00
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
ynh_add_nginx_config
ynh_add_systemd_config
2023-09-26 21:21:32 +02:00
yunohost service add "$app" --description="httpsh on ttyd web terminal" --log="/var/log/$app/$app.log"
2023-09-21 15:11:59 +02:00
ynh_use_logrotate --non-append
2024-01-31 16:07:17 +01:00
chown -R "$app:$app" "/var/log/$app"
2023-09-21 15:11:59 +02:00
2023-09-26 21:21:32 +02:00
ynh_add_fail2ban_config --logpath="/var/log/$app/$app.log" --failregex="^error: maximum authentication attempts exceeded for <F-USER>.*</F-USER> from <HOST>$"
2023-09-21 15:11:59 +02:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
2023-09-21 16:53:53 +02:00
ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
2023-09-21 15:11:59 +02:00
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last