mirror of
https://github.com/YunoHost-Apps/reiverr_ynh.git
synced 2024-09-03 20:16:14 +02:00
finish package
This commit is contained in:
parent
369c610a19
commit
19b9f3d7a1
7 changed files with 72 additions and 225 deletions
|
@ -39,45 +39,6 @@ ram.runtime = "50M"
|
|||
type = "group"
|
||||
default = "visitors"
|
||||
|
||||
[install.radarr_domain]
|
||||
ask.en = "(Optional) Insert here the api key from your Radarr instance"
|
||||
ask.fr = "(Optionnel) Insérez ici la clé API de votre instance Radarr"
|
||||
type = "domain"
|
||||
optional = true
|
||||
|
||||
[install.radarr_api]
|
||||
ask.en = "(Optional) Insert here the api key from your Radarr instance"
|
||||
ask.fr = "(Optionnel) Insérez ici la clé API de votre instance Radarr"
|
||||
type = "string"
|
||||
default = false
|
||||
optional = true
|
||||
|
||||
[install.sonarr_domain]
|
||||
ask.en = "(Optional) Insert here the api key from your Sonarr instance"
|
||||
ask.fr = "(Optionnel) Insérez ici la clé API de votre instance Sonarr"
|
||||
type = "domain"
|
||||
optional = true
|
||||
|
||||
[install.sonarr_api]
|
||||
ask.en = "(Optional) Insert here the api key from your Sonarr instance"
|
||||
ask.fr = "(Optionnel) Insérez ici la clé API de votre instance Sonarr"
|
||||
type = "string"
|
||||
default = false
|
||||
optional = true
|
||||
|
||||
[install.jellyfin_domain]
|
||||
ask.en = "(Optional) Insert here the api key from your Jellyfin instance"
|
||||
ask.fr = "(Optionnel) Insérez ici la clé API de votre instance Jellyfin"
|
||||
type = "domain"
|
||||
optional = true
|
||||
|
||||
[install.jellyfin_api]
|
||||
ask.en = "(Optional) Insert here the api key from your Jellyfin instance"
|
||||
ask.fr = "(Optionnel) Insérez ici la clé API de votre instance Jellyfin"
|
||||
type = "string"
|
||||
default = false
|
||||
optional = true
|
||||
|
||||
[resources]
|
||||
|
||||
[resources.sources]
|
||||
|
|
|
@ -15,43 +15,18 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
|
||||
### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs
|
||||
### to be backuped and not an actual copy of any file. The actual backup that
|
||||
### creates and fills the archive with the files happens in the core after this
|
||||
### script is called. Hence ynh_backups calls take basically 0 seconds to run.
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE DATA DIR
|
||||
#=================================================
|
||||
|
||||
# Only relevant if there is a "data_dir" resource for this app
|
||||
ynh_backup --src_path="$data_dir" --is_big
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP FAIL2BAN CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
|
||||
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
|
@ -66,24 +41,6 @@ ynh_backup --src_path="/etc/logrotate.d/$app"
|
|||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
# BACKUP VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/cron.d/$app"
|
||||
|
||||
ynh_backup --src_path="/etc/$app/"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up the MySQL database..."
|
||||
|
||||
### (However, things like MySQL dumps *do* take some time to run, though the
|
||||
### copy of the generated dump to the archive still happens later)
|
||||
|
||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -25,12 +25,6 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
|
|||
|
||||
ynh_change_url_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
# ...
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
|
|
|
@ -38,7 +38,6 @@ chmod 750 "$install_dir"
|
|||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -53,6 +52,7 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
# BUILD APP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building __APP__..."
|
||||
|
||||
pushd $install_dir
|
||||
ynh_use_nodejs
|
||||
|
@ -65,7 +65,6 @@ pushd $install_dir
|
|||
|
||||
ynh_script_progression --message="Cleaning cache... " --weight=3
|
||||
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn cache clean 2>&1
|
||||
|
||||
popd
|
||||
|
||||
chmod 750 "$install_dir"
|
||||
|
@ -117,7 +116,6 @@ ynh_script_progression --message="Starting a systemd service..."
|
|||
# Start a systemd service
|
||||
ynh_exec_warn_less ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match=""
|
||||
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -9,32 +9,14 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
|
||||
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_mongo_remove_db --db_user=$db_user --db_name=$db_name
|
||||
ynh_remove_mongo
|
||||
|
||||
|
||||
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
||||
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
|
@ -42,7 +24,6 @@ ynh_remove_nginx_config
|
|||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=4
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_nodejs
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -17,57 +17,24 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
|
|||
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
# $install_dir will automatically be initialized with some decent
|
||||
# permissions by default ... however, you may need to recursively reapply
|
||||
# ownership to all files such as after the ynh_setup_source step
|
||||
chown -R $app:www-data "$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
|
||||
|
||||
# (Same as for install dir)
|
||||
chown -R $app:www-data "$data_dir"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
|
||||
|
||||
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:$app "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||
|
||||
# This should be a symetric version of what happens in the install script
|
||||
|
||||
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
|
||||
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="A short description of the app" --log="/var/log/$app/$app.log"
|
||||
yunohost service add $app --log="/var/log/$app/$app.log"
|
||||
|
||||
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
|
||||
|
||||
# Other various files...
|
||||
|
||||
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
||||
ynh_restore_file --origin_path="/etc/$app/"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
@ -75,9 +42,7 @@ ynh_restore_file --origin_path="/etc/$app/"
|
|||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
||||
|
||||
# Typically you only have either $app or php-fpm but not both at the same time...
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
|
||||
ynh_exec_warn_less ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match=""
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
|
141
scripts/upgrade
141
scripts/upgrade
|
@ -9,52 +9,26 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Settings are automatically loaded as bash variables
|
||||
# in every app script context, therefore typically these will exist:
|
||||
# - $domain
|
||||
# - $path
|
||||
# - $language
|
||||
# - $install_dir
|
||||
# - $port
|
||||
# ...
|
||||
|
||||
# In the context of upgrade,
|
||||
# - resources are automatically provisioned / updated / deleted (depending on existing resources)
|
||||
# - a safety backup is automatically created by the core and will be restored if the upgrade fails
|
||||
|
||||
### This helper will compare the version of the currently installed app and the version of the upstream package.
|
||||
### $upgrade_type can have 2 different values
|
||||
### - UPGRADE_APP if the upstream app version has changed
|
||||
### - UPGRADE_PACKAGE if only the YunoHost package has changed
|
||||
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
|
||||
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=5
|
||||
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
# Upgrade NPM
|
||||
ynh_npm install --global npm@latest
|
||||
|
||||
# Install Yarn
|
||||
ynh_npm install --global yarn
|
||||
|
||||
# Install vite
|
||||
ynh_npm install --global vite
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
#=================================================
|
||||
|
@ -67,18 +41,13 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
|
|||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up 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 --dest_dir="$install_dir"
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from manifest.toml
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
fi
|
||||
|
||||
# $install_dir will automatically be initialized with some decent
|
||||
# permissions by default ... however, you may need to recursively reapply
|
||||
# ownership to all files such as after the ynh_setup_source step
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
#=================================================
|
||||
|
@ -88,17 +57,29 @@ ynh_script_progression --message="Upgrading system configurations related to $ap
|
|||
|
||||
# This should be a literal copypaste of what happened in the install's "System configuration" section
|
||||
|
||||
ynh_add_fpm_config
|
||||
|
||||
ynh_add_nginx_config
|
||||
|
||||
ynh_add_systemd_config
|
||||
#=================================================
|
||||
# BUILD APP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building __APP__..."
|
||||
|
||||
yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log"
|
||||
pushd $install_dir
|
||||
ynh_use_nodejs
|
||||
|
||||
ynh_use_logrotate --non-append
|
||||
ynh_script_progression --message="npm install... This can be very long, be patient !" --weight=18
|
||||
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --network-timeout=100000
|
||||
|
||||
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
|
||||
ynh_script_progression --message="Building Yarn dev dependencies... This can be very long, be patient !" --weight=25
|
||||
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn run build
|
||||
|
||||
ynh_script_progression --message="Cleaning cache... " --weight=3
|
||||
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn cache clean 2>&1
|
||||
popd
|
||||
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:$app "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
|
||||
|
@ -107,32 +88,42 @@ ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failreg
|
|||
#=================================================
|
||||
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
||||
|
||||
### Same as during install
|
||||
###
|
||||
### The file will automatically be backed-up if it's found to be manually modified (because
|
||||
### ynh_add_config keeps track of the file's checksum)
|
||||
ynh_add_config --template="../conf/.env" --destination="$install_dir/.env"
|
||||
|
||||
ynh_add_config --template="some_config_file" --destination="$install_dir/some_config_file"
|
||||
chmod 400 "$install_dir/.env"
|
||||
chown $app:$app "$install_dir/.env"
|
||||
|
||||
# FIXME: this should be handled by the core in the future
|
||||
# You may need to use chmod 600 instead of 400,
|
||||
# for example if the app is expected to be able to modify its own config
|
||||
chmod 400 "$install_dir/some_config_file"
|
||||
chown $app:$app "$install_dir/some_config_file"
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..."
|
||||
|
||||
### For more complex cases where you want to replace stuff using regexes,
|
||||
### you shoud rely on ynh_replace_string (which is basically a wrapper for sed)
|
||||
### When doing so, you also need to manually call ynh_store_file_checksum
|
||||
###
|
||||
### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$install_dir/some_config_file"
|
||||
### ynh_store_file_checksum --file="$install_dir/some_config_file"
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring logrotate to manage application logfiles" --weight=1
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate --specific_user=$app --non-append
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
ynh_exec_warn_less ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match=""
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
Loading…
Reference in a new issue