mirror of
https://github.com/YunoHost-Apps/prowlarr_ynh.git
synced 2024-09-03 20:16:07 +02:00
Cleanup for version 2
This commit is contained in:
parent
587b44bf5e
commit
1f860f5147
7 changed files with 65 additions and 117 deletions
|
@ -61,6 +61,7 @@ ram.runtime = "50M"
|
|||
[resources.install_dir]
|
||||
|
||||
[resources.data_dir]
|
||||
subdirs = ["logs"]
|
||||
|
||||
[resources.ports]
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -9,12 +7,10 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||
ynh_script_progression --message="Stopping $app's systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
|
||||
|
||||
|
@ -25,22 +21,18 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
|
|||
|
||||
ynh_change_url_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
# UPDATE CONFIGURATION FILE
|
||||
#=================================================
|
||||
|
||||
ynh_replace_string --match_string="<UrlBase>$old_path</UrlBase>" --replace_string="<UrlBase>$new_path</UrlBase>" --target_file="$data_dir/config.xml"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="CommandExecutor: Starting"
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="CommandExecutor: Starting"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -9,8 +7,12 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# INITIALIZE AND STORE SETTINGS
|
||||
#=================================================
|
||||
|
||||
api_key=$(ynh_string_random --length=32)
|
||||
ynh_app_setting_set --app=$app --key=api_key --value=$api_key
|
||||
ynh_app_setting_set --app="$app" --key=api_key --value="$api_key"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
|
@ -18,31 +20,19 @@ ynh_app_setting_set --app=$app --key=api_key --value=$api_key
|
|||
ynh_script_progression --message="Setting up source files..." --weight=3
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
mkdir -p "$data_dir/logs"
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app: "$install_dir"
|
||||
chown -R "$app:" "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
# APP INITIAL CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring Prowlarr..." --weight=2
|
||||
ynh_script_progression --message="Adding $app's configuration files..." --weight=1
|
||||
|
||||
ynh_add_config --template="config.xml" --destination="$data_dir/config.xml"
|
||||
chmod 400 "$data_dir/config.xml"
|
||||
chown $app:$app "$data_dir/config.xml"
|
||||
chown "$app:$app" "$data_dir/config.xml"
|
||||
|
||||
#=================================================
|
||||
# YUNOHOST MULTIMEDIA INTEGRATION
|
||||
|
@ -52,33 +42,31 @@ ynh_script_progression --message="Adding multimedia directories..." --weight=2
|
|||
# Build YunoHost multimedia directories
|
||||
ynh_multimedia_build_main_dir
|
||||
# Enable writing into these directories
|
||||
ynh_multimedia_addaccess $app
|
||||
ynh_multimedia_addaccess "$app"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring log rotation..." --weight=1
|
||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
yunohost service add "$app" --description="Prowlarr daemon" --log="$data_dir/logs/prowlarr.txt"
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
ynh_use_logrotate --logfile="$data_dir/logs"
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
yunohost service add $app --description="Prowlarr daemon" --log="$data_dir/logs/prowlarr.txt"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=2
|
||||
ynh_script_progression --message="Starting $app's systemd service..." --weight=2
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="CommandExecutor: Starting"
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="CommandExecutor: Starting"
|
||||
|
||||
# FIXME Update config.xml checksum, for a mere file ending with or without a new line...
|
||||
ynh_store_file_checksum --file="$data_dir/config.xml"
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -9,18 +7,14 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# REMOVE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
# REMOVE SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
||||
|
||||
# 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
|
||||
yunohost service remove $app
|
||||
if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
|
||||
yunohost service remove "$app"
|
||||
fi
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -18,21 +16,7 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
|
|||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app: "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service --quiet
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
|
||||
yunohost service add $app --description="Prowlarr daemon" --log="$data_dir/logs/prowlarr.txt"
|
||||
chown -R "$app:" "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# YUNOHOST MULTIMEDIA INTEGRATION
|
||||
|
@ -42,14 +26,27 @@ ynh_script_progression --message="Adding multimedia directories..." --weight=2
|
|||
# Build YunoHost multimedia directories
|
||||
ynh_multimedia_build_main_dir
|
||||
# Enable writing into these directories
|
||||
ynh_multimedia_addaccess $app
|
||||
ynh_multimedia_addaccess "$app"
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
systemctl enable "$app.service" --quiet
|
||||
yunohost service add "$app" --description="Prowlarr daemon" --log="$data_dir/logs/prowlarr.txt"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=2
|
||||
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="CommandExecutor: Starting"
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="CommandExecutor: Starting"
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
@ -62,6 +59,6 @@ ynh_store_file_checksum --file="$data_dir/config.xml"
|
|||
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
|
||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||
if [ "${PACKAGE_CHECK_EXEC:-0}" -eq 1 ]; then
|
||||
sleep 5
|
||||
fi
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -9,35 +7,33 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||
ynh_script_progression --message="Stopping $app's systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
|
||||
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=3
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=3
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
fi
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir" --full_replace=1
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app: "$install_dir"
|
||||
chown -R "$app:" "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating the configuration file..." --weight=1
|
||||
|
||||
ynh_add_config --template="config.xml" --destination="$data_dir/config.xml"
|
||||
|
||||
chmod 400 "$data_dir/config.xml"
|
||||
chown "$app:$app" "$data_dir/config.xml"
|
||||
|
||||
#=================================================
|
||||
# REAPPLY SYSTEM CONFIGURATIONS
|
||||
|
@ -49,25 +45,7 @@ ynh_add_nginx_config
|
|||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
yunohost service add $app --description="Prowlarr daemon" --log="$data_dir/logs/prowlarr.txt"
|
||||
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating the configuration file..." --weight=1
|
||||
|
||||
ynh_add_config --template="config.xml" --destination="$data_dir/config.xml"
|
||||
|
||||
chmod 400 "$data_dir/config.xml"
|
||||
chown $app:$app "$data_dir/config.xml"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
|
||||
yunohost service add "$app" --description="Prowlarr daemon" --log="$data_dir/logs/prowlarr.txt"
|
||||
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --non-append
|
||||
|
@ -76,9 +54,9 @@ ynh_use_logrotate --non-append --logfile="$data_dir/logs"
|
|||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=2
|
||||
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="CommandExecutor: Starting"
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="CommandExecutor: Starting"
|
||||
|
||||
# FIXME Update config.xml checksum, for a mere file ending with or without a new line...
|
||||
ynh_store_file_checksum --file="$data_dir/config.xml"
|
||||
|
|
Loading…
Add table
Reference in a new issue