1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/couchpotato_ynh.git synced 2024-09-03 18:16:22 +02:00

Automated packaging v2 conversion

This commit is contained in:
Salamandar 2024-06-06 12:01:19 +02:00
parent 5724bd73fd
commit b13e7546f9
10 changed files with 202 additions and 152 deletions

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/CouchPotato/CouchPotatoServer/archive/7260c12f72447ddb6f062367c6dfbda03ecd4e9c.tar.gz
SOURCE_SUM=2944f73f1630ada31e24d47df678c4412bd6acc93295ce2915179a75ecfd5dd1
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -4,7 +4,7 @@ username =
ssl_key =
proxy_server =
ssl_cert =
data_dir = __DATADIR__
data_dir = __DATA_DIR__
use_proxy = 0
permission_file = 0755
proxy_password =

View file

@ -6,8 +6,8 @@ After=network.target
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__/
ExecStart=/opt/pyenv/versions/__PYTHON_VERSION__/bin/python __FINALPATH__/CouchPotato.py --quiet --pid_file=/var/run/__APP__/__APP__.pid --data_dir=__DATADIR__ --config_file=__DATADIR__/settings.conf
WorkingDirectory=__INSTALL_DIR__/
ExecStart=/opt/pyenv/versions/__PYTHON_VERSION__/bin/python __INSTALL_DIR__/CouchPotato.py --quiet --pid_file=/var/run/__APP__/__APP__.pid --data_dir=__DATA_DIR__ --config_file=__DATA_DIR__/settings.conf
[Install]
WantedBy=multi-user.target

57
manifest.toml Normal file
View file

@ -0,0 +1,57 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "couchpotato"
name = "CouchPotato"
description.en = "Automatic movie downloader"
description.fr = "Téléchargement automatisé de film"
version = "3.0.1~ynh4"
maintainers = ["Snipees"]
[upstream]
license = "GPL-3.0-only"
website = "https://couchpota.to"
code = "https://github.com/CouchPotato/CouchPotatoServer"
cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number)
fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin.
[integration]
yunohost = ">= 4.2.0"
architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"]
multi_instance = false
ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials.
sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal.
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
[install]
[install.domain]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "domain"
[install.path]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "path"
default = "/couchpotato"
[resources]
[resources.sources.main]
url = "https://github.com/CouchPotato/CouchPotatoServer/archive/7260c12f72447ddb6f062367c6dfbda03ecd4e9c.tar.gz"
sha256 = "2944f73f1630ada31e24d47df678c4412bd6acc93295ce2915179a75ecfd5dd1"
[resources.system_user]
[resources.install_dir]
[resources.data_dir]
[resources.permissions]
main.url = "/"
[resources.ports]
main.default = 5050

View file

@ -5,7 +5,7 @@
#=================================================
# dependencies used by the app (must be on a single line)
pkg_dependencies=""
#REMOVEME? pkg_dependencies=""
python_version=2.7.18

View file

@ -14,22 +14,22 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
#REMOVEME? ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
#REMOVEME? ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
#REMOVEME? 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)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
@ -40,13 +40,13 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$final_path"
ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE DATA DIR
#=================================================
ynh_backup --src_path="$datadir" --is_big
ynh_backup --src_path="$data_dir" --is_big
#=================================================
# BACKUP THE NGINX CONFIGURATION

View file

@ -14,50 +14,50 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
#REMOVEME? ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
#REMOVEME? domain=$YNH_APP_ARG_DOMAIN
#REMOVEME? path=$YNH_APP_ARG_PATH
app=$YNH_APP_INSTANCE_NAME
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
#REMOVEME? install_dir=/opt/yunohost/$app
#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1
#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain
#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port..." --weight=1
#REMOVEME? ynh_script_progression --message="Finding an available port..." --weight=1
# Find an available port
port=$(ynh_find_port --port=5050)
ynh_app_setting_set --app=$app --key=port --value=$port
#REMOVEME? port=$(ynh_find_port --port=5050)
#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port
# Optional: Expose this port publicly
# (N.B.: you only need to do this if the app actually needs to expose the port publicly.
@ -70,31 +70,31 @@ ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=1
#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
ynh_install_python --python_version=$python_version
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
# Download, check integrity, uncompress and patch the source from app.src
git clone $source "$final_path"
git clone $source "$install_dir"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
#=================================================
# NGINX CONFIGURATION
@ -111,14 +111,14 @@ ynh_add_nginx_config
#=================================================
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
#REMOVEME? data_dir=/home/yunohost.app/$app
#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir
mkdir -p $datadir
mkdir -p $data_dir
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:$app "$datadir"
chmod 750 "$data_dir"
chmod -R o-rwx "$data_dir"
chown -R $app:$app "$data_dir"
#=================================================
# BUILD COUCHPOTATO
@ -127,7 +127,7 @@ ynh_script_progression --message="Building CouchPotato..." --weight=1
ynh_use_python
pushd $final_path
pushd $install_dir
ynh_pip install --upgrade pyopenssl
ynh_pip install cheetah
popd
@ -170,21 +170,21 @@ if [[ -z $(yunohost app list | grep -q 'id: $transmission') ]]; then
else
ynh_script_progression --message="Transmission is installed. Trying to link it to CouchPotato..."
# Check if the transmission password is in settings
if [[ -n $(ynh_app_setting_get --app=transmission --key=rpcpassword || true) ]]; then
#REMOVEME? if [[ -n $(ynh_app_setting_get --app=transmission --key=rpcpassword || true) ]]; then
ynh_script_progression --message="Transmission will be linked to CouchPotato directly"
transmission_rpcurl="$(ynh_app_setting_get --app=transmission --key=path)transmission"
transmission_rpcpassword=$(ynh_app_setting_get --app=transmission --key=rpcpassword)
#REMOVEME? transmission_rpcurl="$(ynh_app_setting_get --app=transmission --key=path)transmission"
#REMOVEME? transmission_rpcpassword=$(ynh_app_setting_get --app=transmission --key=rpcpassword)
rpc="1" # Enable Transmission RPC
blackhole="0" # Disable Transmission Watchdir
renamer="1" # Enable Renamer
# If transmission uses YunoHost multimedia, use its folder for the renamer
else
# Check if transmission has watchdir enabled
if [[ -n $(ynh_app_setting_get --app=transmission --key=watchdir || true) ]]; then
#REMOVEME? if [[ -n $(ynh_app_setting_get --app=transmission --key=watchdir || true) ]]; then
ynh_script_progression --message="Transmission will be linked to CouchPotato with watchdir"
transmission_watchdir=$(ynh_app_setting_get --app=transmission --key=watchdir)
#REMOVEME? transmission_watchdir=$(ynh_app_setting_get --app=transmission --key=watchdir)
rpc="0" # Disable Transmission RPC
blackhole="1" # Enable Transmission Watchdir
renamer="1" # Enable Renamer
@ -204,10 +204,10 @@ fi
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="../conf/couchpotato.conf" --destination="$datadir/settings.conf"
ynh_add_config --template="../conf/couchpotato.conf" --destination="$data_dir/settings.conf"
chmod 600 "$datadir/settings.conf"
chown $app:$app "$datadir/settings.conf"
chmod 600 "$data_dir/settings.conf"
chown $app:$app "$data_dir/settings.conf"
#=================================================
# SETUP SYSTEMD
@ -227,7 +227,7 @@ app_logs_dir="/var/log/$app"
mkdir -p $app_logs_dir
chown -R $app:$app $app_logs_dir
chmod +x -R $app_logs_dir
ynh_replace_string --match_string="self.log_dir =.*" --replace_string="self.log_dir = '$app_logs_dir'" --target_file="$final_path/CouchPotato.py"
ynh_replace_string --match_string="self.log_dir =.*" --replace_string="self.log_dir = '$app_logs_dir'" --target_file="$install_dir/CouchPotato.py"
#=================================================
# GENERIC FINALIZATION
@ -257,21 +257,21 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1
ynh_permission_update --permission="main" --add="visitors"
#REMOVEME? ynh_permission_update --permission="main" --add="visitors"
# Everyone can access to the api part
# We don't want to display the tile in the sso so we put --show_tile="false"
# And we don't want that the YunoHost Admin can remove visitors group to this permission, so we put --protected="true"
ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true"
#REMOVEME? ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT

View file

@ -13,13 +13,13 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
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)
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#=================================================
# STANDARD REMOVE
@ -53,10 +53,10 @@ ynh_remove_logrotate
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=1
#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#REMOVEME? ynh_secure_remove --file="$install_dir"
#=================================================
# REMOVE NGINX CONFIGURATION
@ -69,11 +69,11 @@ ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_python
ynh_remove_app_dependencies
#REMOVEME? ynh_remove_app_dependencies
#=================================================
# CLOSE A PORT
@ -100,10 +100,10 @@ ynh_secure_remove --file="/var/log/$app"
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user
ynh_system_user_delete --username=$app
#REMOVEME? ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT

View file

@ -15,75 +15,75 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
#REMOVEME? ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
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)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#REMOVEME? test ! -d $install_dir \
|| ynh_die --message="There is already a directory: $install_dir "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
#REMOVEME? ynh_system_user_create --username=$app --home_dir=$install_dir
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path"
ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
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="$datadir" --not_mandatory
ynh_restore_file --origin_path="$data_dir" --not_mandatory
mkdir -p $datadir
mkdir -p $data_dir
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:$app "$datadir"
chmod 750 "$data_dir"
chmod -R o-rwx "$data_dir"
chown -R $app:$app "$data_dir"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
ynh_install_python --python_version=$python_version
#=================================================
@ -100,7 +100,7 @@ ynh_script_progression --message="Building CouchPotato..." --weight=1
ynh_use_python
pushd $final_path
pushd $install_dir
/opt/pyenv/versions/$app/bin/pip install --upgrade pyopenssl
/opt/pyenv/versions/$app/bin/pip install cheetah
popd
@ -128,7 +128,7 @@ app_logs_dir="/var/log/$app"
mkdir -p $app_logs_dir
chown -R $app:$app $app_logs_dir
chmod +x -R $app_logs_dir
ynh_replace_string --match_string="self.log_dir =.*" --replace_string="self.log_dir = '$app_logs_dir'" --target_file="$final_path/CouchPotato.py"
ynh_replace_string --match_string="self.log_dir =.*" --replace_string="self.log_dir = '$app_logs_dir'" --target_file="$install_dir/CouchPotato.py"
#=================================================
# RESTORE SYSTEMD

View file

@ -13,15 +13,15 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
#=================================================
# CHECK VERSION
@ -33,16 +33,16 @@ upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
#REMOVEME? ynh_backup_before_upgrade
#REMOVEME? ynh_clean_setup () {
# Restore it if the upgrade fails
ynh_restore_upgradebackup
#REMOVEME? ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
@ -58,48 +58,48 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# If final_path doesn't exist, create it
if [ -z "$final_path" ]; then
final_path=/opt/yunohost/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# If install_dir doesn't exist, create it
if [ -z "$install_dir" ]; then
#REMOVEME? install_dir=/opt/yunohost/$app
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
fi
# If datadir doesn't exist, create it
if [ -z "$datadir" ]; then
datadir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
# If data_dir doesn't exist, create it
if [ -z "$data_dir" ]; then
data_dir=/home/yunohost.app/$app
#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir
ynh_app_setting_delete --app=$app --key=app_data_dir
fi
# If settings.conf is not at the right place, move it
if [ ! -f "$datadir/settings.conf" ]; then
ynh_delete_file_checksum --file="$final_path/settings.conf"
mv "$final_path/settings.conf" "$datadir/settings.conf"
ynh_store_file_checksum --file="$datadir/settings.conf"
if [ ! -f "$data_dir/settings.conf" ]; then
ynh_delete_file_checksum --file="$install_dir/settings.conf"
mv "$install_dir/settings.conf" "$data_dir/settings.conf"
ynh_store_file_checksum --file="$data_dir/settings.conf"
chmod 600 "$datadir/settings.conf"
chown $app:$app "$datadir/settings.conf"
chmod 600 "$data_dir/settings.conf"
chown $app:$app "$data_dir/settings.conf"
fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
#REMOVEME? if ynh_legacy_permissions_exists; then
#REMOVEME? ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
# Create a permission if needed
if ! ynh_permission_exists --permission="api"; then
ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true"
#REMOVEME? if ! ynh_permission_exists --permission="api"; then
#REMOVEME? ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true"
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -110,21 +110,21 @@ then
ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src
pushd "$final_path"
pushd "$install_dir"
git pull
popd
fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
ynh_install_python --python_version=$python_version
#=================================================
@ -144,7 +144,7 @@ ynh_script_progression --message="Building CouchPotato..." --weight=1
ynh_use_python
pushd $final_path
pushd $install_dir
ynh_pip install --upgrade pyopenssl
ynh_pip install cheetah
popd
@ -187,21 +187,21 @@ if [[ -z $(yunohost app list | grep -q 'id: $transmission') ]]; then
else
ynh_script_progression --message="Transmission is installed. Trying to link it to CouchPotato..."
# Check if the transmission password is in settings
if [[ -n $(ynh_app_setting_get --app=transmission --key=rpcpassword || true) ]]; then
#REMOVEME? if [[ -n $(ynh_app_setting_get --app=transmission --key=rpcpassword || true) ]]; then
ynh_script_progression --message="Transmission will be linked to CouchPotato directly"
transmission_rpcurl="$(ynh_app_setting_get --app=transmission --key=path)transmission"
transmission_rpcpassword=$(ynh_app_setting_get --app=transmission --key=rpcpassword)
#REMOVEME? transmission_rpcurl="$(ynh_app_setting_get --app=transmission --key=path)transmission"
#REMOVEME? transmission_rpcpassword=$(ynh_app_setting_get --app=transmission --key=rpcpassword)
rpc="1" # Enable Transmission RPC
blackhole="0" # Disable Transmission Watchdir
renamer="1" # Enable Renamer
# If transmission uses YunoHost multimedia, use its folder for the renamer
else
# Check if transmission has watchdir enabled
if [[ -n $(ynh_app_setting_get --app=transmission --key=watchdir || true) ]]; then
#REMOVEME? if [[ -n $(ynh_app_setting_get --app=transmission --key=watchdir || true) ]]; then
ynh_script_progression --message="Transmission will be linked to CouchPotato with watchdir"
transmission_watchdir=$(ynh_app_setting_get --app=transmission --key=watchdir)
#REMOVEME? transmission_watchdir=$(ynh_app_setting_get --app=transmission --key=watchdir)
rpc="0" # Disable Transmission RPC
blackhole="1" # Enable Transmission Watchdir
renamer="1" # Enable Renamer
@ -221,10 +221,10 @@ fi
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1
ynh_backup_if_checksum_is_different --file="$datadir/settings.conf"
ynh_backup_if_checksum_is_different --file="$data_dir/settings.conf"
chmod 600 "$datadir/settings.conf"
chown $app:$app "$datadir/settings.conf"
chmod 600 "$data_dir/settings.conf"
chown $app:$app "$data_dir/settings.conf"
#=================================================
# CONFIGURE LOGS
@ -236,7 +236,7 @@ app_logs_dir="/var/log/$app"
mkdir -p $app_logs_dir
chown -R $app:$app $app_logs_dir
chmod +x -R $app_logs_dir
ynh_replace_string --match_string="self.log_dir =.*" --replace_string="self.log_dir = '$app_logs_dir'" --target_file="$final_path/CouchPotato.py"
ynh_replace_string --match_string="self.log_dir =.*" --replace_string="self.log_dir = '$app_logs_dir'" --target_file="$install_dir/CouchPotato.py"
#=================================================
# SETUP SYSTEMD
@ -273,9 +273,9 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT