diff --git a/scripts/backup b/scripts/backup index 95cec80..304f13c 100755 --- a/scripts/backup +++ b/scripts/backup @@ -22,31 +22,23 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$install_dir" #================================================= -# BACKUP THE NGINX CONFIGURATION +# SYSTEM CONFIGURATION #================================================= ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# BACKUP FAIL2BAN CONFIGURATION -#================================================= +ynh_backup --src_path="/etc/systemd/system/$app.service" + +ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" #================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE +# BACKUP VARIOUS FILES #================================================= -ynh_backup --src_path="/etc/logrotate.d/$app" - -#================================================= -# BACKUP SYSTEMD -#================================================= - -ynh_backup --src_path="/etc/systemd/system/$app.service" +ynh_backup --src_path="/var/log/$app/" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 4fd0fbb..ab65081 100755 --- a/scripts/install +++ b/scripts/install @@ -18,10 +18,11 @@ ynh_script_progression --message="Setting up source files..." --weight=1 ynh_setup_source --source_id=ttyd --dest_dir="$install_dir" 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" +ynh_secure_remove --file="$installdir/httpsh" 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" -mkdir "/var/log/$app" -touch "/var/log/$app/$app.log" - +ynh_use_logrotate chown -R "$app:$app" "/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 .* from $" #================================================= diff --git a/scripts/remove b/scripts/remove index 99a00e3..f1efe84 100755 --- a/scripts/remove +++ b/scripts/remove @@ -16,12 +16,8 @@ source /usr/share/yunohost/helpers #================================================= 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`) -if ynh_exec_warn_less yunohost service status "$app" >/dev/null -then - ynh_script_progression --message="Removing $app service integration..." --weight=1 +if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then yunohost service remove "$app" fi diff --git a/scripts/restore b/scripts/restore index 0626462..460460d 100755 --- a/scripts/restore +++ b/scripts/restore @@ -18,7 +18,6 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" chown -R "$app:$app" "$install_dir" -chmod 750 "$install_dir" #================================================= # 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" -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/fail2ban/jail.d/$app.conf" ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" 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 #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 676c622..410635f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,33 +9,6 @@ source _common.sh 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 #================================================= @@ -48,16 +21,18 @@ ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$a #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Upgrading source files..." --weight=1 -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Upgrading source files..." --weight=1 +# 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" - # 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" - ynh_setup_source --source_id=httpsh --dest_dir="$install_dir/httpsh" -fi +# 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" chown -R "$app:$app" "$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" 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 .* from $" -#================================================= -# 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 #=================================================