mirror of
https://github.com/YunoHost-Apps/kodi_ynh.git
synced 2024-09-03 19:26:34 +02:00
commit
9b33ca6627
23 changed files with 737 additions and 413 deletions
55
.github/ISSUE_TEMPLATE.md
vendored
Normal file
55
.github/ISSUE_TEMPLATE.md
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
---
|
||||
name: Bug report
|
||||
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 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
|
||||
|
||||
*A clear and concise description of what the bug is.*
|
||||
|
||||
### 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 | ...*
|
||||
- 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`*
|
||||
|
||||
### Steps to reproduce
|
||||
|
||||
- *If you performed a command from the CLI, the command itself is enough. For example:*
|
||||
```sh
|
||||
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 '...'*
|
||||
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
|
||||
|
||||
*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)
|
66
README.md
66
README.md
|
@ -1,35 +1,47 @@
|
|||
Kodi for YunoHost
|
||||
---------------------
|
||||
<!--
|
||||
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
|
||||
It shall NOT be edited by hand.
|
||||
-->
|
||||
|
||||
**This package is currently under development, install it at your own risk.**
|
||||
# Kodi for YunoHost
|
||||
|
||||
[Kodi](https://kodi.tv) transform your YunoHost server on media center that is designed to look great on your big screen TV but is just as home on a small screen.
|
||||
[![Integration level](https://dash.yunohost.org/integration/kodi.svg)](https://dash.yunohost.org/appci/app/kodi) ![](https://ci-apps.yunohost.org/ci/badges/kodi.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/kodi.maintain.svg)
|
||||
[![Install Kodi with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=kodi)
|
||||
|
||||
**Shipped version:**
|
||||
* 16.1 on Debian from jessie backports
|
||||
* 17.3 on Raspberry from official raspbian repo
|
||||
*[Lire ce readme en français.](./README_fr.md)*
|
||||
|
||||
[![Install Kodi with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=kodi)
|
||||
> *This package allows you to install Kodi quickly and simply on a YunoHost server.
|
||||
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
|
||||
|
||||
## Current package status
|
||||
* The scprit use jessie backports to install Kodi 16 on x86 machines (We have to wait for YunoHost Debian Strech support or use testing source)
|
||||
* A dedicated kodi user is create
|
||||
* Use of systemd
|
||||
* You can launch Kodi with the ```sudo systemctl start kodi``` command or stop Kodi with ```sudo systemctl stop kodi```
|
||||
* You can choose if you want that Kodi start at YunoHost server statup
|
||||
* You can access to the control web interface from the YunoHost pannel
|
||||
* Kodi directly start after package installation
|
||||
* Start and stop Kodi from Admin YunoHost services tab
|
||||
* SSOWat pannel
|
||||
## Overview
|
||||
|
||||
## To do
|
||||
* Test control web interface on Raspberry
|
||||
* Switch from skipped_uri to protected_uri and try if it still works for jsonrpc and image location
|
||||
* Check if webserver port (8080) is free
|
||||
Transform your YunoHost server into media center with Kodi
|
||||
|
||||
## Links
|
||||
**Shipped version:** 17.3~ynh1
|
||||
|
||||
* Report a bug: Use GitHub issues or dedicated forum
|
||||
* YunoHost forum thread: [Kodi package](https://forum.yunohost.org/t/kodi-package-yunohost-as-a-media-center/3561/17)
|
||||
* Kodi website: https://kodi.tv
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
||||
|
||||
## Screenshots
|
||||
|
||||
![](./doc/screenshots/screenshot1.gif)
|
||||
|
||||
## Documentation and resources
|
||||
|
||||
* Official app website: https://kodi.tv
|
||||
* Official admin documentation: https://kodi.wiki/view/Main_Page
|
||||
* Upstream app code repository: https://github.com/xbmc
|
||||
* YunoHost documentation for this app: https://yunohost.org/app_kodi
|
||||
* Report a bug: https://github.com/YunoHost-Apps/kodi_ynh/issues
|
||||
|
||||
## Developer info
|
||||
|
||||
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/kodi_ynh/tree/testing).
|
||||
|
||||
To try the testing branch, please proceed like that.
|
||||
```
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/kodi_ynh/tree/testing --debug
|
||||
or
|
||||
sudo yunohost app upgrade kodi -u https://github.com/YunoHost-Apps/kodi_ynh/tree/testing --debug
|
||||
```
|
||||
|
||||
**More info regarding app packaging:** https://yunohost.org/packaging_apps
|
43
README_fr.md
Normal file
43
README_fr.md
Normal file
|
@ -0,0 +1,43 @@
|
|||
# Kodi pour YunoHost
|
||||
|
||||
[![Niveau d'intégration](https://dash.yunohost.org/integration/kodi.svg)](https://dash.yunohost.org/appci/app/kodi) ![](https://ci-apps.yunohost.org/ci/badges/kodi.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/kodi.maintain.svg)
|
||||
[![Installer Kodi avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=kodi)
|
||||
|
||||
*[Read this readme in english.](./README.md)*
|
||||
*[Lire ce readme en français.](./README_fr.md)*
|
||||
|
||||
> *Ce package vous permet d'installer Kodi rapidement et simplement sur un serveur YunoHost.
|
||||
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
|
||||
|
||||
## Vue d'ensemble
|
||||
|
||||
Transfromez votre serveur YunoHost en media center avec Kodi
|
||||
|
||||
**Version incluse :** 17.3~ynh1
|
||||
|
||||
|
||||
|
||||
## Captures d'écran
|
||||
|
||||
![](./doc/screenshots/screenshot1.gif)
|
||||
|
||||
## Documentations et ressources
|
||||
|
||||
* Site officiel de l'app : https://kodi.tv
|
||||
* Documentation officielle de l'admin : https://kodi.wiki/view/Main_Page
|
||||
* Dépôt de code officiel de l'app : https://github.com/xbmc
|
||||
* Documentation YunoHost pour cette app : https://yunohost.org/app_kodi
|
||||
* Signaler un bug : https://github.com/YunoHost-Apps/kodi_ynh/issues
|
||||
|
||||
## Informations pour les développeurs
|
||||
|
||||
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/kodi_ynh/tree/testing).
|
||||
|
||||
Pour essayer la branche testing, procédez comme suit.
|
||||
```
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/kodi_ynh/tree/testing --debug
|
||||
ou
|
||||
sudo yunohost app upgrade kodi -u https://github.com/YunoHost-Apps/kodi_ynh/tree/testing --debug
|
||||
```
|
||||
|
||||
**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps
|
|
@ -1,12 +1,7 @@
|
|||
;; Test complet
|
||||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/path" (PATH)
|
||||
admin="john" (USER)
|
||||
language="fr"
|
||||
is_public=1 (PUBLIC|public=1|private=0)
|
||||
password="password"
|
||||
port="666" (PORT)
|
||||
domain="domain.tld"
|
||||
path="/path"
|
||||
launch_on_boot=1
|
||||
open_webserver_port=1
|
||||
; Checks
|
||||
|
@ -14,25 +9,16 @@
|
|||
setup_sub_dir=1
|
||||
setup_root=1
|
||||
setup_nourl=0
|
||||
setup_private=1
|
||||
setup_private=0
|
||||
setup_public=1
|
||||
upgrade=0
|
||||
upgrade=1
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
incorrect_path=1
|
||||
port_already_use=1 (8080)
|
||||
change_url=1
|
||||
;;; Levels
|
||||
Level 1=auto
|
||||
Level 2=auto
|
||||
Level 3=auto
|
||||
Level 4=0
|
||||
Level 5=auto
|
||||
Level 6=auto
|
||||
Level 7=auto
|
||||
Level 8=0
|
||||
Level 9=0
|
||||
Level 10=0
|
||||
port_already_use=0
|
||||
change_url=0
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=all
|
||||
Notification=none
|
||||
;;; Upgrade options
|
||||
; commit=CommitHash
|
||||
name=Name and date of the commit.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<services>
|
||||
<esallinterfaces>true</esallinterfaces>
|
||||
<webserver>true</webserver>
|
||||
<webserverport>__PORT__</webserverport>
|
||||
<zeroconf>true</zeroconf>
|
||||
</services>
|
||||
</advancedsettings>
|
7
conf/arm-chorus2.src
Normal file
7
conf/arm-chorus2.src
Normal file
|
@ -0,0 +1,7 @@
|
|||
SOURCE_URL=https://github.com/xbmc/chorus2/releases/download/2.4.4/webinterface.default.2.4.4.zip
|
||||
SOURCE_SUM=efa76c18a155f263183df9eaa345e859f017000da064c35ec9809ff5c09e31c4
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=zip
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_FILENAME=
|
||||
SOURCE_EXTRACT=true
|
7
conf/deb-multimedia-keyring.src
Normal file
7
conf/deb-multimedia-keyring.src
Normal file
|
@ -0,0 +1,7 @@
|
|||
SOURCE_URL=http://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/deb-multimedia-keyring_2016.8.1_all.deb
|
||||
SOURCE_SUM=9faa6f6cba80aeb69c9bac139b74a3d61596d4486e2458c2c65efe9e21ff3c7d
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=deb
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_FILENAME=deb-multimedia-keyring.deb
|
||||
SOURCE_EXTRACT=false
|
|
@ -1,7 +1,6 @@
|
|||
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
||||
location __PATH__/ {
|
||||
rewrite ^__PATH__/jsonrpc(.*) /jsonrpc$uri;
|
||||
rewrite ^__PATH__/image/(.*) /image/$uri;
|
||||
proxy_pass http://127.0.0.1:8080/;
|
||||
proxy_pass http://127.0.0.1:__PORT__/;
|
||||
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
|
@ -12,14 +11,3 @@ location __PATH__/ {
|
|||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
}
|
||||
|
||||
# For kodi
|
||||
# Shouldn't need this when proxy headers are turned on. No idea why it does not work (Settings -> Web interface -> Reverse proxy support)
|
||||
location ~ ^/(image|jsonrpc) {
|
||||
proxy_pass http://127.0.0.1:8080;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
}
|
|
@ -1,21 +1,21 @@
|
|||
[Unit]
|
||||
Description = Kodi Media Center
|
||||
Description=Kodi Media Center
|
||||
|
||||
# if you don't need the MySQL DB backend, this should be sufficient
|
||||
After = systemd-user-sessions.service network.target sound.target
|
||||
After=systemd-user-sessions.service network.target sound.target
|
||||
|
||||
# if you need the MySQL DB backend, use this block instead of the previous
|
||||
# After = systemd-user-sessions.service network.target sound.target mysql.service
|
||||
# Wants = mysql.service
|
||||
|
||||
[Service]
|
||||
User = __APP__
|
||||
Group = __APP__
|
||||
Type = simple
|
||||
#PAMName = login # you might want to try this one, did not work on all systems
|
||||
ExecStart = /usr/bin/xinit /usr/bin/dbus-launch --exit-with-session /usr/bin/kodi-standalone -- :0 -nolisten tcp vt7
|
||||
Restart = on-abort
|
||||
Type=simple
|
||||
User=__APP__
|
||||
Group=__APP__
|
||||
#PAMName=login # you might want to try this one, did not work on all systems
|
||||
ExecStart=/usr/bin/xinit /usr/bin/dbus-launch --exit-with-session /usr/bin/kodi -- :0 -nolisten tcp vt7
|
||||
Restart=on-abort
|
||||
RestartSec = 5
|
||||
|
||||
[Install]
|
||||
WantedBy = multi-user.target
|
||||
WantedBy=multi-user.target
|
||||
|
|
21
conf/xorg.conf
Normal file
21
conf/xorg.conf
Normal file
|
@ -0,0 +1,21 @@
|
|||
Section "Device"
|
||||
Identifier "Configured Video Device"
|
||||
Driver "dummy"
|
||||
EndSection
|
||||
|
||||
Section "Monitor"
|
||||
Identifier "Configured Monitor"
|
||||
HorizSync 31.5-48.5
|
||||
VertRefresh 50-70
|
||||
EndSection
|
||||
|
||||
Section "Screen"
|
||||
Identifier "Default Screen"
|
||||
Monitor "Configured Monitor"
|
||||
Device "Configured Video Device"
|
||||
DefaultDepth 24
|
||||
SubSectionSub "Display"
|
||||
Depth 24
|
||||
Modes "1024x800"
|
||||
EndSubSection
|
||||
EndSection
|
0
doc/.gitkeep
Normal file
0
doc/.gitkeep
Normal file
0
doc/DISCLAIMER.md
Normal file
0
doc/DISCLAIMER.md
Normal file
0
doc/screenshots/.gitkeep
Normal file
0
doc/screenshots/.gitkeep
Normal file
BIN
doc/screenshots/screenshot1.gif
Normal file
BIN
doc/screenshots/screenshot1.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.6 MiB |
|
@ -6,8 +6,14 @@
|
|||
"en": "Transform your YunoHost server into media center with Kodi",
|
||||
"fr": "Transfromez votre serveur YunoHost en media center avec Kodi"
|
||||
},
|
||||
"version": "17.3",
|
||||
"version": "17.3~ynh1",
|
||||
"url": "https://kodi.tv",
|
||||
"upstream": {
|
||||
"license": "GPL-2.0",
|
||||
"website": "https://kodi.tv",
|
||||
"admindoc": "https://kodi.wiki/view/Main_Page",
|
||||
"code": "https://github.com/xbmc"
|
||||
},
|
||||
"license": "GPL-2.0",
|
||||
"maintainer": {
|
||||
"name": "Sylvain Cecchetto",
|
||||
|
@ -15,7 +21,7 @@
|
|||
"url": "blog.cecchettosylvain.fr"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 2.6.4"
|
||||
"yunohost": ">= 4.1.3"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
|
@ -26,19 +32,11 @@
|
|||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain for the control web interface",
|
||||
"fr": "Choisissez un nom de domaine pour l'interface de contrôle web"
|
||||
},
|
||||
"example": "example.com"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"type": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path for the control web interface",
|
||||
"fr": "Choisissez un chemin pour l'interface de contrôle web"
|
||||
},
|
||||
"example": "/kodi",
|
||||
"default": "/kodi"
|
||||
},
|
||||
|
|
|
@ -1 +1,24 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies="xorg xinit dbus-x11 kodi"
|
||||
|
||||
arm_pkg_dependencies="xserver-xorg-legacy xorg dbus-x11 kodi"
|
||||
|
||||
package_check_dependencies="xserver-xorg-video-dummy"
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -6,55 +6,57 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
if [ ! -e _common.sh ]; then
|
||||
# Get the _common.sh file if it's not in the current directory
|
||||
cp ../settings/scripts/_common.sh ./_common.sh
|
||||
chmod a+rx _common.sh
|
||||
fi
|
||||
|
||||
source _common.sh
|
||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# 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
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path_url=$(ynh_app_setting_get "$app" path)
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
launch_on_boot=$(ynh_app_setting_get "$app" launch_on_boot)
|
||||
open_webserver_port=$(ynh_app_setting_get "$app" open_webserver_port)
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_backup "$final_path"
|
||||
|
||||
ynh_backup --src_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_backup "/etc/systemd/system/$app.service"
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SOURCE FILE
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
if [ -f "/etc/apt/sources.list.d/${app}.list" ] ; then
|
||||
ynh_backup "/etc/apt/sources.list.d/${app}.list"
|
||||
fi
|
||||
|
||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
225
scripts/install
225
scripts/install
|
@ -5,146 +5,207 @@
|
|||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source ynh_detect_arch__2
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
is_public=1
|
||||
launch_on_boot=$YNH_APP_ARG_LAUNCH_ON_BOOT
|
||||
open_webserver_port=$YNH_APP_ARG_OPEN_WEBSERVER_PORT
|
||||
arch=$(ynh_detect_arch)
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# GLOBAL VARS
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
arch=$(uname -m)
|
||||
ynh_script_progression --message="Validating installation parameters..."
|
||||
|
||||
final_path=/var/www/$app
|
||||
chorus2_package="https://github.com/xbmc/chorus2/releases/download/2.4.4/webinterface.default.2.4.4.zip"
|
||||
|
||||
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
|
||||
# Normalize the url path syntax
|
||||
path_url=$(ynh_normalize_url_path "$path_url")
|
||||
|
||||
# Check web path availability
|
||||
ynh_webpath_available "$domain" "$path_url"
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register "$app" "$domain" "$path_url"
|
||||
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_app_setting_set "$app" domain "$domain"
|
||||
ynh_app_setting_set "$app" path_url "$path_url"
|
||||
ynh_app_setting_set "$app" final_path "$final_path"
|
||||
ynh_app_setting_set "$app" launch_on_boot "$launch_on_boot"
|
||||
ynh_app_setting_set "$app" open_webserver_port "$open_webserver_port"
|
||||
ynh_script_progression --message="Storing installation settings..."
|
||||
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
ynh_app_setting_set --app=$app --key=launch_on_boot --value=$launch_on_boot
|
||||
ynh_app_setting_set --app=$app --key=open_webserver_port --value=$open_webserver_port
|
||||
|
||||
#=================================================
|
||||
# CREATE KODI USER
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
ynh_system_user_create "$app" "$final_path"
|
||||
sudo mkdir "$final_path"
|
||||
sudo chown -R "$app":"$app" "$final_path"
|
||||
sudo usermod -a -G cdrom,audio,video,plugdev,users,dialout,dip,input,netdev "$app"
|
||||
# FIND AND OPEN A PORT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Finding an available port..."
|
||||
|
||||
# Find an available port
|
||||
port=$(ynh_find_port --port=8095)
|
||||
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_script_progression --message="Configuring firewall..."
|
||||
if [ "$open_webserver_port" -eq 1 ]
|
||||
then
|
||||
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# ADD SYSTEMD CONFIG
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..."
|
||||
|
||||
tmpdir=$(mktemp -d)
|
||||
ynh_setup_source --dest_dir="$tmpdir" --source_id="deb-multimedia-keyring"
|
||||
dpkg -i "$tmpdir/deb-multimedia-keyring.deb"
|
||||
|
||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||
pkg_dependencies="$pkg_dependencies $package_check_dependencies"
|
||||
fi
|
||||
|
||||
if [[ $arch != arm* ]]; then
|
||||
ynh_install_extra_app_dependencies --repo="deb https://www.deb-multimedia.org/ buster main non-free" --package="$pkg_dependencies"
|
||||
else
|
||||
ynh_install_extra_app_dependencies --repo="deb https://www.deb-multimedia.org/ buster main non-free" --package="$arm_pkg_dependencies"
|
||||
fi
|
||||
|
||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||
cp ../conf/xorg.conf /etc/X11/xorg.conf
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..."
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring NGINX web server..."
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# X11 SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring X11..."
|
||||
|
||||
ynh_replace_string --match_string="allowed_users=console" --replace_string="allowed_users=anybody" --target_file="/etc/X11/Xwrapper.config"
|
||||
|
||||
#=================================================
|
||||
# CONFUGURING KODI
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring Kodi..."
|
||||
|
||||
mkdir -p "$final_path/.kodi/userdata/"
|
||||
ynh_add_config --template="../conf/advancedsettings.xml" --destination="$final_path/.kodi/userdata/advancedsettings.xml"
|
||||
|
||||
mkdir -p "$final_path/.kodi/addons/"
|
||||
if [[ $arch != arm* ]]; then
|
||||
ynh_setup_source --dest_dir="$final_path/.kodi/addons/" --source_id="arm-chorus2"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..."
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
if [ "$launch_on_boot" -eq 0 ]
|
||||
then
|
||||
sudo systemctl disable "$app"
|
||||
systemctl disable "$app" --quiet
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Securing files and directories..."
|
||||
|
||||
# Set permissions to app files
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
usermod -a -G cdrom,audio,video,plugdev,users,dialout,dip,input,netdev "$app"
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES AND KODI
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
if [[ $arch != arm* ]]; then
|
||||
ynh_package_update
|
||||
ynh_package_install xorg xinit dbus-x11 kodi
|
||||
else
|
||||
ynh_package_update
|
||||
ynh_package_install xserver-xorg-legacy xorg dbus-x11 kodi
|
||||
fi
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --log "$final_path/.kodi/temp/kodi.log" --needs_exposed_ports $port
|
||||
|
||||
#=================================================
|
||||
# X11 SETTINGS
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
sudo sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start"
|
||||
|
||||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
yunohost service add "$app" --log "$final_path/.kodi/temp/kodi.log"
|
||||
|
||||
|
||||
#=================================================
|
||||
# CONTROL WEB INTERFACE
|
||||
#=================================================
|
||||
sudo mkdir -p "$final_path/.kodi/userdata/"
|
||||
sudo cp ../conf/advancedsettings.xml "$final_path/.kodi/userdata/advancedsettings.xml"
|
||||
|
||||
if [[ $arch != arm* ]]; then
|
||||
sudo wget -q $chorus2_package -P /tmp
|
||||
sudo unzip /tmp/webinterface.default.2.4.4.zip -d /tmp/
|
||||
sudo mkdir -p "$final_path/.kodi/addons/"
|
||||
sudo mv /tmp/webinterface.default/ "$final_path/.kodi/addons/webinterface.chorus2/"
|
||||
fi
|
||||
|
||||
sudo chown -R "$app":"$app" "$final_path"
|
||||
|
||||
if [ "$open_webserver_port" -eq 1 ]
|
||||
then
|
||||
yunohost firewall allow --no-upnp TCP 8080 2>&1
|
||||
fi
|
||||
|
||||
|
||||
#=================================================
|
||||
# NGINX
|
||||
#=================================================
|
||||
finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup_if_checksum_is_different "$finalnginxconf"
|
||||
sudo cp ../conf/nginx.conf "$finalnginxconf"
|
||||
|
||||
if [ "$path_url" == "/" ]; then
|
||||
ynh_replace_string "__PATH__/" "/" "$finalnginxconf"
|
||||
else
|
||||
ynh_replace_string "__PATH__" "$path_url" "$finalnginxconf"
|
||||
fi
|
||||
ynh_script_progression --message="Configuring permissions..."
|
||||
|
||||
ynh_app_setting_set "$app" protected_uris "/"
|
||||
|
||||
domainregex=$(echo "$domain" | sed 's/-/\%&/g')
|
||||
ynh_app_setting_set "$app" skipped_regex "$domainregex/jsonrpc.*$,$domainregex/image.*$"
|
||||
|
||||
# Reload SSOwat config
|
||||
yunohost app ssowatconf
|
||||
|
||||
# Reload Nginx
|
||||
systemctl reload nginx
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
# Everyone can access the app.
|
||||
# The "main" permission is automatically created before the install script.
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# START KODI
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
sudo systemctl start "$app"
|
||||
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"
|
||||
|
|
122
scripts/remove
122
scripts/remove
|
@ -9,83 +9,97 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path_url=$(ynh_app_setting_get "$app" path)
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
launch_on_boot=$(ynh_app_setting_get "$app" launch_on_boot)
|
||||
open_webserver_port=$(ynh_app_setting_get "$app" open_webserver_port)
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
launch_on_boot=$(ynh_app_setting_get --app=$app --key=launch_on_boot)
|
||||
open_webserver_port=$(ynh_app_setting_get --app=$app --key=open_webserver_port)
|
||||
|
||||
#=================================================
|
||||
# GLOBAL VARS
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||
#=================================================
|
||||
arch=$(uname -m)
|
||||
|
||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app service integration..."
|
||||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE SYSTEMD SCRIPT (SERVICE)
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
# Stop and diasble Kodi service
|
||||
# Remove kodi.service file
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..."
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_remove_nginx_config
|
||||
|
||||
|
||||
#=================================================
|
||||
# CLOSE WEB SERVER PORT
|
||||
#=================================================
|
||||
if [ "$open_webserver_port" -eq 1 ]
|
||||
then
|
||||
yunohost firewall disallow TCP 8080 2>&1
|
||||
fi
|
||||
|
||||
|
||||
#=================================================
|
||||
# REMOVE SERVICE FROM ADMIN PANEL
|
||||
#=================================================
|
||||
if yunohost service status | grep -q "$app"
|
||||
then
|
||||
echo "Remove $app service"
|
||||
yunohost service remove "$app"
|
||||
fi
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
|
||||
#=================================================
|
||||
# X11 SETTINGS
|
||||
#=================================================
|
||||
sudo sed -i 's/allowed_users=anybody/allowed_users=console/' /etc/X11/Xwrapper.config
|
||||
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES AND KODI
|
||||
#=================================================
|
||||
if [[ $arch != arm* ]]; then
|
||||
ynh_package_remove xorg xinit dbus-x11 kodi
|
||||
ynh_secure_remove "/etc/apt/sources.list.d/${app}.list"
|
||||
ynh_package_update
|
||||
else
|
||||
ynh_package_remove xserver-xorg-legacy xorg dbus-x11 kodi
|
||||
fi
|
||||
ynh_script_progression --message="Removing dependencies..."
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app main directory..."
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove "$final_path"
|
||||
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 KODI USER
|
||||
# CLOSE A PORT
|
||||
#=================================================
|
||||
ynh_system_user_delete "$app"
|
||||
|
||||
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
|
||||
#=================================================
|
||||
# X11 SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring X11..."
|
||||
|
||||
ynh_replace_string "allowed_users=anybody" "allowed_users=console" /etc/X11/Xwrapper.config
|
||||
|
||||
#=================================================
|
||||
# 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"
|
||||
|
|
187
scripts/restore
187
scripts/restore
|
@ -1,140 +1,173 @@
|
|||
#!/bin/bash
|
||||
|
||||
# MEMO TO TEST THIS SCRIPT
|
||||
# yunohost backup create --ignore-system --apps kodi
|
||||
# yunohost app remove kodi
|
||||
# yunohost backup restore backup.tar
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
if [ ! -e _common.sh ]; then
|
||||
# Get the _common.sh file if it's not in the current directory
|
||||
cp ../settings/scripts/_common.sh ./_common.sh
|
||||
chmod a+rx _common.sh
|
||||
fi
|
||||
source _common.sh
|
||||
# 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_detect_arch__2
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
||||
#=================================================
|
||||
# GLOBAL VARS
|
||||
#=================================================
|
||||
arch=$(uname -m)
|
||||
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path_url=$(ynh_app_setting_get "$app" path)
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
launch_on_boot=$(ynh_app_setting_get "$app" launch_on_boot)
|
||||
open_webserver_port=$(ynh_app_setting_get "$app" open_webserver_port)
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
launch_on_boot=$(ynh_app_setting_get --app=$app --key=launch_on_boot)
|
||||
open_webserver_port=$(ynh_app_setting_get --app=$app --key=open_webserver_port)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
arch=$(ynh_detect_arch)
|
||||
|
||||
#=================================================
|
||||
# FIND AND OPEN A PORT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Finding an available port..."
|
||||
|
||||
# Open the port
|
||||
# ynh_script_progression --message="Configuring firewall..."
|
||||
if [ "$open_webserver_port" -eq 1 ]
|
||||
then
|
||||
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_webpath_available "$domain" "$path_url" \
|
||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||
test ! -d "$final_path" \
|
||||
|| ynh_die "There is already a directory: $final_path "
|
||||
ynh_script_progression --message="Validating restoration parameters..."
|
||||
|
||||
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 "
|
||||
|
||||
#=================================================
|
||||
# CREATE KODI USER
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
ynh_system_user_create "$app" "$final_path"
|
||||
sudo mkdir "$final_path"
|
||||
sudo chown -R "$app":"$app" "$final_path"
|
||||
sudo usermod -a -G cdrom,audio,video,plugdev,users,dialout,dip,input,netdev "$app"
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..."
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_restore_file "$final_path"
|
||||
# Restore permissions on app files
|
||||
chown -R "$app":"$app" "$final_path"
|
||||
ynh_script_progression --message="Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..."
|
||||
|
||||
tmpdir=$(mktemp -d)
|
||||
ynh_setup_source --dest_dir="$tmpdir" --source_id="deb-multimedia-keyring"
|
||||
dpkg -i "$tmpdir/deb-multimedia-keyring.deb"
|
||||
|
||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||
pkg_dependencies="$pkg_dependencies $package_check_dependencies"
|
||||
fi
|
||||
|
||||
if [[ $arch != arm* ]]; then
|
||||
ynh_install_extra_app_dependencies --repo="deb https://www.deb-multimedia.org/ buster main non-free" --package="$pkg_dependencies"
|
||||
else
|
||||
ynh_install_extra_app_dependencies --repo="deb https://www.deb-multimedia.org/ buster main non-free" --package="$arm_pkg_dependencies"
|
||||
fi
|
||||
|
||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||
cp ../settings/conf/xorg.conf /etc/X11/xorg.conf
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
ynh_restore_file "/etc/systemd/system/$app.service"
|
||||
|
||||
|
||||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
#=================================================
|
||||
yunohost service add "$app" --log "$final_path/.kodi/temp/kodi.log"
|
||||
ynh_script_progression --message="Restoring the systemd configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service --quiet
|
||||
|
||||
#=================================================
|
||||
# RESTORE LAUNCH ON BOOT
|
||||
#=================================================
|
||||
if [ "$launch_on_boot" -eq 0 ]
|
||||
then
|
||||
sudo systemctl disable "$app"
|
||||
systemctl disable "$app".service --quiet
|
||||
else
|
||||
systemctl enable "$app".service
|
||||
systemctl enable "$app".service --quiet
|
||||
fi
|
||||
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES AND KODI
|
||||
#=================================================
|
||||
if [[ $arch != arm* ]]; then
|
||||
ynh_restore_file "/etc/apt/sources.list.d/${app}.list"
|
||||
ynh_package_update
|
||||
ynh_package_install xorg xinit dbus-x11 kodi
|
||||
else
|
||||
ynh_package_update
|
||||
ynh_package_install xserver-xorg-legacy xorg dbus-x11 kodi
|
||||
fi
|
||||
|
||||
|
||||
#=================================================
|
||||
# X11 SETTINGS
|
||||
#=================================================
|
||||
sudo sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config
|
||||
ynh_script_progression --message="Configuring X11..."
|
||||
|
||||
ynh_replace_string "allowed_users=console" "allowed_users=anybody" /etc/X11/Xwrapper.config
|
||||
|
||||
#=================================================
|
||||
# CONTROL WEB INTERFACE
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
if [ "$open_webserver_port" -eq 1 ]
|
||||
then
|
||||
yunohost firewall allow --no-upnp TCP 8080 2>&1
|
||||
fi
|
||||
|
||||
|
||||
# Reload SSOwat config
|
||||
yunohost app ssowatconf
|
||||
|
||||
# Reload Nginx
|
||||
systemctl reload nginx
|
||||
ynh_script_progression --message="Restoring user rights..."
|
||||
|
||||
# Restore permissions on app files
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
usermod -a -G cdrom,audio,video,plugdev,users,dialout,dip,input,netdev "$app"
|
||||
|
||||
#=================================================
|
||||
# START KODI
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
sudo systemctl start "$app"
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --log "$final_path/.kodi/temp/kodi.log" --needs_exposed_ports $port
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start"
|
||||
|
||||
#=================================================
|
||||
# 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"
|
||||
|
|
208
scripts/upgrade
208
scripts/upgrade
|
@ -5,137 +5,169 @@
|
|||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
source _common.sh
|
||||
source ynh_detect_arch__2
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path_url=$(ynh_app_setting_get "$app" path)
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
launch_on_boot=$(ynh_app_setting_get "$app" launch_on_boot)
|
||||
open_webserver_port=$(ynh_app_setting_get "$app" open_webserver_port)
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
launch_on_boot=$(ynh_app_setting_get --app=$app --key=launch_on_boot)
|
||||
open_webserver_port=$(ynh_app_setting_get --app=$app --key=open_webserver_port)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
arch=$(ynh_detect_arch)
|
||||
|
||||
#=================================================
|
||||
# GLOBAL VARS
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
arch=$(uname -m)
|
||||
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
# Fix launch_on_boot as a boolean value
|
||||
if [ "$launch_on_boot" = "Yes" ]; then
|
||||
ynh_app_setting_set "$app" launch_on_boot 1
|
||||
launch_on_boot=1
|
||||
elif [ "$launch_on_boot" = "No" ]; then
|
||||
ynh_app_setting_set "$app" launch_on_boot 0
|
||||
launch_on_boot=0
|
||||
fi
|
||||
|
||||
# Fix launch_on_boot as a boolean value
|
||||
if [ "$open_webserver_port" = "Yes" ]; then
|
||||
ynh_app_setting_set "$app" open_webserver_port 1
|
||||
open_webserver_port=1
|
||||
elif [ "$open_webserver_port" = "No" ]; then
|
||||
ynh_app_setting_set "$app" open_webserver_port 0
|
||||
open_webserver_port=0
|
||||
fi
|
||||
|
||||
|
||||
#=================================================
|
||||
# STOP KODI
|
||||
#=================================================
|
||||
sudo systemctl stop "$app"
|
||||
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
|
||||
# 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"
|
||||
|
||||
#=================================================
|
||||
# REPLACE SYSTEMD CONFIG
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
# Fix launch_on_boot as a boolean value
|
||||
if [ "$launch_on_boot" = "Yes" ]; then
|
||||
ynh_app_setting_set --app=$app --key=launch_on_boot --value=1
|
||||
launch_on_boot=1
|
||||
elif [ "$launch_on_boot" = "No" ]; then
|
||||
ynh_app_setting_set --app=$app --key=launch_on_boot --value=0
|
||||
launch_on_boot=0
|
||||
fi
|
||||
|
||||
# Fix launch_on_boot as a boolean value
|
||||
if [ "$open_webserver_port" = "Yes" ]; then
|
||||
ynh_app_setting_set --app=$app --key=open_webserver_port --value=1
|
||||
open_webserver_port=1
|
||||
elif [ "$open_webserver_port" = "No" ]; then
|
||||
ynh_app_setting_set --app=$app --key=open_webserver_port --value=0
|
||||
open_webserver_port=0
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
|
||||
#=================================================
|
||||
# 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..."
|
||||
|
||||
tmpdir=$(mktemp -d)
|
||||
ynh_setup_source --dest_dir="$tmpdir" --source_id="deb-multimedia-keyring"
|
||||
dpkg -i "$tmpdir/deb-multimedia-keyring.deb"
|
||||
|
||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||
pkg_dependencies="$pkg_dependencies $package_check_dependencies"
|
||||
fi
|
||||
|
||||
if [[ $arch != arm* ]]; then
|
||||
ynh_install_extra_app_dependencies --repo="deb https://www.deb-multimedia.org/ buster main non-free" --package="$pkg_dependencies"
|
||||
else
|
||||
ynh_install_extra_app_dependencies --repo="deb https://www.deb-multimedia.org/ buster main non-free" --package="$arm_pkg_dependencies"
|
||||
fi
|
||||
|
||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||
cp ../conf/xorg.conf /etc/X11/xorg.conf
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading systemd configuration..."
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Securing files and directories..."
|
||||
|
||||
# Set permissions on app files
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
usermod -a -G cdrom,audio,video,plugdev,users,dialout,dip,input,netdev "$app"
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES AND KODI
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
if [[ "$arch" != arm* ]]; then
|
||||
ynh_package_update
|
||||
ynh_package_install xorg xinit dbus-x11 kodi
|
||||
else
|
||||
ynh_package_update
|
||||
ynh_package_install xserver-xorg-legacy xorg dbus-x11 kodi
|
||||
|
||||
fi
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --log "$final_path/.kodi/temp/kodi.log" --needs_exposed_ports $port
|
||||
|
||||
#=================================================
|
||||
# X11 SETTINGS
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
sudo sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start"
|
||||
|
||||
#=================================================
|
||||
# CONTROL WEB INTERFACE
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
if [ $open_webserver_port -eq 1 ]
|
||||
then
|
||||
yunohost firewall allow --no-upnp TCP 8080 2>&1
|
||||
fi
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# NGINX
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup_if_checksum_is_different "$finalnginxconf"
|
||||
sudo cp ../conf/nginx.conf "$finalnginxconf"
|
||||
|
||||
if [ "$path_url" == "/" ]; then
|
||||
ynh_replace_string "__PATH__/" "/" "$finalnginxconf"
|
||||
else
|
||||
ynh_replace_string "__PATH__" "$path_url" "$finalnginxconf"
|
||||
fi
|
||||
|
||||
ynh_app_setting_set "$app" protected_uris "/"
|
||||
|
||||
domainregex=$(echo "$domain" | sed 's/-/\%&/g')
|
||||
ynh_app_setting_set "$app" skipped_regex "$domainregex/jsonrpc.*$,$domainregex/image.*$"
|
||||
|
||||
# Reload SSOwat config
|
||||
yunohost app ssowatconf
|
||||
|
||||
# Reload Nginx
|
||||
systemctl reload nginx
|
||||
|
||||
|
||||
|
||||
#=================================================
|
||||
# START KODI
|
||||
#=================================================
|
||||
sudo systemctl start "$app"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed"
|
||||
|
|
25
scripts/ynh_detect_arch__2
Normal file
25
scripts/ynh_detect_arch__2
Normal file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Check the architecture
|
||||
#
|
||||
# example: architecture=$(ynh_detect_arch)
|
||||
#
|
||||
# usage: ynh_detect_arch
|
||||
#
|
||||
# Requires YunoHost version 2.2.4 or higher.
|
||||
|
||||
ynh_detect_arch(){
|
||||
local architecture
|
||||
if [ -n "$(uname -m | grep arm64)" ] || [ -n "$(uname -m | grep aarch64)" ]; then
|
||||
architecture="arm64"
|
||||
elif [ -n "$(uname -m | grep 64)" ]; then
|
||||
architecture="x86-64"
|
||||
elif [ -n "$(uname -m | grep 86)" ]; then
|
||||
architecture="i386"
|
||||
elif [ -n "$(uname -m | grep arm)" ]; then
|
||||
architecture="arm"
|
||||
else
|
||||
architecture="unknown"
|
||||
fi
|
||||
echo $architecture
|
||||
}
|
Loading…
Reference in a new issue