mirror of
https://github.com/YunoHost-Apps/transmission_ynh.git
synced 2024-09-04 01:46:12 +02:00
Merge pull request #31 from YunoHost-Apps/global_update
[enh] Update of the scripts
This commit is contained in:
commit
116d35fd50
8 changed files with 113 additions and 424 deletions
|
@ -20,10 +20,10 @@
|
||||||
Level 1=auto
|
Level 1=auto
|
||||||
Level 2=auto
|
Level 2=auto
|
||||||
Level 3=auto
|
Level 3=auto
|
||||||
|
# Level 4: No multi-users support
|
||||||
Level 4=na
|
Level 4=na
|
||||||
# Level 4:
|
# Level 5: https://github.com/YunoHost-Apps/transmission_ynh/issues/30
|
||||||
Level 5=auto
|
Level 5=1
|
||||||
# Level 5:
|
|
||||||
Level 6=auto
|
Level 6=auto
|
||||||
Level 7=auto
|
Level 7=auto
|
||||||
Level 8=0
|
Level 8=0
|
||||||
|
|
|
@ -2,19 +2,20 @@
|
||||||
"name": "Transmission",
|
"name": "Transmission",
|
||||||
"id": "transmission",
|
"id": "transmission",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"requirements": {
|
|
||||||
"yunohost": ">= 2.4.0"
|
|
||||||
},
|
|
||||||
"description": {
|
"description": {
|
||||||
"en": "A Fast, Easy, and Free BitTorrent Client",
|
"en": "A Fast, Easy, and Free BitTorrent Client",
|
||||||
"fr": "Un client BitTorrent libre et rapide"
|
"fr": "Un client BitTorrent libre et rapide"
|
||||||
},
|
},
|
||||||
|
"version": "1.0",
|
||||||
"url": "https://www.transmissionbt.com/",
|
"url": "https://www.transmissionbt.com/",
|
||||||
"license": " GPL-3.0",
|
"license": " GPL-3.0",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "Apps Group",
|
"name": "Apps Group",
|
||||||
"email": "apps_group@yunohost.org"
|
"email": "apps_group@yunohost.org"
|
||||||
},
|
},
|
||||||
|
"requirements": {
|
||||||
|
"yunohost": ">= 2.7.2"
|
||||||
|
},
|
||||||
"multi_instance": false,
|
"multi_instance": false,
|
||||||
"services": [
|
"services": [
|
||||||
"nginx",
|
"nginx",
|
||||||
|
|
|
@ -7,130 +7,17 @@
|
||||||
ynh_multimedia_build_main_dir () {
|
ynh_multimedia_build_main_dir () {
|
||||||
wget -qq https://github.com/YunoHost-Apps/yunohost.multimedia/archive/master.zip
|
wget -qq https://github.com/YunoHost-Apps/yunohost.multimedia/archive/master.zip
|
||||||
unzip -qq master.zip
|
unzip -qq master.zip
|
||||||
sudo ./yunohost.multimedia-master/script/ynh_media_build.sh
|
./yunohost.multimedia-master/script/ynh_media_build.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
ynh_multimedia_addfolder () {
|
ynh_multimedia_addfolder () {
|
||||||
sudo ./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source="$1" --dest="$2"
|
./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source="$1" --dest="$2"
|
||||||
}
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
#=================================================
|
|
||||||
# TESTING
|
|
||||||
#=================================================
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_nginx_config () {
|
|
||||||
finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
||||||
ynh_backup_if_checksum_is_different "$finalnginxconf" 1
|
|
||||||
sudo cp ../conf/nginx.conf "$finalnginxconf"
|
|
||||||
|
|
||||||
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
|
|
||||||
# Substitute in a nginx config file only if the variable is not empty
|
|
||||||
if test -n "${path_url:-}"; then
|
|
||||||
ynh_replace_string "__PATH__" "$path_url" "$finalnginxconf"
|
|
||||||
fi
|
|
||||||
if test -n "${domain:-}"; then
|
|
||||||
ynh_replace_string "__DOMAIN__" "$domain" "$finalnginxconf"
|
|
||||||
fi
|
|
||||||
if test -n "${port:-}"; then
|
|
||||||
ynh_replace_string "__PORT__" "$port" "$finalnginxconf"
|
|
||||||
fi
|
|
||||||
if test -n "${app:-}"; then
|
|
||||||
ynh_replace_string "__NAME__" "$app" "$finalnginxconf"
|
|
||||||
fi
|
|
||||||
if test -n "${final_path:-}"; then
|
|
||||||
ynh_replace_string "__FINALPATH__" "$final_path" "$finalnginxconf"
|
|
||||||
fi
|
|
||||||
ynh_store_file_checksum "$finalnginxconf"
|
|
||||||
|
|
||||||
sudo systemctl reload nginx
|
|
||||||
}
|
|
||||||
|
|
||||||
ynh_remove_nginx_config () {
|
|
||||||
ynh_secure_remove "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
||||||
sudo systemctl reload nginx
|
|
||||||
}
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECKING
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
CHECK_DOMAINPATH () { # Vérifie la disponibilité du path et du domaine.
|
|
||||||
if sudo yunohost app --help | grep --quiet url-available
|
|
||||||
then
|
|
||||||
# Check availability of a web path
|
|
||||||
ynh_webpath_available $domain $path_url
|
|
||||||
# Register/book a web path for an app
|
|
||||||
ynh_webpath_register $app $domain $path_url
|
|
||||||
else
|
|
||||||
# Use the legacy command
|
|
||||||
sudo yunohost app checkurl $domain$path_url -a $app
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# DISPLAYING
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# NO_PRINT () { # Supprime l'affichage dans stdout pour la commande en argument.
|
|
||||||
# set +x
|
|
||||||
# $@
|
|
||||||
# set -x
|
|
||||||
# }
|
|
||||||
|
|
||||||
WARNING () { # Écrit sur le canal d'erreur pour passer en warning.
|
|
||||||
$@ >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
# SUPPRESS_WARNING () { # Force l'écriture sur la sortie standard
|
|
||||||
# $@ 2>&1
|
|
||||||
# }
|
|
||||||
|
|
||||||
# QUIET () { # Redirige la sortie standard dans /dev/null
|
|
||||||
# $@ > /dev/null
|
|
||||||
# }
|
|
||||||
|
|
||||||
ALL_QUIET () { # Redirige la sortie standard et d'erreur dans /dev/null
|
|
||||||
$@ > /dev/null 2>&1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP
|
# BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
BACKUP_FAIL_UPGRADE () {
|
|
||||||
WARNING echo "Upgrade failed."
|
|
||||||
app_bck=${app//_/-} # Replace all '_' by '-'
|
|
||||||
if sudo yunohost backup list | grep -q $app_bck-pre-upgrade$backup_number; then # Vérifie l'existence de l'archive avant de supprimer l'application et de restaurer
|
|
||||||
sudo yunohost app remove $app # Supprime l'application avant de la restaurer.
|
|
||||||
sudo yunohost backup restore --ignore-hooks $app_bck-pre-upgrade$backup_number --apps $app --force # Restore the backup if upgrade failed
|
|
||||||
ynh_die "The app was restored to the way it was before the failed upgrade."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
BACKUP_BEFORE_UPGRADE () { # Backup the current version of the app, restore it if the upgrade fails
|
|
||||||
backup_number=1
|
|
||||||
old_backup_number=2
|
|
||||||
app_bck=${app//_/-} # Replace all '_' by '-'
|
|
||||||
if sudo yunohost backup list | grep -q $app_bck-pre-upgrade1; then # Vérifie l'existence d'une archive déjà numéroté à 1.
|
|
||||||
backup_number=2 # Et passe le numéro de l'archive à 2
|
|
||||||
old_backup_number=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
sudo yunohost backup create --ignore-hooks --apps $app --name $app_bck-pre-upgrade$backup_number # Créer un backup différent de celui existant.
|
|
||||||
if [ "$?" -eq 0 ]; then # Si le backup est un succès, supprime l'archive précédente.
|
|
||||||
if sudo yunohost backup list | grep -q $app_bck-pre-upgrade$old_backup_number; then # Vérifie l'existence de l'ancienne archive avant de la supprimer, pour éviter une erreur.
|
|
||||||
QUIET sudo yunohost backup delete $app_bck-pre-upgrade$old_backup_number
|
|
||||||
fi
|
|
||||||
else # Si le backup a échoué
|
|
||||||
ynh_die "Backup failed, the upgrade process was aborted."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
HUMAN_SIZE () { # Transforme une taille en Ko en une taille lisible pour un humain
|
HUMAN_SIZE () { # Transforme une taille en Ko en une taille lisible pour un humain
|
||||||
human=$(numfmt --to=iec --from-unit=1K $1)
|
human=$(numfmt --to=iec --from-unit=1K $1)
|
||||||
echo $human
|
echo $human
|
||||||
|
@ -138,236 +25,13 @@ HUMAN_SIZE () { # Transforme une taille en Ko en une taille lisible pour un huma
|
||||||
|
|
||||||
CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant
|
CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant
|
||||||
file_to_analyse=$1
|
file_to_analyse=$1
|
||||||
backup_size=$(sudo du --summarize "$file_to_analyse" | cut -f1)
|
backup_size=$(du --summarize "$file_to_analyse" | cut -f1)
|
||||||
free_space=$(sudo df --output=avail "/home/yunohost.backup" | sed 1d)
|
free_space=$(df --output=avail "/home/yunohost.backup" | sed 1d)
|
||||||
|
|
||||||
if [ $free_space -le $backup_size ]
|
if [ $free_space -le $backup_size ]
|
||||||
then
|
then
|
||||||
WARNING echo "Espace insuffisant pour sauvegarder $file_to_analyse."
|
echo "Espace insuffisant pour sauvegarder $file_to_analyse." >&2
|
||||||
WARNING echo "Espace disponible: $(HUMAN_SIZE $free_space)"
|
echo "Espace disponible: $(HUMAN_SIZE $free_space)" >&2
|
||||||
ynh_die "Espace nécessaire: $(HUMAN_SIZE $backup_size)"
|
ynh_die "Espace nécessaire: $(HUMAN_SIZE $backup_size)"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Ce helper est temporaire et sert de remplacement à la véritable fonction ynh_restore_file. Le temps qu'elle arrive...
|
|
||||||
ynh_restore_file () {
|
|
||||||
if [ -f "$1" ]; then
|
|
||||||
ynh_die "There is already a file at this path: $1"
|
|
||||||
fi
|
|
||||||
sudo cp -a "${YNH_APP_BACKUP_DIR}$1" "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
#=================================================
|
|
||||||
# FUTUR YNH HELPERS
|
|
||||||
#=================================================
|
|
||||||
# Importer ce fichier de fonction avant celui des helpers officiel
|
|
||||||
# Ainsi, les officiels prendront le pas sur ceux-ci le cas échéant
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Normalize the url path syntax
|
|
||||||
# Handle the slash at the beginning of path and its absence at ending
|
|
||||||
# Return a normalized url path
|
|
||||||
#
|
|
||||||
# example: url_path=$(ynh_normalize_url_path $url_path)
|
|
||||||
# ynh_normalize_url_path example -> /example
|
|
||||||
# ynh_normalize_url_path /example -> /example
|
|
||||||
# ynh_normalize_url_path /example/ -> /example
|
|
||||||
# ynh_normalize_url_path / -> /
|
|
||||||
#
|
|
||||||
# usage: ynh_normalize_url_path path_to_normalize
|
|
||||||
# | arg: url_path_to_normalize - URL path to normalize before using it
|
|
||||||
ynh_normalize_url_path () {
|
|
||||||
path_url=$1
|
|
||||||
test -n "$path_url" || ynh_die "ynh_normalize_url_path expect a URL path as first argument and received nothing."
|
|
||||||
if [ "${path_url:0:1}" != "/" ]; then # If the first character is not a /
|
|
||||||
path_url="/$path_url" # Add / at begin of path variable
|
|
||||||
fi
|
|
||||||
if [ "${path_url:${#path_url}-1}" == "/" ] && [ ${#path_url} -gt 1 ]; then # If the last character is a / and that not the only character.
|
|
||||||
path_url="${path_url:0:${#path_url}-1}" # Delete the last character
|
|
||||||
fi
|
|
||||||
echo $path_url
|
|
||||||
}
|
|
||||||
|
|
||||||
# Manage a fail of the script
|
|
||||||
#
|
|
||||||
# Print a warning to inform that the script was failed
|
|
||||||
# Execute the ynh_clean_setup function if used in the app script
|
|
||||||
#
|
|
||||||
# usage of ynh_clean_setup function
|
|
||||||
# This function provide a way to clean some residual of installation that not managed by remove script.
|
|
||||||
# To use it, simply add in your script:
|
|
||||||
# ynh_clean_setup () {
|
|
||||||
# instructions...
|
|
||||||
# }
|
|
||||||
# This function is optionnal.
|
|
||||||
#
|
|
||||||
# Usage: ynh_exit_properly is used only by the helper ynh_abort_if_errors.
|
|
||||||
# You must not use it directly.
|
|
||||||
ynh_exit_properly () {
|
|
||||||
exit_code=$?
|
|
||||||
if [ "$exit_code" -eq 0 ]; then
|
|
||||||
exit 0 # Exit without error if the script ended correctly
|
|
||||||
fi
|
|
||||||
|
|
||||||
trap '' EXIT # Ignore new exit signals
|
|
||||||
set +eu # Do not exit anymore if a command fail or if a variable is empty
|
|
||||||
|
|
||||||
echo -e "!!\n $app's script has encountered an error. Its execution was cancelled.\n!!" >&2
|
|
||||||
|
|
||||||
if type -t ynh_clean_setup > /dev/null; then # Check if the function exist in the app script.
|
|
||||||
ynh_clean_setup # Call the function to do specific cleaning for the app.
|
|
||||||
fi
|
|
||||||
|
|
||||||
ynh_die # Exit with error status
|
|
||||||
}
|
|
||||||
|
|
||||||
# Exit if an error occurs during the execution of the script.
|
|
||||||
#
|
|
||||||
# Stop immediatly the execution if an error occured or if a empty variable is used.
|
|
||||||
# The execution of the script is derivate to ynh_exit_properly function before exit.
|
|
||||||
#
|
|
||||||
# Usage: ynh_abort_if_errors
|
|
||||||
ynh_abort_if_errors () {
|
|
||||||
set -eu # Exit if a command fail, and if a variable is used unset.
|
|
||||||
trap ynh_exit_properly EXIT # Capturing exit signals on shell script
|
|
||||||
}
|
|
||||||
|
|
||||||
# Find a free port and return it
|
|
||||||
#
|
|
||||||
# example: port=$(ynh_find_port 8080)
|
|
||||||
#
|
|
||||||
# usage: ynh_find_port begin_port
|
|
||||||
# | arg: begin_port - port to start to search
|
|
||||||
ynh_find_port () {
|
|
||||||
port=$1
|
|
||||||
test -n "$port" || ynh_die "The argument of ynh_find_port must be a valid port."
|
|
||||||
while netcat -z 127.0.0.1 $port # Check if the port is free
|
|
||||||
do
|
|
||||||
port=$((port+1)) # Else, pass to next port
|
|
||||||
done
|
|
||||||
echo $port
|
|
||||||
}
|
|
||||||
|
|
||||||
# Delete a system user
|
|
||||||
#
|
|
||||||
# usage: ynh_system_user_delete user_name
|
|
||||||
# | arg: user_name - Name of the system user that will be create
|
|
||||||
ynh_system_user_delete () {
|
|
||||||
if ynh_system_user_exists "$1" # Check if the user exists on the system
|
|
||||||
then
|
|
||||||
echo "Remove the user $1" >&2
|
|
||||||
sudo userdel $1
|
|
||||||
else
|
|
||||||
echo "The user $1 was not found" >&2
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Substitute/replace a string by another in a file
|
|
||||||
#
|
|
||||||
# usage: ynh_replace_string match_string replace_string target_file
|
|
||||||
# | arg: match_string - String to be searched and replaced in the file
|
|
||||||
# | arg: replace_string - String that will replace matches
|
|
||||||
# | arg: target_file - File in which the string will be replaced.
|
|
||||||
ynh_replace_string () {
|
|
||||||
delimit=@
|
|
||||||
match_string=${1//${delimit}/"\\${delimit}"} # Escape the delimiter if it's in the string.
|
|
||||||
replace_string=${2//${delimit}/"\\${delimit}"}
|
|
||||||
workfile=$3
|
|
||||||
|
|
||||||
sudo sed --in-place "s${delimit}${match_string}${delimit}${replace_string}${delimit}g" "$workfile"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Remove a file or a directory securely
|
|
||||||
#
|
|
||||||
# usage: ynh_secure_remove path_to_remove
|
|
||||||
# | arg: path_to_remove - File or directory to remove
|
|
||||||
ynh_secure_remove () {
|
|
||||||
path_to_remove=$1
|
|
||||||
forbidden_path=" \
|
|
||||||
/var/www \
|
|
||||||
/home/yunohost.app"
|
|
||||||
|
|
||||||
if [[ "$forbidden_path" =~ "$path_to_remove" \
|
|
||||||
# Match all paths or subpaths in $forbidden_path
|
|
||||||
|| "$path_to_remove" =~ ^/[[:alnum:]]+$ \
|
|
||||||
# Match all first level paths from / (Like /var, /root, etc...)
|
|
||||||
|| "${path_to_remove:${#path_to_remove}-1}" = "/" ]]
|
|
||||||
# Match if the path finishes by /. Because it seems there is an empty variable
|
|
||||||
then
|
|
||||||
echo "Avoid deleting $path_to_remove." >&2
|
|
||||||
else
|
|
||||||
if [ -e "$path_to_remove" ]
|
|
||||||
then
|
|
||||||
sudo rm -R "$path_to_remove"
|
|
||||||
else
|
|
||||||
echo "$path_to_remove wasn't deleted because it doesn't exist." >&2
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check availability of a web path
|
|
||||||
#
|
|
||||||
# example: ynh_webpath_available some.domain.tld /coffee
|
|
||||||
#
|
|
||||||
# usage: ynh_webpath_available domain path
|
|
||||||
# | arg: domain - the domain/host of the url
|
|
||||||
# | arg: path - the web path to check the availability of
|
|
||||||
ynh_webpath_available () {
|
|
||||||
local domain=$1
|
|
||||||
local path=$2
|
|
||||||
sudo yunohost domain url-available $domain $path
|
|
||||||
}
|
|
||||||
|
|
||||||
# Register/book a web path for an app
|
|
||||||
#
|
|
||||||
# example: ynh_webpath_register wordpress some.domain.tld /coffee
|
|
||||||
#
|
|
||||||
# usage: ynh_webpath_register app domain path
|
|
||||||
# | arg: app - the app for which the domain should be registered
|
|
||||||
# | arg: domain - the domain/host of the web path
|
|
||||||
# | arg: path - the web path to be registered
|
|
||||||
ynh_webpath_register () {
|
|
||||||
local app=$1
|
|
||||||
local domain=$2
|
|
||||||
local path=$3
|
|
||||||
sudo yunohost app register-url $app $domain $path
|
|
||||||
}
|
|
||||||
|
|
||||||
# Calculate and store a file checksum into the app settings
|
|
||||||
#
|
|
||||||
# $app should be defined when calling this helper
|
|
||||||
#
|
|
||||||
# usage: ynh_store_file_checksum file
|
|
||||||
# | arg: file - The file on which the checksum will performed, then stored.
|
|
||||||
ynh_store_file_checksum () {
|
|
||||||
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
|
||||||
ynh_app_setting_set $app $checksum_setting_name $(sudo md5sum "$1" | cut -d' ' -f1)
|
|
||||||
}
|
|
||||||
|
|
||||||
# Verify the checksum and backup the file if it's different
|
|
||||||
# This helper is primarily meant to allow to easily backup personalised/manually
|
|
||||||
# modified config files.
|
|
||||||
#
|
|
||||||
# $app should be defined when calling this helper
|
|
||||||
#
|
|
||||||
# usage: ynh_backup_if_checksum_is_different file
|
|
||||||
# | arg: file - The file on which the checksum test will be perfomed.
|
|
||||||
#
|
|
||||||
# | ret: Return the name a the backup file, or nothing
|
|
||||||
ynh_backup_if_checksum_is_different () {
|
|
||||||
local file=$1
|
|
||||||
local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
|
||||||
local checksum_value=$(ynh_app_setting_get $app $checksum_setting_name)
|
|
||||||
if [ -n "$checksum_value" ]
|
|
||||||
then # Proceed only if a value was stored into the app settings
|
|
||||||
if ! echo "$checksum_value $file" | sudo md5sum -c --status
|
|
||||||
then # If the checksum is now different
|
|
||||||
backup_file="/home/yunohost.conf/backup/$file.backup.$(date '+%Y%m%d.%H%M%S')"
|
|
||||||
sudo mkdir -p "$(dirname "$backup_file")"
|
|
||||||
sudo cp -a "$file" "$backup_file" # Backup the current file
|
|
||||||
echo "File $file has been manually modified since the installation or last upgrade. So it has been duplicated in $backup_file" >&2
|
|
||||||
echo "$backup_file" # Return the name of the backup file
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
|
@ -14,9 +14,9 @@ set -eu
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ ! -e _common.sh ]; then
|
if [ ! -e _common.sh ]; then
|
||||||
# Rapatrie le fichier de fonctions si il n'est pas dans le dossier courant
|
# Get the _common.sh file if it's not in the current directory
|
||||||
sudo cp ../settings/scripts/_common.sh ./_common.sh
|
cp ../settings/scripts/_common.sh ./_common.sh
|
||||||
sudo chmod a+rx _common.sh
|
chmod a+rx _common.sh
|
||||||
fi
|
fi
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
@ -35,7 +35,7 @@ domain=$(ynh_app_setting_get $app domain)
|
||||||
# BACKUP OF THE NGINX CONFIGURATION
|
# BACKUP OF THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "${YNH_APP_BACKUP_DIR}/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC BACKUP
|
# SPECIFIC BACKUP
|
||||||
|
@ -43,23 +43,22 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "${YNH_APP_BACKUP_DIR}/etc/ng
|
||||||
# BACKUP TRANSMISSION CONFIGURATION
|
# BACKUP TRANSMISSION CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup "/etc/transmission-daemon/settings.json" "${YNH_APP_BACKUP_DIR}/etc/transmission-daemon/settings.json"
|
ynh_backup "/etc/transmission-daemon/settings.json"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP DATA
|
# BACKUP DATA
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
CHECK_SIZE "/usr/share/transmission"
|
ynh_backup "/usr/share/transmission"
|
||||||
ynh_backup "/usr/share/transmission" "${YNH_APP_BACKUP_DIR}/usr/share/transmission"
|
|
||||||
|
|
||||||
CHECK_SIZE "/var/lib/transmission-daemon"
|
ynh_backup "/var/lib/transmission-daemon"
|
||||||
ynh_backup "/var/lib/transmission-daemon" "${YNH_APP_BACKUP_DIR}/var/lib/transmission-daemon"
|
|
||||||
|
|
||||||
backup_core_only=$(ynh_app_setting_get $app backup_core_only)
|
backup_core_only=$(ynh_app_setting_get $app backup_core_only)
|
||||||
if [ -z $backup_core_only ] # Si backup_core_only a une valeur dans le fichier settings.yml, ne sauvegarde pas le dossier data
|
# If backup_core_only have a value in settings.yml, do not backup the data directory
|
||||||
|
if [ -z $backup_core_only ]
|
||||||
then
|
then
|
||||||
CHECK_SIZE "/home/yunohost.transmission"
|
CHECK_SIZE "/home/yunohost.transmission"
|
||||||
ynh_backup "/home/yunohost.transmission" "${YNH_APP_BACKUP_DIR}/home/yunohost.transmission"
|
ynh_backup "/home/yunohost.transmission"
|
||||||
else
|
else
|
||||||
echo "Data dir will not saved, because backup_core_only is set." >&2
|
echo "Data dir will not saved, because backup_core_only is set." >&2
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -13,7 +13,8 @@ source /usr/share/yunohost/helpers
|
||||||
# MANAGE FAILURE OF THE SCRIPT
|
# MANAGE FAILURE OF THE SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est détectée.
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
|
@ -28,8 +29,13 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
path_url=$(ynh_normalize_url_path $path_url) # Vérifie et corrige la syntaxe du path.
|
# Normalize the url path syntax
|
||||||
CHECK_DOMAINPATH # Vérifie la disponibilité du path et du domaine.
|
path_url=$(ynh_normalize_url_path $path_url)
|
||||||
|
|
||||||
|
# Check web path availability
|
||||||
|
ynh_webpath_available $domain $path_url
|
||||||
|
# Register (book) web path
|
||||||
|
ynh_webpath_register $app $domain $path_url
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
|
@ -44,14 +50,16 @@ ynh_app_setting_set $app path $path_url
|
||||||
# FIND AND OPEN PORTS
|
# FIND AND OPEN PORTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
port=$(ynh_find_port 9091) # Cherche un port libre.
|
# Find a free port
|
||||||
# Ouvre le port dans le firewall
|
port=$(ynh_find_port 9091)
|
||||||
ALL_QUIET sudo yunohost firewall allow --no-upnp TCP $port
|
# Open this port
|
||||||
|
yunohost firewall allow --no-upnp TCP $port >/dev/null 2>&1
|
||||||
ynh_app_setting_set $app port $port
|
ynh_app_setting_set $app port $port
|
||||||
|
|
||||||
peer_port=$(ynh_find_port 51413) # Cherche un port libre.
|
# Find a free port
|
||||||
# Ouvre le port dans le firewall
|
peer_port=$(ynh_find_port 51413)
|
||||||
ALL_QUIET sudo yunohost firewall allow TCP $peer_port
|
# Open this port
|
||||||
|
yunohost firewall allow TCP $peer_port >/dev/null 2>&1
|
||||||
ynh_app_setting_set $app peer_port $peer_port
|
ynh_app_setting_set $app peer_port $peer_port
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -67,7 +75,7 @@ ynh_package_install transmission-daemon
|
||||||
# Add a "/" at the end of path_url for next commands
|
# Add a "/" at the end of path_url for next commands
|
||||||
# To avoid a double / in the nginx config file.
|
# To avoid a double / in the nginx config file.
|
||||||
[ "$path_url" = "/" ] || path_url=${path_url}/
|
[ "$path_url" = "/" ] || path_url=${path_url}/
|
||||||
ynh_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP
|
# SPECIFIC SETUP
|
||||||
|
@ -75,23 +83,23 @@ ynh_nginx_config
|
||||||
# CREATE DIRECTORIES
|
# CREATE DIRECTORIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo mkdir -p /home/yunohost.transmission/{progress,completed,watched}
|
mkdir -p /home/yunohost.transmission/{progress,completed,watched}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SECURING FILES AND DIRECTORIES
|
# SECURING FILES AND DIRECTORIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo chown -R debian-transmission:www-data /home/yunohost.transmission/
|
chown -R debian-transmission:www-data /home/yunohost.transmission/
|
||||||
sudo chown -R debian-transmission: /home/yunohost.transmission/{progress,watched}
|
chown -R debian-transmission: /home/yunohost.transmission/{progress,watched}
|
||||||
sudo chmod -R 764 /home/yunohost.transmission
|
chmod -R 764 /home/yunohost.transmission
|
||||||
sudo chmod -R 777 /home/yunohost.transmission/watched
|
chmod -R 777 /home/yunohost.transmission/watched
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURE TRANSMISSION
|
# CONFIGURE TRANSMISSION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Transmission has to be stopped before modifying its config
|
# Transmission has to be stopped before modifying its config
|
||||||
sudo systemctl stop transmission-daemon
|
systemctl stop transmission-daemon
|
||||||
|
|
||||||
# Create a RPC password
|
# Create a RPC password
|
||||||
rpcpassword=$(ynh_string_random)
|
rpcpassword=$(ynh_string_random)
|
||||||
|
@ -101,7 +109,7 @@ ynh_replace_string "__RPC_PASSWORD_TO_CHANGE__" "$rpcpassword" ../conf/settings.
|
||||||
ynh_replace_string "__PATH__" "$path_url" ../conf/settings.json
|
ynh_replace_string "__PATH__" "$path_url" ../conf/settings.json
|
||||||
ynh_replace_string "__PEER_PORT__" "$peer_port" ../conf/settings.json
|
ynh_replace_string "__PEER_PORT__" "$peer_port" ../conf/settings.json
|
||||||
ynh_replace_string "__PORT__" "$port" ../conf/settings.json
|
ynh_replace_string "__PORT__" "$port" ../conf/settings.json
|
||||||
sudo cp ../conf/settings.json /etc/transmission-daemon/settings.json
|
cp ../conf/settings.json /etc/transmission-daemon/settings.json
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE THE CHECKSUM OF THE CONFIG FILE
|
# STORE THE CHECKSUM OF THE CONFIG FILE
|
||||||
|
@ -125,8 +133,8 @@ ynh_multimedia_addfolder "/home/yunohost.transmission/watched" "share/Torrent to
|
||||||
# PATCH SOURCE TO ADD A DOWNLOAD BUTTON
|
# PATCH SOURCE TO ADD A DOWNLOAD BUTTON
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo cp ../sources/extra_files/app/toolbar-downloads.png /usr/share/transmission/web/style/transmission/images/toolbar-downloads.png
|
cp ../sources/extra_files/app/toolbar-downloads.png /usr/share/transmission/web/style/transmission/images/toolbar-downloads.png
|
||||||
sudo bash -c 'cat ../sources/extra_files/app/ynh_common.css >> /usr/share/transmission/web/style/transmission/common.css'
|
cat ../sources/extra_files/app/ynh_common.css >> /usr/share/transmission/web/style/transmission/common.css
|
||||||
ynh_replace_string "<div id=\"toolbar-inspector\" title=\"Toggle Inspector\"></div>" "<div id=\"toolbar-inspector\" title=\"Toggle Inspector\"></div><div id=\"toolbar-separator\"></div><a href=\"../../downloads/\" id=\"toolbar-downloads\" title=\"Downloads\" target=\"_blank\"></a>" /usr/share/transmission/web/index.html
|
ynh_replace_string "<div id=\"toolbar-inspector\" title=\"Toggle Inspector\"></div>" "<div id=\"toolbar-inspector\" title=\"Toggle Inspector\"></div><div id=\"toolbar-separator\"></div><a href=\"../../downloads/\" id=\"toolbar-downloads\" title=\"Downloads\" target=\"_blank\"></a>" /usr/share/transmission/web/index.html
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -135,16 +143,16 @@ ynh_replace_string "<div id=\"toolbar-inspector\" title=\"Toggle Inspector\"></d
|
||||||
# ENABLE SERVICE IN ADMIN PANEL
|
# ENABLE SERVICE IN ADMIN PANEL
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo yunohost service add transmission-daemon --log "/var/log/syslog"
|
yunohost service add transmission-daemon --log "/var/log/syslog"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START TRANSMISSION
|
# START TRANSMISSION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo systemctl start transmission-daemon
|
systemctl start transmission-daemon
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo systemctl reload nginx
|
systemctl reload nginx
|
||||||
|
|
|
@ -32,24 +32,34 @@ ynh_package_autoremove transmission-common
|
||||||
# DISABLE SERVICE IN ADMIN PANEL
|
# DISABLE SERVICE IN ADMIN PANEL
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if sudo yunohost service status | grep -q transmission-daemon # Test l'existence du service dans Yunohost
|
if yunohost service status | grep -q transmission-daemon
|
||||||
then
|
then
|
||||||
echo "Remove transmission-daemon service"
|
echo "Remove transmission-daemon service"
|
||||||
sudo yunohost service remove transmission-daemon
|
yunohost service remove transmission-daemon
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CLOSE THE PORTS
|
# CLOSE THE PORTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ALL_QUIET sudo yunohost firewall disallow TCP $port
|
if yunohost firewall list | grep -q "\- $port$"
|
||||||
ALL_QUIET sudo yunohost firewall disallow TCP $peer_port
|
then
|
||||||
|
echo "Close port $port"
|
||||||
|
yunohost firewall disallow TCP $port 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if yunohost firewall list | grep -q "\- $peer_port$"
|
||||||
|
then
|
||||||
|
echo "Close port $peer_port"
|
||||||
|
yunohost firewall disallow TCP $peer_port 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE NGINX CONFIGURATION
|
# REMOVE THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_remove_nginx_config # Suppression de la configuration nginx
|
# Remove the dedicated nginx config
|
||||||
|
ynh_remove_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC REMOVE
|
# SPECIFIC REMOVE
|
||||||
|
@ -58,14 +68,15 @@ ynh_remove_nginx_config # Suppression de la configuration nginx
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
backup_core_only=$(ynh_app_setting_get $app backup_core_only)
|
backup_core_only=$(ynh_app_setting_get $app backup_core_only)
|
||||||
if [ -z $backup_core_only ] # Si backup_core_only a une valeur dans le fichier settings.yml, ne supprime pas le dossier data
|
# If backup_core_only have a value in settings.yml, do not remove the data directory
|
||||||
|
if [ -z $backup_core_only ]
|
||||||
then
|
then
|
||||||
ynh_secure_remove /home/yunohost.transmission
|
ynh_secure_remove /home/yunohost.transmission
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# And remove the link in yunohost.multimedia
|
# And remove the link in yunohost.multimedia
|
||||||
sudo rm "/home/yunohost.multimedia/share/Torrents"
|
rm "/home/yunohost.multimedia/share/Torrents"
|
||||||
sudo rm "/home/yunohost.multimedia/share/Torrent to download"
|
rm "/home/yunohost.multimedia/share/Torrent to download"
|
||||||
|
|
||||||
# Web interface
|
# Web interface
|
||||||
ynh_secure_remove /usr/share/transmission
|
ynh_secure_remove /usr/share/transmission
|
||||||
|
|
|
@ -14,9 +14,9 @@ set -eu
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ ! -e _common.sh ]; then
|
if [ ! -e _common.sh ]; then
|
||||||
# Rapatrie le fichier de fonctions si il n'est pas dans le dossier courant
|
# Get the _common.sh file if it's not in the current directory
|
||||||
sudo cp ../settings/scripts/_common.sh ./_common.sh
|
cp ../settings/scripts/_common.sh ./_common.sh
|
||||||
sudo chmod a+rx _common.sh
|
chmod a+rx _common.sh
|
||||||
fi
|
fi
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
@ -36,7 +36,7 @@ peer_port=$(ynh_app_setting_get $app peer_port)
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo yunohost app checkurl "${domain}${path_url}" -a "$app" \
|
ynh_webpath_available $domain $path_url \
|
||||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -51,8 +51,8 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
# OPEN PORTS
|
# OPEN PORTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ALL_QUIET sudo yunohost firewall allow --no-upnp TCP $port
|
yunohost firewall allow --no-upnp TCP $port >/dev/null 2>&1
|
||||||
ALL_QUIET sudo yunohost firewall allow TCP $peer_port
|
yunohost firewall allow TCP $peer_port >/dev/null 2>&1
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORE
|
# SPECIFIC RESTORE
|
||||||
|
@ -67,7 +67,7 @@ ynh_package_install transmission-daemon
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Transmission has to be stopped before modifying its config
|
# Transmission has to be stopped before modifying its config
|
||||||
sudo systemctl stop transmission-daemon
|
systemctl stop transmission-daemon
|
||||||
|
|
||||||
ynh_secure_remove /etc/transmission-daemon/settings.json
|
ynh_secure_remove /etc/transmission-daemon/settings.json
|
||||||
ynh_restore_file /etc/transmission-daemon/settings.json
|
ynh_restore_file /etc/transmission-daemon/settings.json
|
||||||
|
@ -82,17 +82,20 @@ ynh_restore_file /usr/share/transmission
|
||||||
ynh_secure_remove /var/lib/transmission-daemon
|
ynh_secure_remove /var/lib/transmission-daemon
|
||||||
ynh_restore_file /var/lib/transmission-daemon
|
ynh_restore_file /var/lib/transmission-daemon
|
||||||
|
|
||||||
if [ -d "${YNH_APP_BACKUP_DIR}/home/yunohost.transmission" ] # Le dossier data est restauré seulement si il existe. Si le backup a été fait avec l'option backup_core_only, ce dossier n'a pas été sauvegardé.
|
# The data directory is restored only if it's in the backup.
|
||||||
|
# If the backup have made with backup_core_only option, this directory didn't saved.
|
||||||
|
if [ -d "${YNH_APP_BACKUP_DIR}/home/yunohost.transmission" ]
|
||||||
then
|
then
|
||||||
ynh_restore_file "/home/yunohost.transmission"
|
ynh_restore_file "/home/yunohost.transmission"
|
||||||
else
|
else
|
||||||
sudo mkdir -p /home/yunohost.transmission/{progress,completed,watched}
|
mkdir -p /home/yunohost.transmission/{progress,completed,watched}
|
||||||
sudo chown -R debian-transmission:www-data /home/yunohost.transmission/
|
chown -R debian-transmission:www-data /home/yunohost.transmission/
|
||||||
sudo chown -R debian-transmission: /home/yunohost.transmission/{progress,watched}
|
chown -R debian-transmission: /home/yunohost.transmission/{progress,watched}
|
||||||
sudo chmod -R 640 /home/yunohost.transmission
|
chmod -R 640 /home/yunohost.transmission
|
||||||
sudo chmod -R 777 /home/yunohost.transmission/watched
|
chmod -R 777 /home/yunohost.transmission/watched
|
||||||
fi
|
fi
|
||||||
ynh_app_setting_delete $app backup_core_only # Retire l'option backup_core_only du fichier settings.yml le cas échéant
|
# Remove the backup_core_only option from the settings.yml
|
||||||
|
ynh_app_setting_delete $app backup_core_only
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# YUNOHOST MULTIMEDIA INTEGRATION
|
# YUNOHOST MULTIMEDIA INTEGRATION
|
||||||
|
@ -110,16 +113,16 @@ ynh_multimedia_addfolder "/home/yunohost.transmission/watched" "share/Torrent to
|
||||||
# ENABLE SERVICE IN ADMIN PANEL
|
# ENABLE SERVICE IN ADMIN PANEL
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo yunohost service add transmission-daemon --log "/var/log/syslog"
|
yunohost service add transmission-daemon --log "/var/log/syslog"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START TRANSMISSION
|
# START TRANSMISSION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo systemctl start transmission-daemon
|
systemctl start transmission-daemon
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo systemctl reload nginx
|
systemctl reload nginx
|
||||||
|
|
|
@ -37,18 +37,20 @@ fi
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_app_setting_set $app backup_core_only 1 # Indique au backup/restore de ne pas sauvegarder le dossier de data.
|
# Inform the backup/restore process that it should not save the data directory
|
||||||
BACKUP_BEFORE_UPGRADE # Backup the current version of the app
|
ynh_app_setting_set $app backup_core_only 1
|
||||||
|
ynh_backup_before_upgrade # Backup the current version of the app
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
BACKUP_FAIL_UPGRADE # restore it if the upgrade fails
|
ynh_restore_upgradebackup # restore it if the upgrade fails
|
||||||
}
|
}
|
||||||
ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est détectée.
|
ynh_abort_if_errors # Exit if an error occurs during the execution of the script
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK THE PATH
|
# CHECK THE PATH
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
path_url=$(ynh_normalize_url_path $path_url) # Vérifie et corrige la syntaxe du path.
|
# Normalize the URL path syntax
|
||||||
|
path_url=$(ynh_normalize_url_path $path_url)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
|
@ -59,7 +61,7 @@ path_url=$(ynh_normalize_url_path $path_url) # Vérifie et corrige la syntaxe du
|
||||||
# Add a "/" at the end of path_url for next commands
|
# Add a "/" at the end of path_url for next commands
|
||||||
# To avoid a double / in the nginx config file.
|
# To avoid a double / in the nginx config file.
|
||||||
[ "$path_url" = "/" ] || path_url=${path_url}/
|
[ "$path_url" = "/" ] || path_url=${path_url}/
|
||||||
ynh_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
|
@ -67,25 +69,25 @@ ynh_nginx_config
|
||||||
# CREATE DIRECTORIES
|
# CREATE DIRECTORIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo mkdir -p /home/yunohost.transmission/{progress,completed,watched}
|
mkdir -p /home/yunohost.transmission/{progress,completed,watched}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SECURING FILES AND DIRECTORIES
|
# SECURING FILES AND DIRECTORIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo chown -R debian-transmission:www-data /home/yunohost.transmission/
|
chown -R debian-transmission:www-data /home/yunohost.transmission/
|
||||||
sudo chown -R debian-transmission: /home/yunohost.transmission/{progress,watched}
|
chown -R debian-transmission: /home/yunohost.transmission/{progress,watched}
|
||||||
sudo chmod -R 640 /home/yunohost.transmission
|
chmod -R 640 /home/yunohost.transmission
|
||||||
sudo chmod -R 777 /home/yunohost.transmission/watched
|
chmod -R 777 /home/yunohost.transmission/watched
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURE TRANSMISSION
|
# CONFIGURE TRANSMISSION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Transmission has to be stopped before modifying its config
|
# Transmission has to be stopped before modifying its config
|
||||||
sudo systemctl stop transmission-daemon
|
systemctl stop transmission-daemon
|
||||||
|
|
||||||
# Créé un backup du fichier de config si il a été modifié.
|
# Verify the checksum and backup the file if it's different
|
||||||
ynh_backup_if_checksum_is_different /etc/transmission-daemon/settings.json
|
ynh_backup_if_checksum_is_different /etc/transmission-daemon/settings.json
|
||||||
|
|
||||||
# Create a RPC password
|
# Create a RPC password
|
||||||
|
@ -96,12 +98,13 @@ ynh_replace_string "__RPC_PASSWORD_TO_CHANGE__" "$rpcpassword" ../conf/settings.
|
||||||
ynh_replace_string "__PATH__" "$path_url" ../conf/settings.json
|
ynh_replace_string "__PATH__" "$path_url" ../conf/settings.json
|
||||||
ynh_replace_string "__PEER_PORT__" "$peer_port" ../conf/settings.json
|
ynh_replace_string "__PEER_PORT__" "$peer_port" ../conf/settings.json
|
||||||
ynh_replace_string "__PORT__" "$port" ../conf/settings.json
|
ynh_replace_string "__PORT__" "$port" ../conf/settings.json
|
||||||
sudo cp ../conf/settings.json /etc/transmission-daemon/settings.json
|
cp ../conf/settings.json /etc/transmission-daemon/settings.json
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE THE CHECKSUM OF THE CONFIG FILE
|
# STORE THE CHECKSUM OF THE CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
# Recalculate and store the config file checksum into the app settings
|
||||||
ynh_store_file_checksum /etc/transmission-daemon/settings.json
|
ynh_store_file_checksum /etc/transmission-daemon/settings.json
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -120,10 +123,10 @@ ynh_multimedia_addfolder "/home/yunohost.transmission/watched" "share/Torrent to
|
||||||
# PATCH SOURCE TO ADD A DOWNLOAD BUTTON
|
# PATCH SOURCE TO ADD A DOWNLOAD BUTTON
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo cp ../sources/extra_files/app/toolbar-downloads.png /usr/share/transmission/web/style/transmission/images/toolbar-downloads.png
|
cp ../sources/extra_files/app/toolbar-downloads.png /usr/share/transmission/web/style/transmission/images/toolbar-downloads.png
|
||||||
if ! grep --quiet "Inserted by Yunohost install script" /usr/share/transmission/web/style/transmission/common.css
|
if ! grep --quiet "Inserted by Yunohost install script" /usr/share/transmission/web/style/transmission/common.css
|
||||||
then
|
then
|
||||||
sudo bash -c 'cat ../sources/extra_files/app/ynh_common.css >> /usr/share/transmission/web/style/transmission/common.css'
|
cat ../sources/extra_files/app/ynh_common.css >> /usr/share/transmission/web/style/transmission/common.css
|
||||||
fi
|
fi
|
||||||
ynh_replace_string "<div id=\"toolbar-inspector\" title=\"Toggle Inspector\"></div>$" "<div id=\"toolbar-inspector\" title=\"Toggle Inspector\"></div><div id=\"toolbar-separator\"></div><a href=\"../../downloads/\" id=\"toolbar-downloads\" title=\"Downloads\" target=\"_blank\"></a>" /usr/share/transmission/web/index.html
|
ynh_replace_string "<div id=\"toolbar-inspector\" title=\"Toggle Inspector\"></div>$" "<div id=\"toolbar-inspector\" title=\"Toggle Inspector\"></div><div id=\"toolbar-separator\"></div><a href=\"../../downloads/\" id=\"toolbar-downloads\" title=\"Downloads\" target=\"_blank\"></a>" /usr/share/transmission/web/index.html
|
||||||
|
|
||||||
|
@ -131,13 +134,13 @@ ynh_replace_string "<div id=\"toolbar-inspector\" title=\"Toggle Inspector\"></d
|
||||||
# START TRANSMISSION
|
# START TRANSMISSION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo systemctl start transmission-daemon
|
systemctl start transmission-daemon
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
sudo systemctl reload nginx
|
systemctl reload nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE BACKUP_CORE_ONLY
|
# REMOVE BACKUP_CORE_ONLY
|
||||||
|
|
Loading…
Reference in a new issue