1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/sonarr_ynh.git synced 2024-09-03 20:26:19 +02:00

finalize port

This commit is contained in:
Salamandar 2024-02-05 23:31:26 +01:00
parent 5bc3d2d8d4
commit e487cfaa3d
5 changed files with 39 additions and 36 deletions

View file

@ -21,16 +21,22 @@ ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE DATA DIR
#=================================================
ynh_backup --src_path="$data_dir"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP VARIOUS FILES
#=================================================

View file

@ -30,12 +30,10 @@ ynh_change_url_nginx_config
#=================================================
# UPDATE CONFIGURATION FILE
#=================================================
#REMOVEME?
path=$new_path
ynh_exec_warn_less ynh_add_config --template="../conf/config.xml" --destination="$install_dir/config.xml"
ynh_exec_warn_less ynh_add_config --template="config.xml" --destination="$data_dir/config.xml"
chown $app:$app "$install_dir/config.xml"
chown "$app:$app" "$data_dir/config.xml"
#=================================================
# GENERIC FINALISATION
@ -44,7 +42,8 @@ chown $app:$app "$install_dir/config.xml"
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Starting Web Server"
# Start a systemd service
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Application started."
#=================================================
# END OF SCRIPT

View file

@ -16,7 +16,7 @@ ynh_script_progression --message="Removing system configurations related to $app
# 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
yunohost service remove "$app"
yunohost service remove "$app"
fi
# Remove the dedicated systemd config

View file

@ -15,14 +15,19 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=2
# Remove the version installed by the deb package
ynh_secure_remove "$install_dir"
ynh_restore_file --origin_path="$install_dir"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:$app" "$install_dir"
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_restore_file --origin_path="$data_dir" --not_mandatory
chown -R "$app:$app" "$data_dir"
#=================================================
# YUNOHOST MULTIMEDIA INTEGRATION
#=================================================
@ -59,22 +64,10 @@ ynh_restore_file --origin_path="/var/log/$app/"
#=================================================
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Starting Web Server" --timeout=30
# If a first Sonarr app was running before installing this one,
# it may have been stopped by the installation of the dependencies.
# Let's restart it.
if ! systemctl is-active "$app.service"; then
ynh_exec_fully_quiet ynh_systemd_action --service_name=sonarr --action="start" --log_path="systemd" --line_match="Starting Web Server" --timeout=30
fi
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Application started." --timeout=30
ynh_systemd_action --service_name=nginx --action=reload
ynh_exec_warn ls -lah "$install_dir"
ynh_exec_warn cat "$install_dir/config.xml"
ynh_exec_warn cat "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -23,12 +23,24 @@ ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd"
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
if [ -d "$install_dir/logs" ]; then
if [ -d "$data_dir/logs" ]; then
ynh_secure_remove --file="/var/log/$app"
mv "$install_dir/logs" "/var/log/$app"
ln -s "/var/log/$app" "$install_dir/logs"
mv "$data_dir/logs" "/var/log/$app"
ln -s "/var/log/$app" "$data_dir/logs"
fi
#=================================================
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from manifest.toml
ynh_setup_source --dest_dir="$install_dir" --full_replace=1
chown -R "$app:$app" "$install_dir"
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
@ -49,14 +61,7 @@ ynh_use_logrotate --non-append --logfile="/var/log/$app/"
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Starting Web Server" --timeout=30
# If a first Sonarr app was running before installing this one,
# it may have been stopped by the installation of the dependencies.
# Let's restart it. (hence why we use sonarr and not $app..)
if ! systemctl -q is-active sonarr; then
ynh_exec_fully_quiet ynh_systemd_action --service_name=sonarr --action="restart" --log_path="systemd" --line_match="Starting Web Server" --timeout=30
fi
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Application started." --timeout=30
#=================================================
# END OF SCRIPT