1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/simple-torrent_ynh.git synced 2024-09-03 20:26:18 +02:00
This commit is contained in:
ericgaspar 2021-08-22 12:45:48 +02:00
commit 1b9b7af870
5 changed files with 45 additions and 33 deletions

View file

@ -25,6 +25,7 @@ app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
@ -41,7 +42,7 @@ ynh_backup --src_path="$final_path"
# BACKUP DATA
#=================================================
ynh_backup --src_path="/home/yunohost.app/$app" --is_big
ynh_backup --src_path="$datadir" --is_big
#=================================================
# BACKUP THE NGINX CONFIGURATION

View file

@ -107,13 +107,19 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=3
ynh_add_nginx_config
#=================================================
# CREATE DIRECTORIES
# CREATE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Creating a data directory..." --weight=1
datadir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
mkdir -p $datadir/{torrents,downloads}
mkdir -p /home/yunohost.app/$app/{torrents,downloads}
# Set permissions to app files
chown -R $app:www-data /home/yunohost.app/$app
chmod 755 /home/yunohost.app/$app/{torrents,downloads}
chmod 755 $datadir/{torrents,downloads}
chmod -R o-rwx $datadir
chown -R $app:www-data $datadir
#=================================================
# MODIFY A CONFIG FILE

View file

@ -20,6 +20,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
peer_port=$(ynh_app_setting_get --app=$app --key=peer_port)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# STANDARD REMOVE
@ -50,6 +51,17 @@ ynh_script_progression --message="Removing $app main directory..." --weight=6
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE DATA DIR
#=================================================
# Remove the app data directory with the command `yunohost app remove --purge`
if [ "$YNH_APP_PURGE" == true ]
then
ynh_script_progression --message="Removing $app data directory..." --weight=2
ynh_secure_remove --file="$datadir"
fi
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================

View file

@ -27,6 +27,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
peer_port=$(ynh_app_setting_get --app=$app --key=peer_port)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
@ -52,7 +53,6 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
ynh_script_progression --message="Configuring firewall..." --weight=3
#ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
ynh_exec_warn_less yunohost firewall allow Both $peer_port
#=================================================
@ -80,10 +80,13 @@ chmod +x $final_path/$app
#=================================================
ynh_script_progression --message="Restoring $app data..." --weight=10
ynh_restore_file --origin_path="/home/yunohost.app/$app" --not_mandatory
ynh_restore_file --origin_path="$datadir" --not_mandatory
chown -R $app:www-data /home/yunohost.app/$app
chmod 755 /home/yunohost.app/$app/{torrents,downloads}
mkdir -p $datadir/{torrents,downloads}
chmod 755 $datadir/{torrents,downloads}
chmod -R o-rwx $datadir
chown -R $app:www-data $datadir
#=================================================
# RESTORE SYSTEMD

View file

@ -26,10 +26,23 @@ architecture=$(ynh_detect_arch)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up $app before upgrading (may take a while)..." --weight=4
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
@ -48,20 +61,6 @@ if ynh_legacy_permissions_exists; then
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up $app before upgrading (may take a while)..." --weight=4
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
@ -119,15 +118,6 @@ ynh_script_progression --message="Modifying a config file..." --weight=1
ynh_add_config --template="../conf/config.default.yml" --destination="$final_path/config.yml"
#=================================================
# CREATE DIRECTORIES
#=================================================
mkdir -p /home/yunohost.app/$app/{torrents,downloads}
chown -R $app:www-data /home/yunohost.app/$app
chmod 755 /home/yunohost.app/$app/{torrents,downloads}
#=================================================
# SETUP SYSTEMD
#=================================================