1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/httpsh_ynh.git synced 2024-09-03 19:25:55 +02:00

Cleanup a bit

This commit is contained in:
Félix Piédallu 2024-01-31 16:07:17 +01:00
parent 8df7dacdf0
commit 0d6c83569f
5 changed files with 29 additions and 84 deletions

View file

@ -22,31 +22,23 @@ ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="$install_dir" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # SYSTEM CONFIGURATION
#================================================= #=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= ynh_backup --src_path="/etc/systemd/system/$app.service"
# BACKUP FAIL2BAN CONFIGURATION
#================================================= ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
#================================================= #=================================================
# SPECIFIC BACKUP # BACKUP VARIOUS FILES
#=================================================
# BACKUP LOGROTATE
#================================================= #=================================================
ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/var/log/$app/"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -18,10 +18,11 @@ ynh_script_progression --message="Setting up source files..." --weight=1
ynh_setup_source --source_id=ttyd --dest_dir="$install_dir" ynh_setup_source --source_id=ttyd --dest_dir="$install_dir"
chmod +x "$install_dir/ttyd" chmod +x "$install_dir/ttyd"
ynh_setup_source --source_id=httpsh --dest_dir="$install_dir/httpsh"
# TODO: copy files where needed # 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" 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" ynh_add_config --template="../conf/ttyd_httpsh.conf" --destination="$install_dir/ttyd_httpsh.conf"
@ -39,14 +40,10 @@ ynh_add_systemd_config
yunohost service add "$app" --description="httpsh on ttyd web terminal" --log="/var/log/$app/$app.log" yunohost service add "$app" --description="httpsh on ttyd web terminal" --log="/var/log/$app/$app.log"
mkdir "/var/log/$app" ynh_use_logrotate
touch "/var/log/$app/$app.log"
chown -R "$app:$app" "/var/log/$app" chown -R "$app:$app" "/var/log/$app"
chmod 750 "/var/log/$app" chmod 750 "/var/log/$app"
ynh_use_logrotate
ynh_add_fail2ban_config --logpath="/var/log/$app/$app.log" --failregex="^error: maximum authentication attempts exceeded for <F-USER>.*</F-USER> from <HOST>$" ynh_add_fail2ban_config --logpath="/var/log/$app/$app.log" --failregex="^error: maximum authentication attempts exceeded for <F-USER>.*</F-USER> from <HOST>$"
#================================================= #=================================================

View file

@ -16,12 +16,8 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# This should be a symetric version of what happens in the install script
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) # Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status "$app" >/dev/null if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
then
ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove "$app" yunohost service remove "$app"
fi fi

View file

@ -18,7 +18,6 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$install_dir" ynh_restore_file --origin_path="$install_dir"
chown -R "$app:$app" "$install_dir" chown -R "$app:$app" "$install_dir"
chmod 750 "$install_dir"
#================================================= #=================================================
# RESTORE SYSTEM CONFIGURATIONS # RESTORE SYSTEM CONFIGURATIONS
@ -32,19 +31,19 @@ systemctl enable "$app.service" --quiet
yunohost service add "$app" --description="httpsh on ttyd web terminal" --log="/var/log/$app/$app.log" yunohost service add "$app" --description="httpsh on ttyd web terminal" --log="/var/log/$app/$app.log"
mkdir "/var/log/$app"
touch "/var/log/$app/$app.log"
chown -R "$app:$app" "/var/log/$app"
chmod 750 "/var/log/$app"
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf" ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
ynh_systemd_action --action=restart --service_name=fail2ban ynh_systemd_action --action=restart --service_name=fail2ban
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_restore_file --origin_path="/var/log/$app/"
chown -R "$app:$app" "/var/log/$app"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================

View file

@ -9,33 +9,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
#ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
#
# N.B. : the following setting migration snippets are provided as *EXAMPLES*
# of what you may want to do in some cases (e.g. a setting was not defined on
# some legacy installs and you therefore want to initiaze stuff during upgrade)
#
# If db_name doesn't exist, create it
#if [ -z "$db_name" ]; then
# db_name=$(ynh_sanitize_dbid --db_name=$app)
# ynh_app_setting_set --app=$app --key=db_name --value=$db_name
#fi
# If install_dir doesn't exist, create it
#if [ -z "$install_dir" ]; then
# install_dir=/var/www/$app
# ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
#fi
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
@ -48,16 +21,18 @@ ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$a
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Upgrading source files..." --weight=1
if [ "$upgrade_type" == "UPGRADE_APP" ] # Download, check integrity, uncompress and patch the source from app.src
then ynh_setup_source --source_id=ttyd --dest_dir="$install_dir"
ynh_script_progression --message="Upgrading source files..." --weight=1 chmod +x "$install_dir/ttyd"
# Download, check integrity, uncompress and patch the source from app.src # Get only the ttyd-login script
ynh_setup_source --source_id=ttyd --dest_dir="$install_dir" ynh_setup_source --source_id=httpsh --dest_dir="$install_dir/httpsh"
chmod +x "$install_dir/ttyd" mv "$install_dir/httpsh/usr/local/bin/ttyd-login" "$install_dir/httpsh-ttyd-login"
ynh_setup_source --source_id=httpsh --dest_dir="$install_dir/httpsh" ynh_secure_remove --file="$installdir/httpsh"
fi
ynh_add_config --template="../conf/ttyd_httpsh.conf" --destination="$install_dir/ttyd_httpsh.conf"
chown -R "$app:$app" "$install_dir" chown -R "$app:$app" "$install_dir"
chmod 750 "$install_dir" chmod 750 "$install_dir"
@ -74,24 +49,10 @@ ynh_add_systemd_config
yunohost service add "$app" --description="httpsh on ttyd web terminal" --log="/var/log/$app/$app.log" yunohost service add "$app" --description="httpsh on ttyd web terminal" --log="/var/log/$app/$app.log"
ynh_use_logrotate --non-append ynh_use_logrotate --non-append
chown -R "$app:$app" "/var/log/$app"
ynh_add_fail2ban_config --logpath="/var/log/$app/$app.log" --failregex="^error: maximum authentication attempts exceeded for <F-USER>.*</F-USER> from <HOST>$" ynh_add_fail2ban_config --logpath="/var/log/$app/$app.log" --failregex="^error: maximum authentication attempts exceeded for <F-USER>.*</F-USER> from <HOST>$"
#=================================================
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1
# TODO: copy files where needed
mv "$install_dir/httpsh/usr/local/bin/ttyd-login" "$install_dir/httpsh"
ynh_add_config --template="../conf/ttyd_httpsh.conf" --destination="$install_dir/ttyd_httpsh.conf"
chown -R "$app:$app" "/var/log/$app"
chmod 750 "/var/log/$app"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================