mirror of
https://github.com/YunoHost-Apps/couchpotato_ynh.git
synced 2024-09-03 18:16:22 +02:00
apply example_ynh
This commit is contained in:
parent
2a7461345d
commit
ba9b7ebc61
15 changed files with 1035 additions and 437 deletions
46
README.md
46
README.md
|
@ -1,30 +1,32 @@
|
||||||
## <img src="https://github.com/binhex/docker-templates/raw/master/binhex/images/couchpotato-icon.png" height="32" align="top"> couchpotato_ynh <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>
|
## <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>
|
||||||
|
|
||||||
[](https://dash.yunohost.org/appci/app/couchpotato)  
|
[](https://dash.yunohost.org/appci/app/couchpotato)  
|
||||||
|
[](https://install-app.yunohost.org/?app=couchpotato)
|
||||||
|
|
||||||
[](https://github.com/Snipees/couchpotato_ynh/releases)
|
> *This package allows you to install CouchPotato quickly and simply on a YunoHost server.
|
||||||
[](https://github.com/Snipees/couchpotato_ynh/milestones)
|
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
|
||||||
[](https://github.com/Snipees/couchpotato_ynh#dependencies)
|
|
||||||
[](https://raw.githubusercontent.com/Snipees/couchpotato_ynh/master/LICENSE)
|
|
||||||
[](https://github.com/YunoHost/yunohost)
|
|
||||||
[](https://github.com/YunoHost-Apps/couchpotato_ynh/issues)
|
|
||||||
|
|
||||||
[ **CouchPotato Integration for Yunohost** ]
|
## Overview
|
||||||
Download movies automatically, easily and in the best quality as soon as they are available.
|
Download movies automatically, easily and in the best quality as soon as they are available.
|
||||||
|
|
||||||
- Integrates automatically with [transmission_ynh](https://github.com/YunoHost-Apps/transmission_ynh) (or tries to...),
|
- Integrates automatically with [transmission_ynh](https://github.com/YunoHost-Apps/transmission_ynh) (or tries to...),
|
||||||
- Integrates [YunoHost multimedia](https://github.com/YunoHost-Apps/yunohost.multimedia) folder structure
|
- Integrates [YunoHost multimedia](https://github.com/YunoHost-Apps/yunohost.multimedia) folder structure
|
||||||
|
|
||||||
### How to install:
|
**Shipped version:** 3.0.1
|
||||||
- Use **Install software** option from Yunohost admin panel
|
|
||||||
- Find textbox tagged as **Install custom App from github**
|
|
||||||
- Copy and paste: https://github.com/YunoHost-Apps/couchpotato_ynh
|
|
||||||
|
|
||||||
|
## YunoHost specific features
|
||||||
|
|
||||||
### More information about:
|
#### Supported architectures
|
||||||
- CouchPotato : https://couchpota.to
|
|
||||||
- Yunohost : https://yunohost.org
|
|
||||||
|
|
||||||
|
* x86-64 - [](https://ci-apps.yunohost.org/ci/apps/couchpotato/)
|
||||||
|
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/couchpotato/)
|
||||||
|
|
||||||
|
## Links
|
||||||
|
|
||||||
|
* Report a bug: https://github.com/YunoHost-Apps/couchpotato_ynh/issues
|
||||||
|
* App website: https://couchpota.to
|
||||||
|
* Upstream app repository: https://github.com/CouchPotato/CouchPotatoServer
|
||||||
|
* YunoHost website: https://yunohost.org/
|
||||||
|
|
||||||
#### Special Thanks to the Yunohost Community:
|
#### Special Thanks to the Yunohost Community:
|
||||||
[Snipees](https://github.com/Snipees)
|
[Snipees](https://github.com/Snipees)
|
||||||
|
@ -47,3 +49,17 @@ Download movies automatically, easily and in the best quality as soon as they ar
|
||||||
[scith](https://github.com/scith),
|
[scith](https://github.com/scith),
|
||||||
[tifred](https://github.com/drfred1981),
|
[tifred](https://github.com/drfred1981),
|
||||||
... :dizzy:
|
... :dizzy:
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Developer info
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/couchpotato_ynh/tree/testing).
|
||||||
|
|
||||||
|
To try the testing branch, please proceed like that.
|
||||||
|
```
|
||||||
|
sudo yunohost app install https://github.com/YunoHost-Apps/couchpotato_ynh/tree/testing --debug
|
||||||
|
or
|
||||||
|
sudo yunohost app upgrade couchpotato -u https://github.com/YunoHost-Apps/couchpotato_ynh/tree/testing --debug
|
||||||
|
```
|
||||||
|
|
|
@ -1,35 +1,34 @@
|
||||||
;; Test CouchPotato
|
# See here for more information
|
||||||
auto_remove=1
|
# https://github.com/YunoHost/package_check#syntax-check_process-file
|
||||||
; Manifest
|
|
||||||
domain="domain.tld" (DOMAIN)
|
# Move this file from check_process.default to check_process when you have filled it.
|
||||||
path="/couchpotato" (PATH)"
|
|
||||||
; Checks
|
;; Test complet
|
||||||
pkg_linter=1
|
; Manifest
|
||||||
setup_sub_dir=1
|
domain="domain.tld" (DOMAIN)
|
||||||
setup_root=1
|
path="/couchpotato" (PATH)"
|
||||||
setup_nourl=0
|
; Checks
|
||||||
setup_private=0
|
pkg_linter=1
|
||||||
setup_public=0
|
setup_sub_dir=1
|
||||||
upgrade=1
|
setup_root=1
|
||||||
backup_restore=1
|
setup_nourl=0
|
||||||
multi_instance=0
|
setup_private=0
|
||||||
wrong_user=0
|
setup_public=0
|
||||||
wrong_path=1
|
upgrade=1
|
||||||
incorrect_path=1
|
upgrade=1 from_commit=2a7461345d70ae231cc81a580189934626ed8c58
|
||||||
corrupt_source=0
|
backup_restore=1
|
||||||
fail_download_source=0
|
multi_instance=0
|
||||||
port_already_use=1 (5050)
|
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
|
||||||
final_path_already_use=0
|
# incorrect_path=1
|
||||||
|
port_already_use=1 (5050)
|
||||||
|
change_url=0
|
||||||
;;; Levels
|
;;; Levels
|
||||||
Level 1=auto
|
# If the level 5 (Package linter) is forced to 1. Please add justifications here.
|
||||||
Level 2=auto
|
Level 5=auto
|
||||||
Level 3=auto
|
;;; Options
|
||||||
# The app is single-user and does not support LDAP. It is therefore protected behind SSO.
|
Email=
|
||||||
Level 4=1
|
Notification=none
|
||||||
# See https://github.com/YunoHost/package_linter/issues/15
|
;;; Upgrade options
|
||||||
Level 5=1
|
; commit=2a7461345d70ae231cc81a580189934626ed8c58
|
||||||
Level 6=auto
|
name=From GIT
|
||||||
Level 7=auto
|
|
||||||
Level 8=0
|
|
||||||
Level 9=0
|
|
||||||
Level 10=0
|
|
||||||
|
|
6
conf/app.src
Normal file
6
conf/app.src
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
SOURCE_URL=https://github.com/CouchPotato/CouchPotatoServer/archive/build/3.0.1.tar.gz
|
||||||
|
SOURCE_SUM=f08f9c6ac02f66c6667f17ded1eea4c051a62bbcbadd2a8673394019878e92f7
|
||||||
|
SOURCE_SUM_PRG=sha256sum
|
||||||
|
SOURCE_FORMAT=tar.gz
|
||||||
|
SOURCE_IN_SUBDIR=true
|
||||||
|
SOURCE_FILENAME=
|
6
conf/multimedia.src
Normal file
6
conf/multimedia.src
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
SOURCE_URL=https://github.com/YunoHost-Apps/yunohost.multimedia/archive/v1.2.tar.gz
|
||||||
|
SOURCE_SUM=7dfc07e32d7842f87274ef780cb9757a7679573cbbeb095c5f86ef76806f5d95
|
||||||
|
SOURCE_SUM_PRG=sha256sum
|
||||||
|
SOURCE_FORMAT=tar.gz
|
||||||
|
SOURCE_IN_SUBDIR=true
|
||||||
|
SOURCE_FILENAME=
|
6
conf/pythonz.src
Normal file
6
conf/pythonz.src
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
SOURCE_URL=https://github.com/saghul/pythonz/archive/9067f35e0253b015eb51b8a4d60c0bd1a06dcc83.tar.gz
|
||||||
|
SOURCE_SUM=ce9eb5400fff81e4877e04dd7166c764d8adc999d9ca6b06ce933ee9375b8652
|
||||||
|
SOURCE_SUM_PRG=sha256sum
|
||||||
|
SOURCE_FORMAT=tar.gz
|
||||||
|
SOURCE_IN_SUBDIR=true
|
||||||
|
SOURCE_FILENAME=
|
|
@ -3,10 +3,10 @@ Description=CouchPotato application instance
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=__PYTHON__ __APPDIR__/CouchPotato.py --quiet --pid_file=__PIDFILE__ --data_dir=__DATADIR__ --config_file=__CONFIGFILE__
|
ExecStart=__FINALPATH__/ve2/bin/python __FINALPATH__/CouchPotato.py --quiet --pid_file=/var/run/__APP__/__APP__.pid --data_dir=__APP_DATA_DIR__ --config_file=__FINALPATH__/settings.conf
|
||||||
Type=simple
|
Type=simple
|
||||||
User=__USER__
|
User=__APP__
|
||||||
Group=__USER__
|
Group=__APP__
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
46
issue_template.md
Normal file
46
issue_template.md
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
---
|
||||||
|
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.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**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.*
|
||||||
|
3. *Delete the italic comments as you write over them below, and remove this guide.*
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
*A clear and concise description of what the bug is.*
|
||||||
|
|
||||||
|
**Versions**
|
||||||
|
- 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 | ...*
|
||||||
|
- Are you in a special context or did you perform some particular tweaking on your YunoHost instance ?: *no / yes*
|
||||||
|
- If yes, please explain:
|
||||||
|
- 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.*
|
||||||
|
- *If you performed a command from the CLI, the command itself is enough. For example:*
|
||||||
|
```sh
|
||||||
|
sudo yunohost app install couchpotato
|
||||||
|
```
|
||||||
|
- *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 '....'*
|
||||||
|
4. *See error*
|
||||||
|
|
||||||
|
**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.*
|
||||||
|
*If applicable and useful, add screenshots to help explain your problem.*
|
|
@ -1,44 +1,47 @@
|
||||||
{
|
{
|
||||||
"packaging_format": 1,
|
"name": "CouchPotato",
|
||||||
"name": "CouchPotato",
|
"id": "couchpotato",
|
||||||
"id": "couchpotato",
|
"packaging_format": 1,
|
||||||
"description": {
|
"description": {
|
||||||
"en": "Automatic movie downloader",
|
"en": "Automatic movie downloader",
|
||||||
"fr": "Téléchargement automatisé de film"
|
"fr": "Téléchargement automatisé de film"
|
||||||
},
|
},
|
||||||
"url": "https://couchpota.to/",
|
"version": "3.0.1~ynh1",
|
||||||
"license": "free",
|
"url": "https://couchpota.to/",
|
||||||
"maintainer": {
|
"license": "free",
|
||||||
"name": "Snipees",
|
"maintainer": {
|
||||||
"email": "snipees@wareziens.net",
|
"name": "Snipees",
|
||||||
"url": "https://github.com/Snipees"
|
"email": "snipees@wareziens.net",
|
||||||
},
|
"url": "https://github.com/Snipees"
|
||||||
"multi_instance": false,
|
},
|
||||||
"services": [
|
"requirements": {
|
||||||
"nginx"
|
"yunohost": ">= 3.5"
|
||||||
],
|
},
|
||||||
"requirements": {
|
"multi_instance": false,
|
||||||
"yunohost": ">= 2.4.0"
|
"services": [
|
||||||
},
|
"nginx"
|
||||||
"arguments": {
|
],
|
||||||
"install": [
|
"arguments": {
|
||||||
{
|
"install" : [
|
||||||
"name": "domain",
|
{
|
||||||
"ask": {
|
"name": "domain",
|
||||||
"en": "Choose a domain for CouchPotato",
|
"type": "domain",
|
||||||
"fr": "Choisissez un domaine pour CouchPotato"
|
"ask": {
|
||||||
},
|
"en": "Choose a domain for CouchPotato",
|
||||||
"example": "mydomain.org"
|
"fr": "Choisissez un domaine pour CouchPotato"
|
||||||
},
|
},
|
||||||
{
|
"example": "example.com"
|
||||||
"name": "path",
|
},
|
||||||
"ask": {
|
{
|
||||||
"en": "Choose a path for CouchPotato",
|
"name": "path",
|
||||||
"fr": "Choisissez un chemin pour CouchPotato"
|
"type": "path",
|
||||||
},
|
"ask": {
|
||||||
"example": "/couchpotato",
|
"en": "Choose a path for CouchPotato",
|
||||||
"default": "/couchpotato"
|
"fr": "Choisissez un chemin pour CouchPotato"
|
||||||
}
|
},
|
||||||
]
|
"example": "/couchpotato",
|
||||||
}
|
"default": "/couchpotato"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
18
pull_request_template.md
Normal file
18
pull_request_template.md
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
## 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)/)
|
22
scripts/_common.sh
Normal file
22
scripts/_common.sh
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# COMMON VARIABLES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# dependencies used by the app
|
||||||
|
pkg_dependencies="python-pip python-virtualenv python-dev uwsgi uwsgi-plugin-python"
|
||||||
|
|
||||||
|
python_version=2.7.2
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# PERSONAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# EXPERIMENTAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# FUTURE OFFICIAL HELPERS
|
||||||
|
#=================================================
|
|
@ -1,25 +1,76 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eu
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
# Source app helpers
|
#=================================================
|
||||||
source /usr/share/yunohost/helpers
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Common variable declaration
|
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
app_install_dir="/opt/yunohost/$app"
|
source ../settings/scripts/_common.sh
|
||||||
app_data_dir="/home/yunohost.app/$app"
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Retrieve arguments
|
#=================================================
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Backup sources
|
ynh_clean_setup () {
|
||||||
ynh_backup "$app_install_dir" "sources"
|
true
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info --message="Loading installation settings..."
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
|
app_data_dir=$(ynh_app_setting_get --app=$app --key=app_data_dir)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info --message="Declaring files to be backed up..."
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE APP MAIN DIR
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup --src_path="$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC BACKUP
|
||||||
|
#=================================================
|
||||||
|
# BACKUP LOGROTATE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP SYSTEMD
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP VARIOUS FILES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Backup data
|
# Backup data
|
||||||
ynh_backup "$app_data_dir" "data"
|
ynh_backup --src_path="$app_data_dir"
|
||||||
|
|
||||||
# Backup daemon
|
#=================================================
|
||||||
ynh_backup "/etc/systemd/system/$app.service" "$app.service"
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Copy the conf files
|
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||||
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
|
|
||||||
|
|
400
scripts/install
400
scripts/install
|
@ -1,160 +1,304 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -eu
|
#=================================================
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
# GENERIC START
|
||||||
source="https://github.com/CouchPotato/CouchPotatoServer"
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Source app helpers
|
#=================================================
|
||||||
source /usr/share/yunohost/helpers
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Retrieve arguments
|
ynh_clean_setup () {
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
true
|
||||||
path=$YNH_APP_ARG_PATH
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# Correct path: puts a / at the start and nothing at the end
|
#=================================================
|
||||||
if [ "${path:0:1}" != "/" ]; then
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
path="/$path"
|
#=================================================
|
||||||
fi
|
|
||||||
if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then
|
|
||||||
path="${path:0:${#path}-1}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check domain/path availability
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
path_url=$YNH_APP_ARG_PATH
|
||||||
|| ynh_die "Path not available: ${domain}${path}"
|
|
||||||
|
|
||||||
# Destinations definitions
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
app_install_dir="/opt/yunohost/$app"
|
|
||||||
app_data_dir="/home/yunohost.app/$app"
|
|
||||||
app_logs_dir="/var/log/$app"
|
|
||||||
app_config_file="${app_data_dir}/settings.conf"
|
|
||||||
app_pid_file="/var/run/$app/$app.pid"
|
|
||||||
app_python_bin="/usr/bin/python"
|
|
||||||
|
|
||||||
# Install Couchpotato
|
#=================================================
|
||||||
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Validating installation parameters..."
|
||||||
|
|
||||||
# Get first available port
|
final_path=/opt/yunohost/$app
|
||||||
port=5050
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||||
sudo yunohost app checkport $port
|
|
||||||
while [[ ! $? -eq 0 ]]; do
|
|
||||||
port=$((port+1))
|
|
||||||
sudo yunohost app checkport $port
|
|
||||||
done
|
|
||||||
ynh_app_setting_set "$app" port "$port"
|
|
||||||
|
|
||||||
# Make directories
|
multimedia_final_path=/opt/yunohost/${app}_multimedia
|
||||||
sudo mkdir -p $app_data_dir
|
test ! -e "$multimedia_final_path" || ynh_die --message="This path already contains a folder"
|
||||||
sudo mkdir -p $app_install_dir
|
|
||||||
|
|
||||||
# Install latest version of app using the fork
|
app_data_dir=/home/yunohost.app/$app
|
||||||
sudo git clone $source $app_install_dir
|
test ! -e "$app_data_dir" || ynh_die --message="This path already contains a folder"
|
||||||
|
|
||||||
# Install dependencies (using virtualenv)
|
# Register (book) web path
|
||||||
if [[ $(python --version 2>&1) != Python\ 2* ]]; then
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||||
app_python_bin=$app_install_dir/bin/python
|
|
||||||
sudo apt-get install -y python-pip python-virtualenv python-dev uwsgi uwsgi-plugin-python
|
|
||||||
sudo virtualenv $app_install_dir
|
|
||||||
sudo bash -c "source $app_install_dir/bin/activate && pip install cheetah"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create app user
|
#=================================================
|
||||||
id -u $app &>/dev/null || sudo useradd --home-dir $app_install_dir --shell /bin/false $app
|
# STORE SETTINGS FROM MANIFEST
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Storing installation settings..."
|
||||||
|
|
||||||
# YunoHost multimedia
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||||
# Add yunohost.multimedia directory
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||||
wget -qq https://github.com/YunoHost-Apps/yunohost.multimedia/archive/master.zip
|
ynh_app_setting_set --app=$app --key=multimedia_final_path --value=$multimedia_final_path
|
||||||
unzip -qq master.zip
|
ynh_app_setting_set --app=$app --key=app_data_dir --value=$app_data_dir
|
||||||
sudo ./yunohost.multimedia-master/script/ynh_media_build.sh
|
|
||||||
# Give write access to the yunohost.multimedia directory so that Couchpotato can move Movies to the Movie directory
|
|
||||||
sudo usermod -a -G multimedia $app
|
|
||||||
# Creates the "Movies" subfolder in "Video"
|
|
||||||
sudo mkdir -p "/home/yunohost.multimedia/share/Video/Movies"
|
|
||||||
# Fix permissions
|
|
||||||
sudo ./yunohost.multimedia-master/script/ynh_media_build.sh
|
|
||||||
|
|
||||||
# Transmission link: Preferred method is direct RPC link. If not available, switch to watchdir.
|
#=================================================
|
||||||
transmission_rpcurl=""
|
# STANDARD MODIFICATIONS
|
||||||
transmission_rpcpassword=""
|
#=================================================
|
||||||
transmission_watchdir=""
|
# FIND AND OPEN A PORT
|
||||||
# Check if Transmission is installed
|
#=================================================
|
||||||
if [[ -z $(sudo yunohost app list -i -f transmission | grep -v 'apps:') ]]; then
|
ynh_script_progression --message="Configuring firewall..."
|
||||||
sudo sed -i "s@__RPC__@0@g" ../conf/couchpotato.conf # Disable Transmission RPC
|
|
||||||
sudo sed -i "s@__BLACKHOLE__@0@g" ../conf/couchpotato.conf # Disable Transmission Watchdir
|
# Find an available port
|
||||||
sudo sed -i "s@__RENAMER__@0@g" ../conf/couchpotato.conf # Disable Renamer
|
port=$(ynh_find_port --port=5050)
|
||||||
|
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||||
|
|
||||||
|
# Optional: Expose this port publicly
|
||||||
|
# (N.B. : you only need to do this if the app actually needs to expose the port publicly.
|
||||||
|
# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !)
|
||||||
|
|
||||||
|
# Open the port
|
||||||
|
# ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INSTALL DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
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
|
||||||
|
ynh_setup_source --dest_dir="$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring nginx web server..."
|
||||||
|
|
||||||
|
# Create a dedicated nginx config
|
||||||
|
ynh_add_nginx_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring system user..."
|
||||||
|
|
||||||
|
# Create a system user
|
||||||
|
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC SETUP
|
||||||
|
#=================================================
|
||||||
|
# MAKE DATA DIRECTORY
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Make data directory..."
|
||||||
|
|
||||||
|
# Make directories
|
||||||
|
mkdir -p $app_data_dir
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INSTALL PYTHONZ TO GET PYTHON
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info --message="Installing Python..."
|
||||||
|
|
||||||
|
# Get pythonz
|
||||||
|
# curl -kL https://raw.githubusercontent.com/saghul/pythonz/master/pythonz-install
|
||||||
|
# ./pythonz-install
|
||||||
|
ynh_setup_source --dest_dir="$final_path/.pythonz" --source_id=pythonz
|
||||||
|
export PYTHONZ_ROOT="$final_path/.pythonz"
|
||||||
|
# Then install it
|
||||||
|
python $final_path/.pythonz/pythonz_install.py
|
||||||
|
|
||||||
|
# Install Python
|
||||||
|
$final_path/.pythonz/bin/pythonz install $python_version
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BUILD COUCHPOTATO
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Building CouchPotato..."
|
||||||
|
|
||||||
|
# Set permissions to app files
|
||||||
|
chown -R "$app": "$final_path"
|
||||||
|
|
||||||
|
pushd $final_path/
|
||||||
|
virtualenv -p $($final_path/.pythonz/bin/pythonz locate $python_version) ve2
|
||||||
|
ve2/bin/pip install --upgrade pyopenssl
|
||||||
|
ve2/bin/pip install cheetah
|
||||||
|
popd
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INSTALL YUNOHOST MULTIMEDIA
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Install YunoHost multimedia..."
|
||||||
|
|
||||||
|
ynh_setup_source --dest_dir="$multimedia_final_path" -source_id=multimedia
|
||||||
|
$multimedia_final_path/script/ynh_media_build.sh
|
||||||
|
|
||||||
|
# Give write access to the yunohost.multimedia directory so that Couchpotato can move Movies to the Movie directory
|
||||||
|
usermod -a -G multimedia $app
|
||||||
|
|
||||||
|
# Creates the "Movies" subfolder in "Video"
|
||||||
|
mkdir -p "/home/yunohost.multimedia/share/Video/Movies"
|
||||||
|
|
||||||
|
# Fix permissions
|
||||||
|
$multimedia_final_path/script/ynh_media_build.sh
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CONFIGURE TRANSMISSION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring transmission..."
|
||||||
|
|
||||||
|
# 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
|
||||||
|
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
|
||||||
|
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
|
||||||
|
# If transmission uses YunoHost multimedia, use its folder for the renamer
|
||||||
else
|
else
|
||||||
echo "Transmission is installed. Trying to link it to CouchPotato..."
|
# Check if transmission has watchdir enabled
|
||||||
# Check if the transmission password is in settings
|
if [[ -n $(ynh_app_setting_get --app=transmission --key=watchdir || true) ]]; then
|
||||||
if [[ -n $(ynh_app_setting_get transmission rpcpassword || true) ]]; then
|
ynh_script_progression --message="Transmission will be linked to CouchPotato with watchdir"
|
||||||
echo "Transmission will be linked to CouchPotato directly"
|
transmission_watchdir=$(ynh_app_setting_get --app=transmission --key=watchdir)
|
||||||
transmission_rpcurl="$(ynh_app_setting_get transmission path)transmission"
|
ynh_replace_string --match_string="__RPC__" --replace_string="0" --target_file="../conf/couchpotato.conf" # Disable Transmission RPC
|
||||||
transmission_rpcpassword=$(ynh_app_setting_get transmission rpcpassword)
|
ynh_replace_string --match_string="__BLACKHOLE__" --replace_string="1" --target_file="../conf/couchpotato.conf" # Enable Transmission Watchdir
|
||||||
sudo sed -i "s@__RPC__@1@g" ../conf/couchpotato.conf # Enable Transmission RPC
|
ynh_replace_string --match_string="__RENAMER__" --replace_string="1" --target_file="../conf/couchpotato.conf" # Enable Renamer
|
||||||
sudo sed -i "s@__BLACKHOLE__@0@g" ../conf/couchpotato.conf # Disable Transmission Watchdir
|
|
||||||
sudo sed -i "s@__RENAMER__@1@g" ../conf/couchpotato.conf # Enable Renamer
|
|
||||||
# If transmission uses YunoHost multimedia, use its folder for the renamer
|
# If transmission uses YunoHost multimedia, use its folder for the renamer
|
||||||
else
|
else
|
||||||
# Check if transmission has watchdir enabled
|
ynh_script_progression --message="Cannot link Couchpotato to Transmission because Transmission has no RPC password or watchdir available."
|
||||||
if [[ -n $(ynh_app_setting_get transmission watchdir || true) ]]; then
|
ynh_replace_string --match_string="__RPC__" --replace_string="0" --target_file="../conf/couchpotato.conf" # Disable Transmission RPC
|
||||||
echo "Transmission will be linked to CouchPotato with watchdir"
|
ynh_replace_string --match_string="__BLACKHOLE__" --replace_string="0" --target_file="../conf/couchpotato.conf" # Disable Transmission Watchdir
|
||||||
transmission_watchdir=$(ynh_app_setting_get transmission watchdir)
|
ynh_replace_string --match_string="__RENAMER__" --replace_string="0" --target_file="../conf/couchpotato.conf" # Disable Renamer
|
||||||
sudo sed -i "s@__RPC__@0@g" ../conf/couchpotato.conf # Disable Transmission RPC
|
|
||||||
sudo sed -i "s@__BLACKHOLE__@1@g" ../conf/couchpotato.conf # Enable Transmission Watchdir
|
|
||||||
sudo sed -i "s@__RENAMER__@1@g" ../conf/couchpotato.conf # Enable Renamer
|
|
||||||
# If transmission uses YunoHost multimedia, use its folder for the renamer
|
|
||||||
else
|
|
||||||
echo "Cannot link Couchpotato to Transmission because Transmission has no RPC password or watchdir available."
|
|
||||||
sudo sed -i "s@__RPC__@0@g" ../conf/couchpotato.conf # Disable Transmission RPC
|
|
||||||
sudo sed -i "s@__BLACKHOLE__@0@g" ../conf/couchpotato.conf # Disable Transmission Watchdir
|
|
||||||
sudo sed -i "s@__RENAMER__@0@g" ../conf/couchpotato.conf # Disable Renamer
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Configure App
|
#=================================================
|
||||||
sudo sed -i "s@__RPCURL__@$transmission_rpcurl@g" ../conf/couchpotato.conf
|
# MODIFY A CONFIG FILE
|
||||||
sudo sed -i "s@__RPCPASSWORD__@$transmission_rpcpassword@g" ../conf/couchpotato.conf
|
#=================================================
|
||||||
sudo sed -i "s@__WATCHDIR__@$transmission_watchdir@g" ../conf/couchpotato.conf
|
ynh_script_progression --message="Modifying a config file..."
|
||||||
|
|
||||||
sudo sed -i "s@__PATH__@$path@g" ../conf/couchpotato.conf
|
app_config_file="${final_path}/settings.conf"
|
||||||
sudo sed -i "s@__PORT__@$port@g" ../conf/couchpotato.conf
|
|
||||||
sudo sed -i "s@__DATADIR__@$app_data_dir@g" ../conf/couchpotato.conf
|
|
||||||
|
|
||||||
sudo cp -a ../conf/couchpotato.conf $app_config_file
|
# 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"
|
||||||
|
|
||||||
# Redirect logs directory
|
ynh_replace_string --match_string="__PATH__" --replace_string="$path" --target_file="../conf/couchpotato.conf"
|
||||||
sudo mkdir -p $app_logs_dir
|
ynh_replace_string --match_string="__PORT__" --replace_string="$port@" --target_file="../conf/couchpotato.conf"
|
||||||
sudo chown -R $app $app_logs_dir
|
ynh_replace_string --match_string="__DATADIR__" --replace_string="$app_data_dir" --target_file="../conf/couchpotato.conf"
|
||||||
sudo chmod +x -R $app_logs_dir
|
|
||||||
sudo sed -i "s@self.log_dir =.*@self.log_dir = '$app_logs_dir'@g" $app_install_dir/CouchPotato.py
|
|
||||||
|
|
||||||
# Permissions
|
cp -a ../conf/couchpotato.conf $app_config_file
|
||||||
sudo chown -R $app:$app $app_install_dir
|
|
||||||
sudo chown -R $app:$app $app_data_dir
|
|
||||||
|
|
||||||
# Configure service
|
# Calculate and store the config file checksum into the app settings
|
||||||
sed -i "s@__PYTHON__@$app_python_bin@g" ../conf/systemd.service
|
ynh_store_file_checksum --file="$app_config_file"
|
||||||
sed -i "s@__APPDIR__@$app_install_dir@g" ../conf/systemd.service
|
|
||||||
sed -i "s@__DATADIR__@$app_data_dir@g" ../conf/systemd.service
|
|
||||||
sed -i "s@__PIDFILE__@$app_pid_file@g" ../conf/systemd.service
|
|
||||||
sed -i "s@__CONFIGFILE__@$app_config_file@g" ../conf/systemd.service
|
|
||||||
sed -i "s@__USER__@$app@g" ../conf/systemd.service
|
|
||||||
sudo cp ../conf/systemd.service /etc/systemd/system/$app.service
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl enable $app
|
|
||||||
sudo yunohost service add $app
|
|
||||||
|
|
||||||
# Start service
|
#=================================================
|
||||||
sudo yunohost service start $app
|
# CONFIGURE LOGS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring logs..."
|
||||||
|
|
||||||
# Configure Nginx and reload
|
# Redirect logs directory
|
||||||
sed -i "s@__PATH__@$path@g" ../conf/nginx.conf
|
app_logs_dir="/var/log/$app"
|
||||||
sed -i "s@__PORT__@$port@g" ../conf/nginx.conf
|
mkdir -p $app_logs_dir
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
chown -R $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"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# 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
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring log rotation..."
|
||||||
|
|
||||||
|
# Use logrotate to manage application logfile(s)
|
||||||
|
ynh_use_logrotate
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||||
|
|
||||||
|
yunohost service add $app --description "CouchPotato Daemon" --log "/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# START SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Starting a systemd service..."
|
||||||
|
|
||||||
|
# Start a systemd service
|
||||||
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SSOWAT
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring SSOwat..."
|
||||||
|
|
||||||
# Open the /api path so that external applications can connect
|
# Open the /api path so that external applications can connect
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/api"
|
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/api"
|
||||||
|
|
||||||
# Reload Nginx and regenerate SSOwat conf
|
#=================================================
|
||||||
sudo service nginx reload
|
# RELOAD NGINX
|
||||||
sudo yunohost app ssowatconf
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading nginx web server..."
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Installation of $app completed"
|
||||||
|
|
132
scripts/remove
132
scripts/remove
|
@ -1,42 +1,114 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -u
|
#=================================================
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Source app helpers
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Common variable declaration
|
#=================================================
|
||||||
app_install_dir="/opt/yunohost/$app"
|
# LOAD SETTINGS
|
||||||
app_data_dir="/home/yunohost.app/$app"
|
#=================================================
|
||||||
app_logs_dir="/var/log/$app"
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
# Retrieve arguments
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
|
||||||
|
|
||||||
# Remove files
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
# Kill app and remove from boot
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
sudo service $app stop
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
app_data_dir=$(ynh_app_setting_get --app=$app --key=app_data_dir)
|
||||||
|
|
||||||
# Delete app user
|
#=================================================
|
||||||
sudo deluser $app
|
# STANDARD REMOVE
|
||||||
|
#=================================================
|
||||||
|
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Remove sources
|
# Remove the service from the list of services known by Yunohost (added from `yunohost service add`)
|
||||||
sudo rm -rf $app_install_dir
|
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
||||||
sudo rm -rf $app_data_dir
|
then
|
||||||
sudo rm -rf $app_logs_dir
|
ynh_script_progression --message="Removing $app service..."
|
||||||
|
yunohost service remove $app
|
||||||
|
fi
|
||||||
|
|
||||||
# Remove data
|
#=================================================
|
||||||
sudo rm -rf $app_data_dir
|
# STOP AND REMOVE SERVICE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Stopping and removing the systemd service..."
|
||||||
|
|
||||||
# Remove service
|
# Remove the dedicated systemd config
|
||||||
sudo systemctl disable $app.service
|
ynh_remove_systemd_config
|
||||||
sudo rm -f /etc/systemd/system/$app.service
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo yunohost service remove $app
|
|
||||||
|
|
||||||
# Remove nginx configuration file
|
#=================================================
|
||||||
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
# REMOVE DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing dependencies..."
|
||||||
|
|
||||||
# Restart services
|
# Remove metapackage and its dependencies
|
||||||
sudo service nginx reload
|
ynh_remove_app_dependencies
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE APP MAIN DIR
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing app main directory..."
|
||||||
|
|
||||||
|
# Remove the app directory securely
|
||||||
|
ynh_secure_remove --file="$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing nginx web server configuration..."
|
||||||
|
|
||||||
|
# Remove the dedicated nginx config
|
||||||
|
ynh_remove_nginx_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE LOGROTATE CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing logrotate configuration..."
|
||||||
|
|
||||||
|
# Remove the app-specific logrotate config
|
||||||
|
ynh_remove_logrotate
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CLOSE A PORT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
if yunohost firewall list | grep -q "\- $port$"
|
||||||
|
then
|
||||||
|
ynh_script_progression --message="Closing port $port..."
|
||||||
|
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC REMOVE
|
||||||
|
#=================================================
|
||||||
|
# REMOVE VARIOUS FILES
|
||||||
|
#=================================================
|
||||||
|
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"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# REMOVE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing the dedicated system user..."
|
||||||
|
|
||||||
|
# Delete a system user
|
||||||
|
ynh_system_user_delete --username=$app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Removal of $app completed"
|
||||||
|
|
220
scripts/restore
220
scripts/restore
|
@ -1,95 +1,169 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -eu
|
#=================================================
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Source app helpers
|
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
source /usr/share/yunohost/helpers
|
source ../settings/scripts/_common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Common variable declaration
|
#=================================================
|
||||||
app_install_dir="/opt/yunohost/$app"
|
# MANAGE SCRIPT FAILURE
|
||||||
app_data_dir="/home/yunohost.app/$app"
|
#=================================================
|
||||||
app_logs_dir="/var/log/$app"
|
|
||||||
app_python_bin="/usr/bin/python"
|
|
||||||
|
|
||||||
# Retrieve arguments
|
ynh_clean_setup () {
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
true
|
||||||
path=$(ynh_app_setting_get "$app" path)
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
# Check destination directories
|
#=================================================
|
||||||
[[ -d $app_install_dir ]] && ynh_die \
|
# LOAD SETTINGS
|
||||||
"The destination directory '$app_install_dir' already exists.\
|
#=================================================
|
||||||
You should safely delete it before restoring this app."
|
ynh_script_progression --message="Loading settings..."
|
||||||
|
|
||||||
[[ -d $app_data_dir ]] && ynh_die \
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
"The destination directory '$app_data_dir' already exists.\
|
|
||||||
You should safely delete it before restoring this app."
|
|
||||||
|
|
||||||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
[[ -f $nginx_conf ]] && ynh_die \
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
"The NGINX configuration already exists at '${nginx_conf}'.
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
You should safely delete it before restoring this app."
|
app_data_dir=$(ynh_app_setting_get --app=$app --key=app_data_dir)
|
||||||
|
multimedia_final_path=$(ynh_app_setting_get --app=$app --key=multimedia_final_path)
|
||||||
|
|
||||||
systemd_conf="/etc/systemd/system/${app}.service"
|
#=================================================
|
||||||
[[ -f $systemd_conf ]] && ynh_die \
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
"The Systemd configuration already exists at '${systemd_conf}'.
|
#=================================================
|
||||||
You should safely delete it before restoring this app."
|
ynh_script_progression --message="Validating restoration parameters..."
|
||||||
|
|
||||||
# Restore sources
|
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||||
sudo mkdir -p $app_install_dir
|
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||||
sudo cp -a ./sources/. $app_install_dir
|
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 "
|
||||||
|
|
||||||
# Restore data
|
#=================================================
|
||||||
sudo mkdir -p $app_data_dir
|
# STANDARD RESTORATION STEPS
|
||||||
sudo cp -a ./data/. $app_data_dir
|
#=================================================
|
||||||
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the nginx configuration..."
|
||||||
|
|
||||||
# Reinstall dependencies (using virtualenv)
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
if [[ $(python --version 2>&1) != Python\ 2* ]]; then
|
|
||||||
sudo apt-get install -y python-pip python-virtualenv python-dev uwsgi uwsgi-plugin-python
|
|
||||||
sudo virtualenv $app_install_dir
|
|
||||||
sudo bash -c "source $app_install_dir/bin/activate && pip install cheetah"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Recreate app user
|
#=================================================
|
||||||
id -u $app &>/dev/null || sudo useradd --home-dir $app_install_dir --shell /bin/false $app
|
# RESTORE THE APP MAIN DIR
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the app main directory..."
|
||||||
|
|
||||||
# YunoHost multimedia
|
ynh_restore_file --origin_path="$final_path"
|
||||||
# Add yunohost.multimedia directory
|
|
||||||
wget -qq https://github.com/YunoHost-Apps/yunohost.multimedia/archive/master.zip
|
#=================================================
|
||||||
unzip -qq master.zip
|
# RECREATE THE DEDICATED USER
|
||||||
sudo ./yunohost.multimedia-master/script/ynh_media_build.sh
|
#=================================================
|
||||||
# Give write access to the yunohost.multimedia directory so that Couchpotato can move Movies to the Movie directory
|
ynh_script_progression --message="Recreating the dedicated system user..."
|
||||||
sudo usermod -a -G multimedia $app
|
|
||||||
# Creates the "Movies" subfolder in "Video"
|
# Create the dedicated user (if not existing)
|
||||||
sudo mkdir -p "/home/yunohost.multimedia/share/Video/Movies"
|
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||||
# Fix permissions
|
|
||||||
sudo ./yunohost.multimedia-master/script/ynh_media_build.sh
|
#=================================================
|
||||||
|
# RESTORE USER RIGHTS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring user rights..."
|
||||||
|
|
||||||
|
# Restore permissions on app files
|
||||||
|
chown -R $app:$app $final_path
|
||||||
|
chown -R $app:$app $app_data_dir
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC RESTORATION
|
||||||
|
#=================================================
|
||||||
|
# REINSTALL DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reinstalling dependencies..."
|
||||||
|
|
||||||
|
# Define and install dependencies
|
||||||
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE DATA DIRECTORY
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the data directory..."
|
||||||
|
|
||||||
|
ynh_restore_file --origin_path="$app_data_dir"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INSTALL YUNOHOST MULTIMEDIA
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Install YunoHost multimedia..."
|
||||||
|
|
||||||
|
ynh_setup_source --dest_dir="$multimedia_final_path" -source_id=multimedia
|
||||||
|
$multimedia_final_path/script/ynh_media_build.sh
|
||||||
|
|
||||||
|
# Give write access to the yunohost.multimedia directory so that Couchpotato can move Movies to the Movie directory
|
||||||
|
usermod -a -G multimedia $app
|
||||||
|
|
||||||
|
# Creates the "Movies" subfolder in "Video"
|
||||||
|
mkdir -p "/home/yunohost.multimedia/share/Video/Movies"
|
||||||
|
|
||||||
|
# Fix permissions
|
||||||
|
$multimedia_final_path/script/ynh_media_build.sh
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CONFIGURE LOGS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring logs..."
|
||||||
|
|
||||||
# Redirect logs directory
|
# Redirect logs directory
|
||||||
sudo mkdir -p $app_logs_dir
|
app_logs_dir="/var/log/$app"
|
||||||
sudo chown -R $app $app_logs_dir
|
mkdir -p $app_logs_dir
|
||||||
sudo chmod +x -R $app_logs_dir
|
chown -R $app $app_logs_dir
|
||||||
sudo sed -i "s@self.log_dir =.*@self.log_dir = '$app_logs_dir'@g" $app_install_dir/CouchPotato.py
|
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"
|
||||||
|
|
||||||
# Permissions
|
#=================================================
|
||||||
sudo chown -R $app:$app $app_install_dir
|
# RESTORE SYSTEMD
|
||||||
sudo chown -R $app:$app $app_data_dir
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the systemd configuration..."
|
||||||
|
|
||||||
# Restore daemon config
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||||
sudo cp -a ./$app.service $systemd_conf
|
systemctl enable $app.service
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl enable $app
|
|
||||||
sudo yunohost service add $app
|
|
||||||
|
|
||||||
# Start service
|
#=================================================
|
||||||
sudo yunohost service start $app
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||||
|
|
||||||
# Restore Nginx conf
|
yunohost service add $app --description "A short description of the app" --log "/var/log/$app/$app.log"
|
||||||
sudo cp -a ./nginx.conf "$nginx_conf"
|
|
||||||
|
|
||||||
# Open the /api path so that external applications can connect
|
#=================================================
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/api"
|
# START SYSTEMD SERVICE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Starting a systemd service..."
|
||||||
|
|
||||||
# Reload Nginx and regenerate SSOwat conf
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
sudo service nginx reload
|
|
||||||
sudo yunohost app ssowatconf
|
#=================================================
|
||||||
|
# RESTORE THE LOGROTATE CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the logrotate configuration..."
|
||||||
|
|
||||||
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading nginx web server..."
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Restoration completed for $app"
|
||||||
|
|
293
scripts/upgrade
293
scripts/upgrade
|
@ -1,31 +1,51 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -eu
|
#=================================================
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
# GENERIC START
|
||||||
source="https://github.com/CouchPotato/CouchPotatoServer"
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Backup the current version of the app, restore it if the upgrade fails
|
source _common.sh
|
||||||
EXIT_PROPERLY () {
|
source /usr/share/yunohost/helpers
|
||||||
trap '' EXIT
|
|
||||||
set +e
|
|
||||||
sudo yunohost backup restore --ignore-hooks $app-before-upgrade --apps $app --force --quiet # Restore the backup if upgrade failed
|
|
||||||
ynh_die "Upgrade failed. The app was restored to the way it was before the failed upgrade."
|
|
||||||
}
|
|
||||||
if [[ -n $(sudo yunohost backup info $app-before-upgrade || true) ]]; then
|
|
||||||
sudo yunohost backup delete $app-before-upgrade
|
|
||||||
fi
|
|
||||||
sudo yunohost backup create --ignore-hooks --apps $app --name $app-before-upgrade --quiet
|
|
||||||
set -e
|
|
||||||
trap EXIT_PROPERLY ERR
|
|
||||||
|
|
||||||
# Source app helpers
|
#=================================================
|
||||||
source /usr/share/yunohost/helpers
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
# Retrieve arguments
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
|
||||||
path=$(ynh_app_setting_get "$app" path)
|
|
||||||
port=$(ynh_app_setting_get "$app" port)
|
|
||||||
|
|
||||||
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
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
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Checking version..."
|
||||||
|
|
||||||
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# 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
|
# Cancel upgrade if the version is too old
|
||||||
if [[ -n $(ynh_app_setting_get $app method) ]]; then
|
if [[ -n $(ynh_app_setting_get $app method) ]]; then
|
||||||
ynh_die "Your current version is too old and cannot be upgraded.\
|
ynh_die "Your current version is too old and cannot be upgraded.\
|
||||||
|
@ -33,74 +53,189 @@
|
||||||
If you had a remote install, please remove the app and install redirect_ynh for this purpose instead."
|
If you had a remote install, please remove the app and install redirect_ynh for this purpose instead."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Destinations definitions
|
# If final_path doesn't exist, create it
|
||||||
app_install_dir="/opt/yunohost/$app"
|
if [ -z "$final_path" ]; then
|
||||||
app_data_dir="/home/yunohost.app/$app"
|
final_path=/var/www/$app
|
||||||
app_logs_dir="/var/log/$app"
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||||
app_config_file="${app_data_dir}/settings.conf"
|
fi
|
||||||
app_pid_file="/var/run/$app/$app.pid"
|
|
||||||
app_python_bin="/usr/bin/python"
|
|
||||||
|
|
||||||
# Upgrade Couchpotato
|
#=================================================
|
||||||
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
||||||
|
|
||||||
# Kill app
|
# Backup the current version of the app
|
||||||
sudo service $app stop || true
|
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
|
||||||
|
|
||||||
# Upgrade to the latest version of app using the fork
|
#=================================================
|
||||||
cd $app_install_dir && sudo git pull
|
# CHECK THE PATH
|
||||||
cd -
|
#=================================================
|
||||||
|
|
||||||
# Upgrade dependencies
|
# Normalize the URL path syntax
|
||||||
if [[ $(python --version 2>&1) != Python\ 2* ]]; then
|
# N.B. : this is for app installations before YunoHost 2.7
|
||||||
app_python_bin=$app_install_dir/bin/python
|
# where this value might be something like /foo/ or foo/
|
||||||
sudo apt-get install -y python-pip python-virtualenv python-dev uwsgi uwsgi-plugin-python
|
# instead of /foo ....
|
||||||
fi
|
# 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)
|
||||||
|
|
||||||
# YunoHost multimedia
|
#=================================================
|
||||||
# Add yunohost.multimedia directory
|
# STANDARD UPGRADE STEPS
|
||||||
wget -qq https://github.com/YunoHost-Apps/yunohost.multimedia/archive/master.zip
|
#=================================================
|
||||||
unzip -qq master.zip
|
# STOP SYSTEMD SERVICE
|
||||||
sudo ./yunohost.multimedia-master/script/ynh_media_build.sh
|
#=================================================
|
||||||
# Give write access to the yunohost.multimedia directory so that Couchpotato can move Movies to the Movie directory
|
ynh_script_progression --message="Stopping a systemd service..."
|
||||||
sudo usermod -a -G multimedia $app
|
|
||||||
# Creates the "Movies" subfolder in "Video"
|
|
||||||
sudo mkdir -p "/home/yunohost.multimedia/share/Video/Movies"
|
|
||||||
# Fix permissions
|
|
||||||
sudo ./yunohost.multimedia-master/script/ynh_media_build.sh
|
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
# Redirect logs directory
|
#=================================================
|
||||||
if [[ $app_logs_dir != "$app_data_dir"* ]]; then
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
sudo sed -i "s@self.log_dir =.*@self.log_dir = '$app_logs_dir'@g" $app_install_dir/CouchPotato.py
|
#=================================================
|
||||||
fi
|
|
||||||
|
|
||||||
# Permissions
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
sudo chown -R $app:$app $app_install_dir
|
then
|
||||||
sudo chown -R $app:$app $app_data_dir
|
ynh_script_progression --message="Upgrading source files..."
|
||||||
|
|
||||||
# Configure service
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
sed -i "s@__PYTHON__@$app_python_bin@g" ../conf/systemd.service
|
ynh_setup_source --dest_dir="$final_path"
|
||||||
sed -i "s@__APPDIR__@$app_install_dir@g" ../conf/systemd.service
|
fi
|
||||||
sed -i "s@__DATADIR__@$app_data_dir@g" ../conf/systemd.service
|
|
||||||
sed -i "s@__PIDFILE__@$app_pid_file@g" ../conf/systemd.service
|
|
||||||
sed -i "s@__CONFIGFILE__@$app_config_file@g" ../conf/systemd.service
|
|
||||||
sed -i "s@__USER__@$app@g" ../conf/systemd.service
|
|
||||||
sudo cp ../conf/systemd.service /etc/systemd/system/$app.service
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl enable $app
|
|
||||||
sudo yunohost service add $app
|
|
||||||
|
|
||||||
# Start service
|
#=================================================
|
||||||
sudo yunohost service start $app
|
# NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading nginx web server configuration..."
|
||||||
|
|
||||||
# Configure Nginx and reload
|
# Create a dedicated nginx config
|
||||||
sed -i "s@__PATH__@$path@g" ../conf/nginx.conf
|
ynh_add_nginx_config
|
||||||
sed -i "s@__PORT__@$port@g" ../conf/nginx.conf
|
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
#=================================================
|
||||||
|
# UPGRADE DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading dependencies..."
|
||||||
|
|
||||||
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
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
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC UPGRADE
|
||||||
|
#=================================================
|
||||||
|
# BUILD COUCHPOTATO
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Building CouchPotato..."
|
||||||
|
|
||||||
|
# Set permissions to app files
|
||||||
|
chown -R "$app": "$final_path"
|
||||||
|
|
||||||
|
pushd $final_path/
|
||||||
|
virtualenv -p $($final_path/.pythonz/bin/pythonz locate $python_version) ve2
|
||||||
|
ve2/bin/pip install --upgrade pyopenssl
|
||||||
|
ve2/bin/pip install cheetah
|
||||||
|
popd
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BUILD COUCHPOTATO
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Building CouchPotato..."
|
||||||
|
|
||||||
|
# Set permissions to app files
|
||||||
|
chown -R "$app": "$final_path"
|
||||||
|
|
||||||
|
pushd $final_path/
|
||||||
|
virtualenv -p $($final_path/.pythonz/bin/pythonz locate $python_version) ve2
|
||||||
|
ve2/bin/pip install --upgrade pyopenssl
|
||||||
|
ve2/bin/pip install cheetah
|
||||||
|
popd
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INSTALL YUNOHOST MULTIMEDIA
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Install YunoHost multimedia..."
|
||||||
|
|
||||||
|
ynh_setup_source --dest_dir="$multimedia_final_path" -source_id=multimedia
|
||||||
|
$multimedia_final_path/script/ynh_media_build.sh
|
||||||
|
|
||||||
|
# Give write access to the yunohost.multimedia directory so that Couchpotato can move Movies to the Movie directory
|
||||||
|
usermod -a -G multimedia $app
|
||||||
|
|
||||||
|
# Creates the "Movies" subfolder in "Video"
|
||||||
|
mkdir -p "/home/yunohost.multimedia/share/Video/Movies"
|
||||||
|
|
||||||
|
# Fix permissions
|
||||||
|
$multimedia_final_path/script/ynh_media_build.sh
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CONFIGURE LOGS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring logs..."
|
||||||
|
|
||||||
|
# Redirect logs directory
|
||||||
|
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 LOGROTATE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading logrotate configuration..."
|
||||||
|
|
||||||
|
# Use logrotate to manage app-specific logfile(s)
|
||||||
|
ynh_use_logrotate --non-append
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SYSTEMD
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading systemd configuration..."
|
||||||
|
|
||||||
|
# Create a dedicated systemd config
|
||||||
|
ynh_add_systemd_config --others_var="app_data_dir"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# 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
|
# Open the /api path so that external applications can connect
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/api"
|
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/api"
|
||||||
|
|
||||||
# Reload Nginx and regenerate SSOwat conf
|
#=================================================
|
||||||
sudo service nginx reload
|
# START SYSTEMD SERVICE
|
||||||
sudo yunohost app ssowatconf
|
#=================================================
|
||||||
|
ynh_script_progression --message="Starting a systemd service..."
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading nginx web server..."
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Upgrade of $app completed"
|
||||||
|
|
Loading…
Add table
Reference in a new issue