mirror of
https://github.com/YunoHost-Apps/couchpotato_ynh.git
synced 2024-09-03 18:16:22 +02:00
commit
06e0d129fe
14 changed files with 497 additions and 507 deletions
37
issue_template.md → .github/ISSUE_TEMPLATE.md
vendored
37
issue_template.md → .github/ISSUE_TEMPLATE.md
vendored
|
@ -1,22 +1,24 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us debug, it would be nice to fill the template as much as you can to help us, help you and help us all.
|
||||
about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently.
|
||||
|
||||
---
|
||||
|
||||
**How to post a meaningful bug report**
|
||||
1. *Read this whole template first.*
|
||||
2. *Determine if you are on the right place:*
|
||||
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change url...), you are on the right place!*
|
||||
- *Otherwise, the issue may be due to CouchPotato itself. Refer to its documentation or repository for help.*
|
||||
- *If you have a doubt, post here, we will figure it out together.*
|
||||
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
|
||||
- *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.*
|
||||
- *When in doubt, post here and we will figure it out together.*
|
||||
3. *Delete the italic comments as you write over them below, and remove this guide.*
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
### Describe the bug
|
||||
|
||||
*A clear and concise description of what the bug is.*
|
||||
|
||||
**Versions**
|
||||
### Context
|
||||
|
||||
- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
|
||||
- YunoHost version: x.x.x
|
||||
- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
|
||||
|
@ -25,22 +27,29 @@ about: Create a report to help us debug, it would be nice to fill the template a
|
|||
- Using, or trying to install package version/branch:
|
||||
- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*
|
||||
|
||||
**To Reproduce**
|
||||
*Steps to reproduce the behavior.*
|
||||
### Steps to reproduce
|
||||
|
||||
- *If you performed a command from the CLI, the command itself is enough. For example:*
|
||||
```sh
|
||||
sudo yunohost app install couchpotato
|
||||
sudo yunohost app install the_app
|
||||
```
|
||||
- *If you used the webadmin, please perform the equivalent command from the CLI first.*
|
||||
- *If the error occurs in your browser, explain what you did:*
|
||||
1. *Go to '...'*
|
||||
2. *Click on '....'*
|
||||
3. *Scroll down to '....'*
|
||||
2. *Click on '...'*
|
||||
3. *Scroll down to '...'*
|
||||
4. *See error*
|
||||
|
||||
**Expected behavior**
|
||||
### Expected behavior
|
||||
|
||||
*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*
|
||||
|
||||
**Logs**
|
||||
*After a failed command, YunoHost makes the log available to you, but also to others, thanks to `yunohost log display [log name] --share`. The actual command, with the correct log name, is displayed at the end of the failed attempt in the CLI. Execute it and copy here the share link it outputs.*
|
||||
### Logs
|
||||
|
||||
*When an operation fails, YunoHost provides a simple way to share the logs.*
|
||||
- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.*
|
||||
- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.*
|
||||
|
||||
*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)*
|
||||
|
||||
*If applicable and useful, add screenshots to help explain your problem.*
|
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
## Problem
|
||||
|
||||
- *Description of why you made this PR*
|
||||
|
||||
## Solution
|
||||
|
||||
- *And how do you fix that problem*
|
||||
|
||||
## PR Status
|
||||
|
||||
- [ ] Code finished and ready to be reviewed/tested
|
||||
- [ ] The fix/enhancement were manually tested (if applicable)
|
||||
|
||||
## Automatic tests
|
||||
|
||||
Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization)
|
|
@ -1,4 +1,4 @@
|
|||
## <img src="https://github.com/binhex/docker-templates/raw/master/binhex/images/couchpotato-icon.png" height="32" align="top"> CouchPotato <a href="https://yunohost.org/#/apps_in_progress_en"><img src="http://pix.toile-libre.org/upload/original/1440352021.png" height="32" align="right"></a>
|
||||
# CouchPotato for YunoHost
|
||||
|
||||
[](https://dash.yunohost.org/appci/app/couchpotato)  
|
||||
[](https://install-app.yunohost.org/?app=couchpotato)
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
# See here for more information
|
||||
# https://github.com/YunoHost/package_check#syntax-check_process-file
|
||||
|
||||
# Move this file from check_process.default to check_process when you have filled it.
|
||||
|
||||
;; Test complet
|
||||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/couchpotato" (PATH)"
|
||||
domain="domain.tld"
|
||||
path="/path"
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
|
|
|
@ -4,7 +4,7 @@ username =
|
|||
ssl_key =
|
||||
proxy_server =
|
||||
ssl_cert =
|
||||
data_dir = __DATADIR__
|
||||
data_dir = __APP_DATA_DIR__
|
||||
use_proxy = 0
|
||||
permission_file = 0755
|
||||
proxy_password =
|
||||
|
@ -43,7 +43,7 @@ to = /home/yunohost.multimedia/share/Video/Movies
|
|||
enabled = __RENAMER__
|
||||
|
||||
[blackhole]
|
||||
directory = __WATCHDIR__
|
||||
directory = __TRANSMISSION_WATCHDIR__
|
||||
manual = 0
|
||||
enabled = __BLACKHOLE__
|
||||
create_subdir = 0
|
||||
|
@ -54,7 +54,7 @@ magnet_file = 0
|
|||
username = transmission
|
||||
stalled_as_failed = True
|
||||
delete_failed = True
|
||||
rpc_url = __RPCURL__
|
||||
rpc_url = __TRANSMISSION_RPCURL__
|
||||
manual = 0
|
||||
enabled = __RPC__
|
||||
paused = False
|
||||
|
@ -62,7 +62,7 @@ host = 127.0.0.1:9091
|
|||
delete_files = True
|
||||
directory =
|
||||
remove_complete = True
|
||||
password = __RPCPASSWORD__
|
||||
password = __TRANSMISSION_RPCPASSWORD__
|
||||
|
||||
[suggestion]
|
||||
enabled = True
|
||||
|
|
|
@ -6,16 +6,16 @@
|
|||
"en": "Automatic movie downloader",
|
||||
"fr": "Téléchargement automatisé de film"
|
||||
},
|
||||
"version": "3.0.1~ynh1",
|
||||
"version": "3.0.1~ynh2",
|
||||
"url": "https://couchpota.to/",
|
||||
"license": "free",
|
||||
"license": "GPL-3.0-only",
|
||||
"maintainer": {
|
||||
"name": "Snipees",
|
||||
"email": "snipees@wareziens.net",
|
||||
"url": "https://github.com/Snipees"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.5"
|
||||
"yunohost": ">= 4.2.0"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
|
@ -26,19 +26,11 @@
|
|||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain for CouchPotato",
|
||||
"fr": "Choisissez un domaine pour CouchPotato"
|
||||
},
|
||||
"example": "example.com"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"type": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path for CouchPotato",
|
||||
"fr": "Choisissez un chemin pour CouchPotato"
|
||||
},
|
||||
"example": "/couchpotato",
|
||||
"default": "/couchpotato"
|
||||
}
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
## Problem
|
||||
- *Description of why you made this PR*
|
||||
|
||||
## Solution
|
||||
- *And how do you fix that problem*
|
||||
|
||||
## PR Status
|
||||
- [ ] Code finished.
|
||||
- [ ] Tested with Package_check.
|
||||
- [ ] Fix or enhancement tested.
|
||||
- [ ] Upgrade from last version tested.
|
||||
- [ ] Can be reviewed and tested.
|
||||
|
||||
## Package_check results
|
||||
---
|
||||
*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results*
|
||||
|
||||
[/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/couchpotato_ynh%20PR-NUM-%20(USERNAME)/)
|
|
@ -67,7 +67,7 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
|
|||
#=================================================
|
||||
|
||||
# Backup data
|
||||
ynh_backup --src_path="$app_data_dir"
|
||||
ynh_backup --src_path="$app_data_dir" --is_big
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
154
scripts/install
154
scripts/install
|
@ -8,7 +8,6 @@
|
|||
|
||||
source _common.sh
|
||||
source ynh_install_python
|
||||
source ynh_multimedia_3
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -39,7 +38,6 @@ final_path=/opt/yunohost/$app
|
|||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
app_data_dir=/home/yunohost.app/$app
|
||||
test ! -e "$app_data_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
|
||||
|
@ -58,7 +56,7 @@ ynh_app_setting_set --app=$app --key=app_data_dir --value=$app_data_dir
|
|||
#=================================================
|
||||
# FIND AND OPEN A PORT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring firewall..."
|
||||
ynh_script_progression --message="Finding an available port..."
|
||||
|
||||
# Find an available port
|
||||
port=$(ynh_find_port --port=5050)
|
||||
|
@ -69,6 +67,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port
|
|||
# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !)
|
||||
|
||||
# Open the port
|
||||
# ynh_script_progression --message="Configuring firewall..."
|
||||
# ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
|
||||
|
||||
#=================================================
|
||||
|
@ -78,23 +77,6 @@ ynh_script_progression --message="Installing dependencies..."
|
|||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..."
|
||||
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
git clone $source $final_path
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring nginx web server..."
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
|
@ -103,6 +85,27 @@ ynh_script_progression --message="Configuring system user..."
|
|||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..."
|
||||
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
git clone $source "$final_path"
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring NGINX web server..."
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
|
@ -111,17 +114,18 @@ ynh_system_user_create --username=$app --home_dir=$final_path
|
|||
ynh_script_progression --message="Make data directory..."
|
||||
|
||||
# Make directories
|
||||
mkdir -p $app_data_dir
|
||||
mkdir -p "$app_data_dir"
|
||||
chmod 750 "$app_data_dir"
|
||||
chmod -R o-rwx "$app_data_dir"
|
||||
chown -R $app:$app "$app_data_dir"
|
||||
|
||||
#=================================================
|
||||
# BUILD COUCHPOTATO
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building CouchPotato..."
|
||||
|
||||
# Set permissions to app files
|
||||
chown -R "$app": "$final_path"
|
||||
|
||||
ynh_install_python --python_version=$python_version
|
||||
ynh_use_python
|
||||
|
||||
pushd $final_path
|
||||
/opt/pyenv/versions/$python_version/bin/pip install --upgrade pyopenssl
|
||||
|
@ -133,82 +137,85 @@ popd
|
|||
#=================================================
|
||||
ynh_script_progression --message="Install YunoHost multimedia..."
|
||||
|
||||
# Creates the "Movies" subfolder in "Video"
|
||||
mkdir -p "$MEDIA_DIRECTORY/share/Video/Movies"
|
||||
|
||||
ynh_multimedia_build_main_dir
|
||||
|
||||
# Give write access to the yunohost.multimedia directory so that Couchpotato can move Movies to the Movie directory
|
||||
ynh_multimedia_addaccess $app
|
||||
|
||||
# Creates the "Movies" subfolder in "Video"
|
||||
mkdir -p "/home/yunohost.multimedia/share/Video/Movies"
|
||||
|
||||
# Fix permissions
|
||||
/home/yunohost.multimedia/ynh_media_build.sh
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE TRANSMISSION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring transmission..."
|
||||
|
||||
# Variable initialization
|
||||
rpc=""
|
||||
blackhole=""
|
||||
renamer=""
|
||||
|
||||
# Transmission link: Preferred method is direct RPC link. If not available, switch to watchdir.
|
||||
transmission_rpcurl=""
|
||||
transmission_rpcpassword=""
|
||||
transmission_watchdir=""
|
||||
|
||||
# Check if Transmission is installed
|
||||
if [[ -z $(yunohost app list -i -f transmission | grep -v 'apps:') ]]; then
|
||||
if [[ -z $(yunohost app list | grep -q 'id: $transmission') ]]; then
|
||||
|
||||
ynh_script_progression --message="Transmission is not installed. Disabling link to CouchPotato..."
|
||||
ynh_replace_string --match_string="__RPC__" --replace_string="0" --target_file="../conf/couchpotato.conf" # Disable Transmission RPC
|
||||
ynh_replace_string --match_string="__BLACKHOLE__" --replace_string="0" --target_file="../conf/couchpotato.conf" # Disable Transmission Watchdir
|
||||
ynh_replace_string --match_string="__RENAMER__" --replace_string="0" --target_file="../conf/couchpotato.conf" # Disable Renamer
|
||||
rpc="0"
|
||||
blackhole="0"
|
||||
renamer="0"
|
||||
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
|
||||
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)
|
||||
ynh_replace_string --match_string="__RPC__" --replace_string="1" --target_file="../conf/couchpotato.conf" # Enable Transmission RPC
|
||||
ynh_replace_string --match_string="__BLACKHOLE__" --replace_string="0" --target_file="../conf/couchpotato.conf" # Disable Transmission Watchdir
|
||||
ynh_replace_string --match_string="__RENAMER__" --replace_string="1" --target_file="../conf/couchpotato.conf" # Enable Renamer
|
||||
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
|
||||
ynh_script_progression --message="Transmission will be linked to CouchPotato with watchdir"
|
||||
|
||||
transmission_watchdir=$(ynh_app_setting_get --app=transmission --key=watchdir)
|
||||
ynh_replace_string --match_string="__RPC__" --replace_string="0" --target_file="../conf/couchpotato.conf" # Disable Transmission RPC
|
||||
ynh_replace_string --match_string="__BLACKHOLE__" --replace_string="1" --target_file="../conf/couchpotato.conf" # Enable Transmission Watchdir
|
||||
ynh_replace_string --match_string="__RENAMER__" --replace_string="1" --target_file="../conf/couchpotato.conf" # Enable Renamer
|
||||
rpc="0" # Disable Transmission RPC
|
||||
blackhole="1" # Enable Transmission Watchdir
|
||||
renamer="1" # Enable Renamer
|
||||
# If transmission uses YunoHost multimedia, use its folder for the renamer
|
||||
else
|
||||
ynh_script_progression --message="Cannot link Couchpotato to Transmission because Transmission has no RPC password or watchdir available."
|
||||
ynh_replace_string --match_string="__RPC__" --replace_string="0" --target_file="../conf/couchpotato.conf" # Disable Transmission RPC
|
||||
ynh_replace_string --match_string="__BLACKHOLE__" --replace_string="0" --target_file="../conf/couchpotato.conf" # Disable Transmission Watchdir
|
||||
ynh_replace_string --match_string="__RENAMER__" --replace_string="0" --target_file="../conf/couchpotato.conf" # Disable Renamer
|
||||
|
||||
rpc="0" # Disable Transmission RPC
|
||||
blackhole="0" # Disable Transmission Watchdir
|
||||
renamer="0" # Disable Renamer
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Modifying a config file..."
|
||||
ynh_script_progression --message="Adding a configuration file..."
|
||||
|
||||
app_config_file="${final_path}/settings.conf"
|
||||
ynh_add_config --template="../conf/couchpotato.conf" --destination="$final_path/settings.conf"
|
||||
|
||||
# Configure App
|
||||
ynh_replace_string --match_string="__RPCURL__" --replace_string="$transmission_rpcurl" --target_file="../conf/couchpotato.conf"
|
||||
ynh_replace_string --match_string="__RPCPASSWORD__" --replace_string="$transmission_rpcpassword" --target_file="../conf/couchpotato.conf"
|
||||
ynh_replace_string --match_string="__WATCHDIR__" --replace_string="$transmission_watchdir" --target_file="../conf/couchpotato.conf"
|
||||
chmod 600 "$final_path/settings.conf"
|
||||
chown $app:$app "$final_path/settings.conf"
|
||||
|
||||
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="../conf/couchpotato.conf"
|
||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/couchpotato.conf"
|
||||
ynh_replace_string --match_string="__DATADIR__" --replace_string="$app_data_dir" --target_file="../conf/couchpotato.conf"
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..."
|
||||
|
||||
cp -a ../conf/couchpotato.conf $app_config_file
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum --file="$app_config_file"
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE LOGS
|
||||
|
@ -218,29 +225,12 @@ ynh_script_progression --message="Configuring logs..."
|
|||
# Redirect logs directory
|
||||
app_logs_dir="/var/log/$app"
|
||||
mkdir -p $app_logs_dir
|
||||
chown -R $app $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"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..."
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config --others_var="app_data_dir python_version"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Securing files and directories..."
|
||||
|
||||
# Set permissions to app files
|
||||
chown -R $app:$app $final_path
|
||||
chown -R $app:$app $app_data_dir
|
||||
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
|
@ -254,7 +244,7 @@ ynh_use_logrotate
|
|||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --description "CouchPotato Daemon" --log "/var/log/$app/$app.log"
|
||||
yunohost service add $app --description="CouchPotato Daemon" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
|
@ -267,15 +257,19 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
|
|||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring SSOwat..."
|
||||
ynh_script_progression --message="Configuring permissions..."
|
||||
|
||||
# Open the /api path so that external applications can connect
|
||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/api"
|
||||
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"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..."
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
|
|
@ -63,9 +63,9 @@ ynh_secure_remove --file="$final_path"
|
|||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing nginx web server configuration..."
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..."
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
|
@ -93,9 +93,6 @@ fi
|
|||
#=================================================
|
||||
ynh_script_progression --message="Removing various files..."
|
||||
|
||||
# Remove a directory securely
|
||||
ynh_secure_remove --file="$app_data_dir"
|
||||
|
||||
# Remove the log files
|
||||
ynh_secure_remove --file="/var/log/$app"
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/_common.sh
|
||||
source ../settings/scripts/ynh_install_python
|
||||
source ../settings/scripts/ynh_multimedia_3
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -25,7 +24,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading settings..."
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -43,25 +42,16 @@ ynh_webpath_available --domain=$domain --path_url=$path_url \
|
|||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||
test ! -d $final_path \
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
test ! -d $app_data_dir \
|
||||
|| ynh_die --message="There is already a directory: $app_data_dir "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the nginx configuration..."
|
||||
ynh_script_progression --message="Restoring the NGINX configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
|
@ -71,12 +61,15 @@ ynh_script_progression --message="Recreating the dedicated system user..."
|
|||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring user rights..."
|
||||
ynh_script_progression --message="Restoring the app main directory..."
|
||||
|
||||
# Restore permissions on app files
|
||||
chown -R $app:$app $final_path
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
|
@ -93,13 +86,10 @@ ynh_install_app_dependencies $pkg_dependencies
|
|||
#=================================================
|
||||
ynh_script_progression --message="Building CouchPotato..."
|
||||
|
||||
# Set permissions to app files
|
||||
chown -R "$app": "$final_path"
|
||||
|
||||
ynh_install_python --python_version=$python_version
|
||||
ynh_use_python
|
||||
|
||||
pushd $final_path
|
||||
pyenv virtualenv $python_version $app
|
||||
/opt/pyenv/versions/$app/bin/pip install --upgrade pyopenssl
|
||||
/opt/pyenv/versions/$app/bin/pip install cheetah
|
||||
popd
|
||||
|
@ -109,26 +99,26 @@ popd
|
|||
#=================================================
|
||||
ynh_script_progression --message="Restoring the data directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$app_data_dir"
|
||||
ynh_restore_file --origin_path="$app_data_dir" --not_mandatory
|
||||
|
||||
chown -R $app:$app $app_data_dir
|
||||
mkdir -p "$app_data_dir"
|
||||
chmod 750 "$app_data_dir"
|
||||
chmod -R o-rwx "$app_data_dir"
|
||||
chown -R $app:$app "$app_data_dir"
|
||||
|
||||
#=================================================
|
||||
# INSTALL YUNOHOST MULTIMEDIA
|
||||
#=================================================
|
||||
ynh_script_progression --message="Install YunoHost multimedia..."
|
||||
|
||||
# Creates the "Movies" subfolder in "Video"
|
||||
mkdir -p "$MEDIA_DIRECTORY/share/Video/Movies"
|
||||
|
||||
ynh_multimedia_build_main_dir
|
||||
|
||||
# Give write access to the yunohost.multimedia directory so that Couchpotato can move Movies to the Movie directory
|
||||
ynh_multimedia_addaccess $app
|
||||
|
||||
# Creates the "Movies" subfolder in "Video"
|
||||
mkdir -p "/home/yunohost.multimedia/share/Video/Movies"
|
||||
|
||||
# Fix permissions
|
||||
/home/yunohost.multimedia/ynh_media_build.sh
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE LOGS
|
||||
#=================================================
|
||||
|
@ -137,7 +127,7 @@ ynh_script_progression --message="Configuring logs..."
|
|||
# Redirect logs directory
|
||||
app_logs_dir="/var/log/$app"
|
||||
mkdir -p $app_logs_dir
|
||||
chown -R $app $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"
|
||||
|
||||
|
@ -147,14 +137,14 @@ ynh_replace_string --match_string="self.log_dir =.*" --replace_string="self.log_
|
|||
ynh_script_progression --message="Restoring the systemd configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service
|
||||
systemctl enable $app.service --quiet
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --description "A short description of the app" --log "/var/log/$app/$app.log"
|
||||
yunohost service add $app --description="CouchPotato Daemon" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
|
@ -175,7 +165,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..."
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
|
253
scripts/upgrade
253
scripts/upgrade
|
@ -8,7 +8,6 @@
|
|||
|
||||
source _common.sh
|
||||
source ynh_install_python
|
||||
source ynh_multimedia_3
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -24,10 +23,6 @@ port=$(ynh_app_setting_get --app=$app --key=port)
|
|||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
app_data_dir=$(ynh_app_setting_get --app=$app --key=app_data_dir)
|
||||
|
||||
# Destinations definitions
|
||||
app_logs_dir="/var/log/$app"
|
||||
app_python_bin="/usr/bin/python"
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
@ -35,26 +30,34 @@ ynh_script_progression --message="Checking version..."
|
|||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# Restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||
|
||||
# Fix is_public as a boolean value
|
||||
if [ "$is_public" = "Yes" ]; then
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=1
|
||||
is_public=1
|
||||
elif [ "$is_public" = "No" ]; then
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=0
|
||||
is_public=0
|
||||
fi
|
||||
# Cancel upgrade if the version is too old
|
||||
if [[ -n $(ynh_app_setting_get $app method) ]]; then
|
||||
ynh_die "Your current version is too old and cannot be upgraded.\
|
||||
If you had a local install, please remove the app and reinstall it.\
|
||||
If you had a remote install, please remove the app and install redirect_ynh for this purpose instead."
|
||||
fi
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
if [ -z "$final_path" ]; then
|
||||
final_path=/opt/yunohost/$app
|
||||
|
@ -67,69 +70,17 @@ if [ -z "$app_data_dir" ]; then
|
|||
ynh_app_setting_set --app=$app --key=app_data_dir --value=$app_data_dir
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CHECK THE PATH
|
||||
#=================================================
|
||||
|
||||
# Normalize the URL path syntax
|
||||
# N.B. : this is for app installations before YunoHost 2.7
|
||||
# where this value might be something like /foo/ or foo/
|
||||
# instead of /foo ....
|
||||
# If nobody installed your app before 2.7, then you may
|
||||
# safely remove this line
|
||||
path_url=$(ynh_normalize_url_path --path_url=$path_url)
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..."
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
pushd $final_path
|
||||
git pull
|
||||
popd
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading nginx web server configuration..."
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..."
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
# 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"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
|
@ -139,6 +90,39 @@ ynh_script_progression --message="Making sure dedicated system user exists..."
|
|||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..."
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
pushd "$final_path"
|
||||
git pull
|
||||
popd
|
||||
fi
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..."
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
|
@ -146,10 +130,8 @@ ynh_system_user_create --username=$app --home_dir=$final_path
|
|||
#=================================================
|
||||
ynh_script_progression --message="Building CouchPotato..."
|
||||
|
||||
# Set permissions to app files
|
||||
chown -R "$app": "$final_path"
|
||||
|
||||
ynh_install_python --python_version=$python_version
|
||||
ynh_use_python
|
||||
|
||||
pushd $final_path
|
||||
/opt/pyenv/versions/$python_version/bin/pip install --upgrade pyopenssl
|
||||
|
@ -161,84 +143,77 @@ popd
|
|||
#=================================================
|
||||
ynh_script_progression --message="Install YunoHost multimedia..."
|
||||
|
||||
# Creates the "Movies" subfolder in "Video"
|
||||
mkdir -p "$MEDIA_DIRECTORY/share/Video/Movies"
|
||||
|
||||
ynh_multimedia_build_main_dir
|
||||
|
||||
# Give write access to the yunohost.multimedia directory so that Couchpotato can move Movies to the Movie directory
|
||||
ynh_multimedia_addaccess $app
|
||||
|
||||
# Creates the "Movies" subfolder in "Video"
|
||||
mkdir -p "/home/yunohost.multimedia/share/Video/Movies"
|
||||
|
||||
# Fix permissions
|
||||
/home/yunohost.multimedia/ynh_media_build.sh
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE TRANSMISSION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring transmission..."
|
||||
|
||||
# Variable initialization
|
||||
rpc=""
|
||||
blackhole=""
|
||||
renamer=""
|
||||
|
||||
# Transmission link: Preferred method is direct RPC link. If not available, switch to watchdir.
|
||||
transmission_rpcurl=""
|
||||
transmission_rpcpassword=""
|
||||
transmission_watchdir=""
|
||||
|
||||
# Check if Transmission is installed
|
||||
if [[ -z $(yunohost app list -i -f transmission | grep -v 'apps:') ]]; then
|
||||
if [[ -z $(yunohost app list | grep -q 'id: $transmission') ]]; then
|
||||
|
||||
ynh_script_progression --message="Transmission is not installed. Disabling link to CouchPotato..."
|
||||
ynh_replace_string --match_string="__RPC__" --replace_string="0" --target_file="../conf/couchpotato.conf" # Disable Transmission RPC
|
||||
ynh_replace_string --match_string="__BLACKHOLE__" --replace_string="0" --target_file="../conf/couchpotato.conf" # Disable Transmission Watchdir
|
||||
ynh_replace_string --match_string="__RENAMER__" --replace_string="0" --target_file="../conf/couchpotato.conf" # Disable Renamer
|
||||
rpc="0"
|
||||
blackhole="0"
|
||||
renamer="0"
|
||||
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
|
||||
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)
|
||||
ynh_replace_string --match_string="__RPC__" --replace_string="1" --target_file="../conf/couchpotato.conf" # Enable Transmission RPC
|
||||
ynh_replace_string --match_string="__BLACKHOLE__" --replace_string="0" --target_file="../conf/couchpotato.conf" # Disable Transmission Watchdir
|
||||
ynh_replace_string --match_string="__RENAMER__" --replace_string="1" --target_file="../conf/couchpotato.conf" # Enable Renamer
|
||||
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
|
||||
ynh_script_progression --message="Transmission will be linked to CouchPotato with watchdir"
|
||||
|
||||
transmission_watchdir=$(ynh_app_setting_get --app=transmission --key=watchdir)
|
||||
ynh_replace_string --match_string="__RPC__" --replace_string="0" --target_file="../conf/couchpotato.conf" # Disable Transmission RPC
|
||||
ynh_replace_string --match_string="__BLACKHOLE__" --replace_string="1" --target_file="../conf/couchpotato.conf" # Enable Transmission Watchdir
|
||||
ynh_replace_string --match_string="__RENAMER__" --replace_string="1" --target_file="../conf/couchpotato.conf" # Enable Renamer
|
||||
rpc="0" # Disable Transmission RPC
|
||||
blackhole="1" # Enable Transmission Watchdir
|
||||
renamer="1" # Enable Renamer
|
||||
# If transmission uses YunoHost multimedia, use its folder for the renamer
|
||||
else
|
||||
ynh_script_progression --message="Cannot link Couchpotato to Transmission because Transmission has no RPC password or watchdir available."
|
||||
ynh_replace_string --match_string="__RPC__" --replace_string="0" --target_file="../conf/couchpotato.conf" # Disable Transmission RPC
|
||||
ynh_replace_string --match_string="__BLACKHOLE__" --replace_string="0" --target_file="../conf/couchpotato.conf" # Disable Transmission Watchdir
|
||||
ynh_replace_string --match_string="__RENAMER__" --replace_string="0" --target_file="../conf/couchpotato.conf" # Disable Renamer
|
||||
|
||||
rpc="0" # Disable Transmission RPC
|
||||
blackhole="0" # Disable Transmission Watchdir
|
||||
renamer="0" # Disable Renamer
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Modifying a config file..."
|
||||
ynh_script_progression --message="Updating a configuration file..."
|
||||
|
||||
app_config_file="${final_path}/settings.conf"
|
||||
ynh_add_config --template="../conf/couchpotato.conf" --destination="$final_path/settings.conf"
|
||||
|
||||
# Configure App
|
||||
ynh_replace_string --match_string="__RPCURL__" --replace_string="$transmission_rpcurl" --target_file="../conf/couchpotato.conf"
|
||||
ynh_replace_string --match_string="__RPCPASSWORD__" --replace_string="$transmission_rpcpassword" --target_file="../conf/couchpotato.conf"
|
||||
ynh_replace_string --match_string="__WATCHDIR__" --replace_string="$transmission_watchdir" --target_file="../conf/couchpotato.conf"
|
||||
|
||||
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="../conf/couchpotato.conf"
|
||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/couchpotato.conf"
|
||||
ynh_replace_string --match_string="__DATADIR__" --replace_string="$app_data_dir" --target_file="../conf/couchpotato.conf"
|
||||
|
||||
ynh_backup_if_checksum_is_different --file=$app_config_file
|
||||
|
||||
cp -a ../conf/couchpotato.conf $app_config_file
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum --file="$app_config_file"
|
||||
chmod 600 "$final_path/settings.conf"
|
||||
chown $app:$app "$final_path/settings.conf"
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE LOGS
|
||||
|
@ -249,6 +224,16 @@ ynh_script_progression --message="Configuring logs..."
|
|||
app_logs_dir="/var/log/$app"
|
||||
ynh_replace_string --match_string="self.log_dir =.*" --replace_string="self.log_dir = '$app_logs_dir'" --target_file="$final_path/CouchPotato.py"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading systemd configuration..."
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
|
@ -258,31 +243,11 @@ ynh_script_progression --message="Upgrading logrotate configuration..."
|
|||
ynh_use_logrotate --non-append
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading systemd configuration..."
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config --others_var="app_data_dir python_version"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Securing files and directories..."
|
||||
|
||||
# Set permissions on app files
|
||||
chown -R $app:$app $final_path
|
||||
chown -R $app:$app $app_data_dir
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading SSOwat configuration..."
|
||||
|
||||
# Open the /api path so that external applications can connect
|
||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/api"
|
||||
yunohost service add $app --description="CouchPotato Daemon" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
|
@ -294,7 +259,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..."
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
|
|
@ -1,52 +1,91 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Need also the helper https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_handle_getopts_args/ynh_handle_getopts_args
|
||||
pyenv_version=1.2.19
|
||||
pyenv_virtualenv_version=1.1.5
|
||||
pyenv_install_dir="/opt/pyenv"
|
||||
ynh_python_try_bash_extension() {
|
||||
if [ -x src/configure ]; then
|
||||
src/configure && make -C src || {
|
||||
ynh_print_info --message="Optional bash extension failed to build, but things will still work normally."
|
||||
}
|
||||
fi
|
||||
}
|
||||
|
||||
pyenv_install_dir="/opt/pyenv"
|
||||
python_version_path="$pyenv_install_dir/versions"
|
||||
# PYENV_ROOT is the directory of pyenv, it needs to be loaded as a environment variable.
|
||||
export PYENV_ROOT="$pyenv_install_dir"
|
||||
|
||||
# Required dependencies
|
||||
pyenv_dependencies="build-essential libssl1.0-dev|libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl git"
|
||||
pyenv_dependencies="build-essential libssl1.0-dev|libssl-dev zlib1g-dev libbz2-dev libreadline-dev|libedit-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl git"
|
||||
|
||||
# Install python version management
|
||||
# Load the version of Python for an app, and set variables.
|
||||
#
|
||||
# [internal]
|
||||
# ynh_use_python has to be used in any app scripts before using Python for the first time.
|
||||
# This helper will provide alias and variables to use in your scripts.
|
||||
#
|
||||
# usage: ynh_install_pyenv
|
||||
ynh_install_pyenv () {
|
||||
echo "Installation of pyenv - python version management" >&2
|
||||
# Build an app.src for pyenv
|
||||
mkdir -p "../conf"
|
||||
echo "SOURCE_URL=https://github.com/pyenv/pyenv/archive/v${pyenv_version}.tar.gz
|
||||
SOURCE_SUM=e93466735ac9c34d68b7d5d71f32c16a2b4b1a6a1adffb85acc4126a3398b9d0" > "../conf/pyenv.src"
|
||||
# Download and extract pyenv
|
||||
ynh_setup_source "$pyenv_install_dir" pyenv
|
||||
# To use pip or Python, use the alias `ynh_pip` and `ynh_python`
|
||||
# Those alias will use the correct version installed for the app
|
||||
# For example: use `ynh_pip install` instead of `pip install`
|
||||
#
|
||||
# With `sudo` or `ynh_exec_as`, use instead the fallback variables `$ynh_pip` and `$ynh_python`
|
||||
# And propagate $PATH to sudo with $ynh_python_load_path
|
||||
# Exemple: `ynh_exec_as $app $ynh_python_load_path $ynh_pip install`
|
||||
#
|
||||
# $PATH contains the path of the requested version of Python.
|
||||
# However, $PATH is duplicated into $python_path to outlast any manipulation of $PATH
|
||||
# You can use the variable `$ynh_python_load_path` to quickly load your Python version
|
||||
# in $PATH for an usage into a separate script.
|
||||
# Exemple: $ynh_python_load_path $final_path/script_that_use_pip.sh`
|
||||
#
|
||||
#
|
||||
# Finally, to start a Python service with the correct version, 2 solutions
|
||||
# Either the app is dependent of python or pip, but does not called it directly.
|
||||
# In such situation, you need to load PATH
|
||||
# `Environment="__YNH_PYTHON_LOAD_ENV_PATH__"`
|
||||
# `ExecStart=__FINALPATH__/my_app`
|
||||
# You will replace __YNH_PYTHON_LOAD_ENV_PATH__ with $ynh_python_load_path
|
||||
#
|
||||
# Or Python start the app directly, then you don't need to load the PATH variable
|
||||
# `ExecStart=__YNH_PYTHON__ my_app run`
|
||||
# You will replace __YNH_PYTHON__ with $ynh_python
|
||||
#
|
||||
#
|
||||
# one other variable is also available
|
||||
# - $python_path: The absolute path to Python binaries for the chosen version.
|
||||
#
|
||||
# usage: ynh_use_python
|
||||
#
|
||||
# Requires YunoHost version 2.7.12 or higher.
|
||||
ynh_use_python () {
|
||||
python_version=$(ynh_app_setting_get --app=$app --key=python_version)
|
||||
|
||||
# Build an app.src for pyenv-virtualenv
|
||||
mkdir -p "../conf"
|
||||
echo "SOURCE_URL=https://github.com/pyenv/pyenv-virtualenv/archive/v${pyenv_virtualenv_version}.tar.gz
|
||||
SOURCE_SUM=27ae3de027a6f6dccdca4085225512e559c6b94b31625bd2b357a18890a1e618" > "../conf/pyenv-virtualenv.src"
|
||||
# Download and extract pyenv-virtualenv
|
||||
ynh_setup_source "$pyenv_install_dir/plugins/pyenv-virtualenv" pyenv-virtualenv
|
||||
# Get the absolute path of this version of Python
|
||||
python_path="$python_version_path/$YNH_APP_INSTANCE_NAME/bin"
|
||||
|
||||
(cd $pyenv_install_dir
|
||||
./src/configure && make -C src)
|
||||
# Allow alias to be used into bash script
|
||||
shopt -s expand_aliases
|
||||
|
||||
# Create shims directory if needed
|
||||
if [ ! -d $pyenv_install_dir/shims ] ; then
|
||||
mkdir $pyenv_install_dir/shims
|
||||
# Create an alias for the specific version of Python and a variable as fallback
|
||||
ynh_python="$python_path/python"
|
||||
alias ynh_python="$ynh_python"
|
||||
# And pip
|
||||
ynh_pip="$python_path/pip"
|
||||
alias ynh_pip="$ynh_pip"
|
||||
|
||||
# Load the path of this version of Python in $PATH
|
||||
if [[ :$PATH: != *":$python_path"* ]]; then
|
||||
PATH="$python_path:$PATH"
|
||||
fi
|
||||
# Create an alias to easily load the PATH
|
||||
ynh_python_load_path="PATH=$PATH"
|
||||
|
||||
# Sets the local application-specific Python version
|
||||
pushd $final_path
|
||||
$pyenv_install_dir/bin/pyenv local $python_version
|
||||
popd
|
||||
}
|
||||
|
||||
# Install a specific version of python
|
||||
# Install a specific version of Python
|
||||
#
|
||||
# ynh_install_python will install the version of python provided as argument by using pyenv.
|
||||
#
|
||||
# pyenv (python version management) stores the target python version in a .python_version file created in the target folder (using pyenv local <version>)
|
||||
# It then uses that information for every python user that uses pyenv provided python command
|
||||
# ynh_install_python will install the version of Python provided as argument by using pyenv.
|
||||
#
|
||||
# This helper creates a /etc/profile.d/pyenv.sh that configures PATH environment for pyenv
|
||||
# for every LOGIN user, hence your user must have a defined shell (as opposed to /usr/sbin/nologin)
|
||||
|
@ -56,99 +95,188 @@ fi
|
|||
# When not possible (e.g. in systemd service definition), please use direct path
|
||||
# to pyenv shims (e.g. $PYENV_ROOT/shims/bundle)
|
||||
#
|
||||
# usage: ynh_install_python python_version user
|
||||
# | arg: -v, --python_version= - Version of python to install.
|
||||
# If possible, prefer to use major version number (e.g. 3 instead of 3.7.3).
|
||||
# The crontab will handle the update of minor versions when needed.
|
||||
# usage: ynh_install_python --python_version=python_version
|
||||
# | arg: -v, --python_version= - Version of Python to install.
|
||||
#
|
||||
# Requires YunoHost version 2.7.12 or higher.
|
||||
ynh_install_python () {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [v]=python_version= )
|
||||
# Use pyenv, https://github.com/pyenv/pyenv to manage the python versions
|
||||
local legacy_args=v
|
||||
local -A args_array=( [v]=python_version= )
|
||||
local python_version
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
# Create $pyenv_install_dir
|
||||
mkdir -p "$pyenv_install_dir/plugins/pyenv-virtualenv"
|
||||
|
||||
# Load pyenv path in PATH
|
||||
CLEAR_PATH="$pyenv_install_dir/bin:$PATH"
|
||||
|
||||
# Remove /usr/local/bin in PATH in case of python prior installation
|
||||
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
||||
|
||||
# Move an existing python binary, to avoid to block pyenv
|
||||
#test -x /usr/bin/python && mv /usr/bin/python /usr/bin/python_pyenv
|
||||
|
||||
# If pyenv is not previously setup, install it
|
||||
if ! type pyenv > /dev/null 2>&1
|
||||
then
|
||||
ynh_install_pyenv
|
||||
elif dpkg --compare-versions "$($pyenv_install_dir/bin/pyenv --version | cut -d" " -f2)" lt $pyenv_version
|
||||
then
|
||||
ynh_install_pyenv
|
||||
elif dpkg --compare-versions "$($pyenv_install_dir/plugins/pyenv-virtualenv/bin/pyenv-virtualenv --version | cut -d" " -f2)" lt $pyenv_virtualenv_version
|
||||
then
|
||||
ynh_install_pyenv
|
||||
fi
|
||||
|
||||
# Restore /usr/local/bin in PATH (if needed)
|
||||
PATH=$CLEAR_PATH
|
||||
|
||||
# And replace the old python binary
|
||||
# test -x /usr/bin/python_pyenv && mv /usr/bin/python_pyenv /usr/bin/python
|
||||
|
||||
# Install required dependencies
|
||||
ynh_add_app_dependencies --package="$pyenv_dependencies"
|
||||
|
||||
# Install the requested version of python
|
||||
pyenv install --skip-existing $python_version
|
||||
# Load pyenv path in PATH
|
||||
local CLEAR_PATH="$pyenv_install_dir/bin:$PATH"
|
||||
|
||||
# Store the ID of this app and the version of python requested for it
|
||||
echo "$YNH_APP_ID:$python_version" | tee --append "$pyenv_install_dir/ynh_app_version"
|
||||
# Remove /usr/local/bin in PATH in case of Python prior installation
|
||||
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
||||
|
||||
# Move an existing Python binary, to avoid to block pyenv
|
||||
#test -x /usr/bin/python && mv /usr/bin/python /usr/bin/python_pyenv
|
||||
|
||||
# Install or update pyenv
|
||||
pyenv="$(command -v pyenv $pyenv_install_dir/bin/pyenv | head -1)"
|
||||
if [ -n "$pyenv" ]; then
|
||||
ynh_print_info --message="pyenv already seems installed in \`$pyenv'."
|
||||
pushd "${pyenv%/*/*}"
|
||||
if git remote -v 2>/dev/null | grep "https://github.com/pyenv/pyenv.git"; then
|
||||
echo "Trying to update with git..."
|
||||
git pull -q --tags origin master
|
||||
cd ..
|
||||
ynh_python_try_bash_extension
|
||||
fi
|
||||
popd
|
||||
else
|
||||
ynh_print_info --message="Installing pyenv with git..."
|
||||
mkdir -p $pyenv_install_dir
|
||||
pushd $pyenv_install_dir
|
||||
git init -q
|
||||
git remote add -f -t master origin https://github.com/pyenv/pyenv.git > /dev/null 2>&1
|
||||
git checkout -q -b master origin/master
|
||||
ynh_python_try_bash_extension
|
||||
pyenv=$pyenv_install_dir/bin/pyenv
|
||||
popd
|
||||
fi
|
||||
|
||||
pyenv_virtualenv="$(command -v "$pyenv_install_dir"/plugins/*/bin/pyenv-virtualenv pyenv-virtualenv | head -1)"
|
||||
if [ -n "$pyenv_virtualenv" ]; then
|
||||
ynh_print_info --message="\`pyenv virtualenv' command already available in \`$pyenv_virtualenv'."
|
||||
pushd "${pyenv_virtualenv%/*/*}"
|
||||
if git remote -v 2>/dev/null | grep "https://github.com/pyenv/pyenv-virtualenv.git"; then
|
||||
ynh_print_info --message="Trying to update pyenv-virtualenv with git..."
|
||||
git pull -q origin master
|
||||
fi
|
||||
popd
|
||||
else
|
||||
ynh_print_info --message="Installing pyenv-virtualenv with git..."
|
||||
mkdir -p "${pyenv_install_dir}/plugins"
|
||||
git clone -q https://github.com/pyenv/pyenv-virtualenv.git "${pyenv_install_dir}/plugins/pyenv-virtualenv"
|
||||
fi
|
||||
|
||||
pyenv_latest="$(command -v "$pyenv_install_dir"/plugins/*/bin/pyenv-latest pyenv-latest | head -1)"
|
||||
if [ -n "$pyenv_latest" ]; then
|
||||
ynh_print_info --message="\`pyenv latest' command already available in \`$pyenv_latest'."
|
||||
pushd "${pyenv_latest%/*/*}"
|
||||
if git remote -v 2>/dev/null | grep "https://github.com/momo-lab/xxenv-latest.git"; then
|
||||
ynh_print_info --message="Trying to update xxenv-latest with git..."
|
||||
git pull -q origin master
|
||||
fi
|
||||
popd
|
||||
else
|
||||
ynh_print_info --message="Installing xxenv-latest with git..."
|
||||
mkdir -p "${pyenv_install_dir}/plugins"
|
||||
git clone -q https://github.com/momo-lab/xxenv-latest.git "${pyenv_install_dir}/plugins/xxenv-latest"
|
||||
fi
|
||||
|
||||
# Enable caching
|
||||
mkdir -p "${pyenv_install_dir}/cache"
|
||||
|
||||
# Create shims directory if needed
|
||||
mkdir -p "${pyenv_install_dir}/shims"
|
||||
|
||||
# Restore /usr/local/bin in PATH
|
||||
PATH=$CLEAR_PATH
|
||||
|
||||
# And replace the old Python binary
|
||||
# test -x /usr/bin/python_pyenv && mv /usr/bin/python_pyenv /usr/bin/python
|
||||
|
||||
# Install the requested version of Python
|
||||
local final_python_version=$(pyenv latest --print $python_version)
|
||||
ynh_print_info --message="Installation of Python-$python_version"
|
||||
pyenv install --skip-existing $final_python_version > /dev/null 2>&1
|
||||
|
||||
# Store python_version into the config of this app
|
||||
ynh_app_setting_set --app=$app --key=python_version --value=$python_version
|
||||
ynh_app_setting_set --app=$YNH_APP_INSTANCE_NAME --key=python_version --value=$python_version
|
||||
|
||||
# Set environment for python users
|
||||
# Remove app virtualenv
|
||||
if `pyenv virtualenvs | grep --quiet "$YNH_APP_INSTANCE_NAME " 1>/dev/null 2>&1`
|
||||
then
|
||||
pyenv virtualenv-delete --force $YNH_APP_INSTANCE_NAME
|
||||
fi
|
||||
|
||||
# Create app virtualenv
|
||||
pyenv virtualenv --force $python_version $YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Cleanup Python versions
|
||||
ynh_cleanup_python
|
||||
|
||||
# Set environment for Python users
|
||||
echo "#pyenv
|
||||
export PYENV_ROOT=$pyenv_install_dir
|
||||
export PATH=\"$pyenv_install_dir/bin:$PATH\"
|
||||
eval \"\$(pyenv init -)\"
|
||||
#pyenv" > /etc/profile.d/pyenv.sh
|
||||
|
||||
# Load the right environment for the Installation
|
||||
# Load the environment
|
||||
eval "$(pyenv init -)"
|
||||
|
||||
(cd $final_path
|
||||
pyenv local $python_version)
|
||||
}
|
||||
|
||||
# Remove the version of python used by the app.
|
||||
# Remove the version of Python used by the app.
|
||||
#
|
||||
# This helper will check if another app uses the same version of python,
|
||||
# if not, this version of python will be removed.
|
||||
# If no other app uses python, pyenv will be also removed.
|
||||
# This helper will also cleanup Python versions
|
||||
#
|
||||
# usage: ynh_remove_python
|
||||
ynh_remove_python () {
|
||||
python_version=$(ynh_app_setting_get --app=$app --key=python_version)
|
||||
local python_version=$(ynh_app_setting_get --app=$YNH_APP_INSTANCE_NAME --key=python_version)
|
||||
|
||||
# Load pyenv path in PATH
|
||||
local CLEAR_PATH="$pyenv_install_dir/bin:$PATH"
|
||||
|
||||
# Remove /usr/local/bin in PATH in case of Python prior installation
|
||||
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
||||
|
||||
pyenv virtualenv-delete --force $YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Remove the line for this app
|
||||
sed --in-place "/$YNH_APP_ID:$python_version/d" "$pyenv_install_dir/ynh_app_version"
|
||||
ynh_app_setting_delete --app=$YNH_APP_INSTANCE_NAME --key=python_version
|
||||
|
||||
# If no other app uses this version of python, remove it.
|
||||
if ! grep --quiet "$python_version" "$pyenv_install_dir/ynh_app_version"
|
||||
# Cleanup Python versions
|
||||
ynh_cleanup_python
|
||||
}
|
||||
|
||||
# Remove no more needed versions of Python used by the app.
|
||||
#
|
||||
# This helper will check what Python version are no more required,
|
||||
# and uninstall them
|
||||
# If no app uses Python, pyenv will be also removed.
|
||||
#
|
||||
# usage: ynh_cleanup_python
|
||||
ynh_cleanup_python () {
|
||||
|
||||
# List required Python version
|
||||
local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$')
|
||||
local required_python_versions=""
|
||||
for installed_app in $installed_apps
|
||||
do
|
||||
local installed_app_python_version=$(ynh_app_setting_get --app=$installed_app --key="python_version")
|
||||
if [[ $installed_app_python_version ]]
|
||||
then
|
||||
$pyenv_install_dir/bin/pyenv uninstall --force $python_version
|
||||
required_python_versions="${installed_app_python_version}\n${required_python_versions}"
|
||||
fi
|
||||
done
|
||||
|
||||
# Remove pyenv environment configuration
|
||||
rm /etc/profile.d/pyenv.sh
|
||||
|
||||
# If no other app uses pyenv, remove pyenv and dedicated group
|
||||
if [ ! -s "$pyenv_install_dir/ynh_app_version" ]
|
||||
# Remove no more needed Python version
|
||||
local installed_python_versions=$(pyenv versions --bare --skip-aliases | grep -Ev '/')
|
||||
for installed_python_version in $installed_python_versions
|
||||
do
|
||||
if ! `echo ${required_python_versions} | grep "${installed_python_version}" 1>/dev/null 2>&1`
|
||||
then
|
||||
ynh_print_info --message="Removing of Python-$installed_python_version"
|
||||
$pyenv_install_dir/bin/pyenv uninstall --force $installed_python_version
|
||||
fi
|
||||
done
|
||||
|
||||
# If none Python version is required
|
||||
if [[ ! $required_python_versions ]]
|
||||
then
|
||||
# Remove pyenv environment configuration
|
||||
ynh_print_info --message="Removing of pyenv-$pyenv_version"
|
||||
ynh_secure_remove --file="$pyenv_install_dir"
|
||||
ynh_secure_remove --file="/etc/profile.d/pyenv.sh"
|
||||
fi
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Install or update the main directory yunohost.multimedia
|
||||
#
|
||||
# usage: ynh_multimedia_build_main_dir
|
||||
ynh_multimedia_build_main_dir () {
|
||||
local ynh_media_release="v1.2"
|
||||
local checksum="806a827ba1902d6911095602a9221181"
|
||||
|
||||
# Download yunohost.multimedia scripts
|
||||
wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz
|
||||
|
||||
# Check the control sum
|
||||
echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \
|
||||
|| ynh_die "Corrupt source"
|
||||
|
||||
# Check if the package acl is installed. Or install it.
|
||||
ynh_package_is_installed 'acl' \
|
||||
|| ynh_package_install acl
|
||||
|
||||
# Extract
|
||||
mkdir yunohost.multimedia-master
|
||||
tar -xf ${ynh_media_release}.tar.gz -C yunohost.multimedia-master --strip-components 1
|
||||
./yunohost.multimedia-master/script/ynh_media_build.sh
|
||||
}
|
||||
|
||||
# Add a directory in yunohost.multimedia
|
||||
# This "directory" will be a symbolic link to a existing directory.
|
||||
#
|
||||
# usage: ynh_multimedia_addfolder "Source directory" "Destination directory"
|
||||
#
|
||||
# | arg: -s, --source_dir= - Source directory - The real directory which contains your medias.
|
||||
# | arg: -d, --dest_dir= - Destination directory - The name and the place of the symbolic link, relative to "/home/yunohost.multimedia"
|
||||
ynh_multimedia_addfolder () {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [s]=source_dir= [d]=dest_dir= )
|
||||
local source_dir
|
||||
local dest_dir
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source="$source_dir" --dest="$dest_dir"
|
||||
}
|
||||
|
||||
# Move a directory in yunohost.multimedia, and replace by a symbolic link
|
||||
#
|
||||
# usage: ynh_multimedia_movefolder "Source directory" "Destination directory"
|
||||
#
|
||||
# | arg: -s, --source_dir= - Source directory - The real directory which contains your medias.
|
||||
# It will be moved to "Destination directory"
|
||||
# A symbolic link will replace it.
|
||||
# | arg: -d, --dest_dir= - Destination directory - The new name and place of the directory, relative to "/home/yunohost.multimedia"
|
||||
ynh_multimedia_movefolder () {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [s]=source_dir= [d]=dest_dir= )
|
||||
local source_dir
|
||||
local dest_dir
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
./yunohost.multimedia-master/script/ynh_media_addfolder.sh --inv --source="$source_dir" --dest="$dest_dir"
|
||||
}
|
||||
|
||||
# Allow an user to have an write authorisation in multimedia directories
|
||||
#
|
||||
# usage: ynh_multimedia_addaccess user_name
|
||||
#
|
||||
# | arg: -u, --user_name= - The name of the user which gain this access.
|
||||
ynh_multimedia_addaccess () {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [u]=user_name=)
|
||||
local user_name
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
groupadd -f multimedia
|
||||
usermod -a -G multimedia $user_name
|
||||
}
|
Loading…
Add table
Reference in a new issue