mirror of
https://github.com/YunoHost-Apps/jellyfin_ynh.git
synced 2024-09-03 19:26:29 +02:00
Coding style, apply template
This commit is contained in:
parent
ab394adb64
commit
747351ab71
7 changed files with 80 additions and 180 deletions
|
@ -30,6 +30,11 @@ cache_path="/var/cache/$app"
|
|||
#=================================================
|
||||
|
||||
install_jellyfin_packages() {
|
||||
# Get version numbers from manifest UNUSED because update_version.py uses the hard-coded variables
|
||||
# pkg_version="$(ynh_app_upstream_version)"
|
||||
# ffmpeg_url="$(ynh_read_manifest --manifest_key="resources.sources.ffmpeg_${debian}.${YNH_ARCH}.url")"
|
||||
# ffmpeg_pkg_version="$(echo "$ffmpeg_url" | sed "s/.*\/jellyfin-ffmpeg[0-9]*_\([0-9.-]*\)-${debian}_${YNH_ARCH}.deb/\1/")"
|
||||
|
||||
# Create the temporary directory
|
||||
tempdir="$(mktemp -d)"
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -24,23 +22,13 @@ ynh_backup --src_path="$config_path"
|
|||
ynh_backup --src_path="/etc/default/jellyfin" --not_mandatory
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/jellyfin.service.d" --not_mandatory
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -9,14 +7,12 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=2
|
||||
ynh_script_progression --message="Stopping $app's systemd service..." --weight=2
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --timeout=15
|
||||
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" --timeout=15
|
||||
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
|
@ -25,15 +21,12 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
|
|||
|
||||
ynh_change_url_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
# BASE URL
|
||||
#=================================================
|
||||
|
||||
# Change the path in system.xml config file
|
||||
if [ $change_path -eq 1 ]
|
||||
then
|
||||
if [ $change_path -eq 1 ]; then
|
||||
# If somehow <BaseUrl /> was not replaced during install
|
||||
if grep -q "<BaseUrl />" "$config_path/network.xml"; then
|
||||
ynh_replace_string --match_string="<BaseUrl />" --replace_string="<BaseUrl>$new_path</BaseUrl>" --target_file="$config_path/network.xml"
|
||||
|
@ -42,14 +35,12 @@ then
|
|||
fi
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=2
|
||||
ynh_script_progression --message="Starting $app's systemd service..." --weight=2
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --timeout=15
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --timeout=15
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -19,13 +17,26 @@ fi
|
|||
ynh_app_setting_set --app="$app" --key=config_path --value="$config_path"
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================ç
|
||||
ynh_script_progression --message="Configuring the dedicated system user..." --weight=1
|
||||
|
||||
if getent group render && ! id -Gn "$app" | grep -qw "\brender\b" >/dev/null; then
|
||||
# Add user to render group
|
||||
adduser "$app" render
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# OPEN PORTS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Checking whether to open ports..." --weight=1
|
||||
configure_jellyfin_discovery_ports install
|
||||
|
||||
ports_args=()
|
||||
if [[ "${opened_ports:-__NOTHING__}" != "__NOTHING__" ]]; then
|
||||
ports_args=( "--needs_exposed_ports" "${opened_ports[@]}" )
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# INSTALL PACKAGES
|
||||
#=================================================
|
||||
|
@ -33,20 +44,6 @@ ynh_script_progression --message="Installing packages..." --weight=1
|
|||
|
||||
install_jellyfin_packages
|
||||
|
||||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================ç
|
||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
||||
|
||||
if getent group render && ! id -Gn "$app" | grep -qw "\brender\b" >/dev/null; then
|
||||
# Add user to render group
|
||||
adduser "$app" render
|
||||
fi
|
||||
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -87,42 +84,29 @@ ynh_script_progression --message="Adding multimedia directories..." --weight=2
|
|||
|
||||
# Build YunoHost multimedia directories
|
||||
ynh_multimedia_build_main_dir
|
||||
|
||||
# Allow Jellyfin to write into these directories
|
||||
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 using the conf/nginx.conf template
|
||||
ynh_add_nginx_config
|
||||
|
||||
ynh_add_config --template="systemd.service" --destination="/etc/systemd/system/jellyfin.service.d/baseurl.service.conf"
|
||||
systemctl daemon-reload
|
||||
yunohost service add "$app" --description="Jellyfin media center" "${ports_args[@]}"
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
ports_args=()
|
||||
if [[ "${opened_ports:-__NOTHING__}" != "__NOTHING__" ]]; then
|
||||
ports_args+=('--needs_exposed_ports')
|
||||
ports_args+=(${opened_ports})
|
||||
fi
|
||||
|
||||
yunohost service add "$app" --description="Jellyfin media center" ${ports_args[@]}
|
||||
|
||||
#=================================================
|
||||
# EDIT SYSTEMD ENVIRONMENT VARIABLE FOR AUTO-DISCOVERY
|
||||
#=================================================
|
||||
ynh_add_config --template="systemd.service" --destination="/etc/systemd/system/jellyfin.service.d/baseurl.service.conf"
|
||||
systemctl daemon-reload
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --timeout=15
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -9,24 +7,16 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||
#=================================================
|
||||
|
||||
# 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=3
|
||||
yunohost service remove "$app"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
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
|
||||
yunohost service remove "$app"
|
||||
fi
|
||||
|
||||
ynh_remove_logrotate
|
||||
|
||||
ynh_remove_nginx_config
|
||||
|
@ -41,11 +31,10 @@ ynh_remove_app_dependencies
|
|||
#=================================================
|
||||
# CLOSE A PORT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Checking whether to open ports..." --weight=1
|
||||
ynh_script_progression --message="Closing ports..." --weight=1
|
||||
|
||||
configure_jellyfin_discovery_ports remove
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE VARIOUS FILES
|
||||
#=================================================
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -10,8 +8,6 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
|
@ -29,6 +25,11 @@ fi
|
|||
ynh_script_progression --message="Checking whether to open ports..." --weight=1
|
||||
configure_jellyfin_discovery_ports install
|
||||
|
||||
ports_args=()
|
||||
if [[ "${opened_ports:-__NOTHING__}" != "__NOTHING__" ]]; then
|
||||
ports_args=( "--needs_exposed_ports" "${opened_ports[@]}" )
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
@ -45,21 +46,14 @@ ynh_script_progression --message="Reinstalling packages..." --weight=7
|
|||
|
||||
install_jellyfin_packages
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring user rights..."
|
||||
|
||||
# Restore permissions on app files
|
||||
chown -R $app: $data_path
|
||||
chown -R $app: $config_path
|
||||
chown -R "$app:" "$data_path"
|
||||
chown -R "$app:" "$config_path"
|
||||
|
||||
#=================================================
|
||||
# YUNOHOST MULTIMEDIA INTEGRATION
|
||||
|
@ -68,52 +62,29 @@ ynh_script_progression --message="Adding multimedia directories..." --weight=2
|
|||
|
||||
# Build YunoHost multimedia directories
|
||||
ynh_multimedia_build_main_dir
|
||||
|
||||
# Allow Jellyfin to write into these directories
|
||||
ynh_multimedia_addaccess $app
|
||||
ynh_multimedia_addaccess "$app"
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
||||
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/jellyfin.service.d" --not_mandatory
|
||||
systemctl enable jellyfin.service --quiet
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
|
||||
yunohost service add "$app" --description="Jellyfin media center" "${ports_args[@]}"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
||||
|
||||
ports_args=()
|
||||
if [[ "${opened_ports:-__NOTHING__}" = "__NOTHING__" ]]; then
|
||||
ports_args+=('--open-ports')
|
||||
ports_args+=(${ports})
|
||||
fi
|
||||
|
||||
yunohost service add "$app" --description="Jellyfin media center" "${ports_args[@]}"
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --timeout=15
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||
ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd" --timeout=15
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -9,19 +7,10 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Checking 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" --timeout=15
|
||||
|
||||
|
@ -61,6 +50,11 @@ fi
|
|||
ynh_script_progression --message="Checking whether to open ports..." --weight=1
|
||||
configure_jellyfin_discovery_ports install
|
||||
|
||||
ports_args=()
|
||||
if [[ "${opened_ports:-__NOTHING__}" != "__NOTHING__" ]]; then
|
||||
ports_args=( "--needs_exposed_ports" "${opened_ports[@]}" )
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# UPGRADE PACKAGES
|
||||
#=================================================
|
||||
|
@ -74,16 +68,6 @@ done
|
|||
|
||||
install_jellyfin_packages
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
|
@ -141,8 +125,8 @@ ynh_add_config --template="LDAP-Auth.xml" --destination="/var/lib/jellyfin/plugi
|
|||
#=================================================
|
||||
|
||||
# Set permissions on app files
|
||||
chown -R $app: $data_path
|
||||
chown -R $app: $config_path
|
||||
chown -R "$app:" "$data_path"
|
||||
chown -R "$app:" "$config_path"
|
||||
|
||||
#=================================================
|
||||
# YUNOHOST MULTIMEDIA INTEGRATION
|
||||
|
@ -151,44 +135,32 @@ ynh_script_progression --message="Adding multimedia directories..." --weight=2
|
|||
|
||||
# Build YunoHost multimedia directories
|
||||
ynh_multimedia_build_main_dir
|
||||
|
||||
# Allow Jellyfin to write into these directories
|
||||
ynh_multimedia_addaccess $app
|
||||
ynh_multimedia_addaccess "$app"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
# REAPPLY SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
|
||||
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
ynh_add_config --template="systemd.service" --destination="/etc/systemd/system/jellyfin.service.d/baseurl.service.conf"
|
||||
systemctl daemon-reload
|
||||
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
ports_args=()
|
||||
if [[ "${opened_ports:-__NOTHING__}" = "__NOTHING__" ]]; then
|
||||
ports_args+=('--open-ports')
|
||||
ports_args+=(${ports})
|
||||
fi
|
||||
|
||||
yunohost service add "$app" --description="Jellyfin media center" "${ports_args[@]}"
|
||||
|
||||
#=================================================
|
||||
# EDIT SYSTEMD ENVIRONMENT VARIABLE FOR AUTO-DISCOVERY
|
||||
#=================================================
|
||||
ynh_add_config --template="systemd.service" --destination="/etc/systemd/system/jellyfin.service.d/baseurl.service.conf"
|
||||
systemctl daemon-reload
|
||||
|
||||
#=================================================
|
||||
# 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="restart" --log_path="systemd" --timeout=15
|
||||
ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd" --timeout=15
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
Loading…
Add table
Reference in a new issue