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 = ssl_key =
proxy_server = proxy_server =
ssl_cert = ssl_cert =
data_dir = __DATADIR__ data_dir = __DATA_DIR__
use_proxy = 0 use_proxy = 0
permission_file = 0755 permission_file = 0755
proxy_password = proxy_password =

View file

@ -6,8 +6,8 @@ After=network.target
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
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 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] [Install]
WantedBy=multi-user.target 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) # dependencies used by the app (must be on a single line)
pkg_dependencies="" #REMOVEME? pkg_dependencies=""
python_version=2.7.18 python_version=2.7.18

View file

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

View file

@ -14,50 +14,50 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
true true
} }
# Exit if an error occurs during the execution of the script # 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 # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
domain=$YNH_APP_ARG_DOMAIN #REMOVEME? domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH #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 # 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 #REMOVEME? install_dir=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" #REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
# Register (book) web path # 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 # 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 #REMOVEME? 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=path --value=$path
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#================================================= #=================================================
# FIND AND OPEN A PORT # 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 # Find an available port
port=$(ynh_find_port --port=5050) #REMOVEME? port=$(ynh_find_port --port=5050)
ynh_app_setting_set --app=$app --key=port --value=$port #REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port
# Optional: Expose this port publicly # Optional: Expose this port publicly
# (N.B.: you only need to do this if the app actually needs to expose the 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 # 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 ynh_install_python --python_version=$python_version
#================================================= #=================================================
# CREATE DEDICATED USER # 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 # 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 # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=1 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 # 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 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app:$app "$final_path" chown -R $app:$app "$install_dir"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -111,14 +111,14 @@ ynh_add_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Creating a data directory..." --weight=1 ynh_script_progression --message="Creating a data directory..." --weight=1
datadir=/home/yunohost.app/$app #REMOVEME? data_dir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=datadir --value=$datadir #REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir
mkdir -p $datadir mkdir -p $data_dir
chmod 750 "$datadir" chmod 750 "$data_dir"
chmod -R o-rwx "$datadir" chmod -R o-rwx "$data_dir"
chown -R $app:$app "$datadir" chown -R $app:$app "$data_dir"
#================================================= #=================================================
# BUILD COUCHPOTATO # BUILD COUCHPOTATO
@ -127,7 +127,7 @@ ynh_script_progression --message="Building CouchPotato..." --weight=1
ynh_use_python ynh_use_python
pushd $final_path pushd $install_dir
ynh_pip install --upgrade pyopenssl ynh_pip install --upgrade pyopenssl
ynh_pip install cheetah ynh_pip install cheetah
popd popd
@ -170,21 +170,21 @@ if [[ -z $(yunohost app list | grep -q 'id: $transmission') ]]; then
else else
ynh_script_progression --message="Transmission is installed. Trying to link it to CouchPotato..." ynh_script_progression --message="Transmission is installed. Trying to link it to CouchPotato..."
# Check if the transmission password is in settings # 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" ynh_script_progression --message="Transmission will be linked to CouchPotato directly"
transmission_rpcurl="$(ynh_app_setting_get --app=transmission --key=path)transmission" #REMOVEME? transmission_rpcurl="$(ynh_app_setting_get --app=transmission --key=path)transmission"
transmission_rpcpassword=$(ynh_app_setting_get --app=transmission --key=rpcpassword) #REMOVEME? transmission_rpcpassword=$(ynh_app_setting_get --app=transmission --key=rpcpassword)
rpc="1" # Enable Transmission RPC rpc="1" # Enable Transmission RPC
blackhole="0" # Disable Transmission Watchdir blackhole="0" # Disable Transmission Watchdir
renamer="1" # Enable Renamer renamer="1" # Enable Renamer
# If transmission uses YunoHost multimedia, use its folder for the renamer # If transmission uses YunoHost multimedia, use its folder for the renamer
else else
# Check if transmission has watchdir enabled # 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" 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 rpc="0" # Disable Transmission RPC
blackhole="1" # Enable Transmission Watchdir blackhole="1" # Enable Transmission Watchdir
renamer="1" # Enable Renamer renamer="1" # Enable Renamer
@ -204,10 +204,10 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1 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" chmod 600 "$data_dir/settings.conf"
chown $app:$app "$datadir/settings.conf" chown $app:$app "$data_dir/settings.conf"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -227,7 +227,7 @@ app_logs_dir="/var/log/$app"
mkdir -p $app_logs_dir mkdir -p $app_logs_dir
chown -R $app:$app $app_logs_dir chown -R $app:$app $app_logs_dir
chmod +x -R $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 # GENERIC FINALIZATION
@ -257,21 +257,21 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
#================================================= #=================================================
# SETUP SSOWAT # 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 # Everyone can access to the api part
# We don't want to display the tile in the sso so we put --show_tile="false" # 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" # 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 # 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 # END OF SCRIPT

View file

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

View file

@ -15,75 +15,75 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # 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) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) #REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) #REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # 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 \ #REMOVEME? test ! -d $install_dir \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $install_dir "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#================================================= #=================================================
# RECREATE THE DEDICATED USER # 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) # 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 # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1 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 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app:$app "$final_path" chown -R $app:$app "$install_dir"
#================================================= #=================================================
# RESTORE THE DATA DIRECTORY # RESTORE THE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1 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 750 "$data_dir"
chmod -R o-rwx "$datadir" chmod -R o-rwx "$data_dir"
chown -R $app:$app "$datadir" chown -R $app:$app "$data_dir"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=1 #REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies #REMOVEME? ynh_install_app_dependencies $pkg_dependencies
ynh_install_python --python_version=$python_version ynh_install_python --python_version=$python_version
#================================================= #=================================================
@ -100,7 +100,7 @@ ynh_script_progression --message="Building CouchPotato..." --weight=1
ynh_use_python 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 --upgrade pyopenssl
/opt/pyenv/versions/$app/bin/pip install cheetah /opt/pyenv/versions/$app/bin/pip install cheetah
popd popd
@ -128,7 +128,7 @@ app_logs_dir="/var/log/$app"
mkdir -p $app_logs_dir mkdir -p $app_logs_dir
chown -R $app:$app $app_logs_dir chown -R $app:$app $app_logs_dir
chmod +x -R $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 # RESTORE SYSTEMD

View file

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