1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/UMS_ynh.git synced 2024-10-01 13:35:01 +02:00

Merge pull request #1 from YunoHost-Apps/testing

Initial release
This commit is contained in:
Krakinou 2021-04-17 10:45:42 +02:00 committed by GitHub
commit 479d587fa0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 3250 additions and 0 deletions

11
.project Normal file
View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>UMS_ynh</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

91
README.md Normal file
View file

@ -0,0 +1,91 @@
# Universal Media Server (ums) YunoHost
[![Integration level](https://dash.yunohost.org/integration/ums.svg)](https://dash.yunohost.org/appci/app/ums) ![](https://ci-apps.yunohost.org/ci/badges/ums.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/ums.maintain.svg)
[![Install ums with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=ums)
Official website : [![https://www.universalmediaserver.com/](https://raw.githubusercontent.com/UniversalMediaServer/UniversalMediaServer/master/src/main/resources/images/logo.png)](https://www.universalmediaserver.com/)
*[Lire ce readme en français.](./README_fr.md)*
> *This package allows you to install ums 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.*
## Overview
Universal Media Server is a free DLNA, UPnP and HTTP/S Media Server supporting all major operating systems, with versions for Windows, Linux and macOS.
The program streams or transcodes many different media formats with little or no configuration.
It is powered by FFmpeg, MediaInfo, OpenSubtitles, Crowdin, MEncoder, tsMuxeR, AviSynth, VLC and more, which combine to offer support for a wide range of media formats.
It was originally based on PS3 Media Server by shagrath, and started by SubJunk, an official developer of PMS, in order to ensure greater stability and file-compatibility.
Upstream source code may be found [here](https://github.com/UniversalMediaServer/UniversalMediaServer)
**Shipped version:** 10.4.1
## Screenshots
![](Link to a screenshot of this app.)
## Configuration
Once installed, UMS will create config file in `/home/ums/.config/UMS/`
All settings are pretty well documented. You may change them from here.
## Documentation
* The [wiki](https://github.com/UniversalMediaServer/UniversalMediaServer/wiki) described main settings
* The [forum](https://www.universalmediaserver.com/forum/) has also a lot of info
## YunoHost specific features
#### Multi-user support
For now, the app support single instance only.
As there is no user management, LDAP is not requested.
The default setting will use the shared multimedia directory by default, you may change this setting in `/home/ums/.config/UMS/UMS.conf` with the setting "folders"
#### Supported architectures
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/ums.svg)](https://ci-apps.yunohost.org/ci/apps/ums/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/ums.svg)](https://ci-apps-arm.yunohost.org/ci/apps/ums/)
## Limitations
* Known limitations :
- No multiinstance
- work only on its own subdomain (ums.mydomain.tld, not on mydomain.tld/ums)
- No user management
- Not tested that much
## Additional information
I added the possibility to install vlc on installation. Beware! I addn't tested it and I'm not sure it is of any use for a headless server.
Moreover, it will download a full graphical UI, so not very useful on a server...
**More info on the documentation page:**
https://yunohost.org/packaging_apps
## Links
* Report a bug: https://github.com/YunoHost-Apps/ums_ynh/issues
* App website: [https://www.universalmediaserver.com](https://www.universalmediaserver.com/)
* Upstream app repository: [https://www.universalmediaserver.com/](https://www.universalmediaserver.com/)
* YunoHost website: https://yunohost.org/
---
## Developer info
**Only if you want to use a testing branch for coding, instead of merging directly into master.**
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/ums_ynh/tree/testing).
To try the testing branch, please proceed like that.
```
sudo yunohost app install https://github.com/YunoHost-Apps/ums_ynh/tree/testing --debug
or
sudo yunohost app upgrade ums -u https://github.com/YunoHost-Apps/ums_ynh/tree/testing --debug
```

87
README_fr.md Normal file
View file

@ -0,0 +1,87 @@
# Universal Media Server (ums) pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/ums.svg)](https://dash.yunohost.org/appci/app/ums) ![](https://ci-apps.yunohost.org/ci/badges/ums.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/ums.maintain.svg)
[![Installer ums avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=ums)
Site Web officiel : [![https://www.universalmediaserver.com/](https://raw.githubusercontent.com/UniversalMediaServer/UniversalMediaServer/master/src/main/resources/images/logo.png)](https://www.universalmediaserver.com/)
*[Read this readme in english.](./README.md)*
> *Ce package vous permet d'installer ums rapidement et simplement sur un serveur YunoHost.
Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.*
## Vue d'ensemble
Universal Media Server est un serveur DLNA, UPnp et HTTP/S libre supportant tous les grands systèmes d'exploitation, avec une version pour Windows, Linux et MacOS
Le programme stream ou transcode beaucoup de formats différents avec peu ou pas de configuration.
Il utilise by FFmpeg, MediaInfo, OpenSubtitles, Crowdin, MEncoder, tsMuxeR, AviSynth, VLC et d'autres, qiu'il combine pour permettre d'exploiter une grande variété de format.
Il était originellement basé sur PS3 Media Server de shagrath, et a été lancé par SubJunk, un développeur officiel de PMS, pour assurer la plus grande stabilité et compatiblité.
Le code du programme peut ^etre consulté [ici]](https://github.com/UniversalMediaServer/UniversalMediaServer)
**Version incluse :** 10.4.1
## Captures d'écran
![](Lien vers une capture d'écran de cette application.)
## Configuration
Une fois installé, tous les réglages peuvent etre trouver dans `/ums/.config/UMS/`
Les réglages sont plutot bien documentés, vous pouvez les changer directement dans le fichier.
## Documentation
* Le [wiki](https://github.com/UniversalMediaServer/UniversalMediaServer/wiki) décrit les principaux réglages.
* Le [forum](https://www.universalmediaserver.com/forum/) a également énormément d'info.
## Caractéristiques spécifiques YunoHost
#### Support multi-utilisateur
Pour l'instant, l'application supporte uniuqment un mode mono-instance.
Et comme elle ne gère pas d'utilisateur, il n'y a bien entendu pas de LDAP.
Le réglage par défaut partagera le répertoire multimedia partagé. Vous pouvez changer ce réglage dans le fichier `/home/ums/.config/UMS/UMS.conf` sur le réglage "folders".
#### Architectures supportées
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/ums.svg)](https://ci-apps.yunohost.org/ci/apps/ums/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/ums.svg)](https://ci-apps-arm.yunohost.org/ci/apps/ums/)
## Limitations
* Limitations connues:
- pas de multiinstance
- fonctionne uniquement en sous-domaine (ums.mydomain.tld, et non mydomain.tld/ums)
- pas de gestion d'utilisateur
- Pas énormément testée
## Informations additionnelles
J'ai rajouté la possibilité d'installer vlc lors de l'installation. ATTENTION, je ne l'ai pas testé et je ne suis pas sur que cela serve à quelque chose sur un serveur headless...
De plus, vlc requiert l'installation d'un environnement graphique complet.
**Plus d'informations sur la page de documentation :**
https://yunohost.org/packaging_apps
## Liens
* Signaler un bug : https://github.com/YunoHost-Apps/ums_ynh/issues
* Site de l'application : [https://www.universalmediaserver.com](https://www.universalmediaserver.com/)
* Dépôt de l'application principale :[ https://www.universalmediaserver.com/](https://www.universalmediaserver.com/)
* Site web YunoHost : https://yunohost.org/
---
## Informations pour les développeurs
**Seulement si vous voulez utiliser une branche de test pour le codage, au lieu de fusionner directement dans la banche principale.**
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/ums_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
```
sudo yunohost app install https://github.com/YunoHost-Apps/ums_ynh/tree/testing --debug
ou
sudo yunohost app upgrade ums -u https://github.com/YunoHost-Apps/ums_ynh/tree/testing --debug
```

27
check_process Normal file
View file

@ -0,0 +1,27 @@
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
is_public=1 (PUBLIC|public=1|private=0)
vlc=no
; Checks
pkg_linter=1
#Only work w/ root domain
setup_sub_dir=0
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
# upgrade=0 from_commit=CommitHash
backup_restore=1
multi_instance=0
port_already_use=0
change_url=0
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=CommitHash
name=Name and date of the commit.
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&

1758
conf/UMS.conf.default Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,12 @@
[
{
"name":"Virtual Folder Name",
"addToMediaLibrary":"true",
"files":["D:\\Path\\To\\Folder","D:\\Path\\To\\Another\\Folder"]
},
{
"name":"Another Virtual Folder Name",
"addToMediaLibrary":"true",
"files":["D:\\Path\\To\\Folder","D:\\Path\\To\\Another\\Folder"]
}
]

57
conf/WEB.conf.default Normal file
View file

@ -0,0 +1,57 @@
##########################################################################################################
# #
# WEB.conf: configure support for web feeds and streams #
# #
# NOTE: This file must be placed in the profile directory to work: #
# #
# http://www.ps3mediaserver.org/forum/viewtopic.php?f=6&t=3507&p=32731#p32731 #
# #
# Supported types: #
# #
# imagefeed, audiofeed, videofeed, audiostream, videostream #
# #
# Format for feeds: #
# #
# type.folders,separated,by,commas=URL #
# #
# Format for streams: #
# #
# type.folders,separated,by,commas=name for audio/video stream,URL,optional thumbnail URL #
# #
# For more web feed/stream options, see: #
# #
# http://www.ps3mediaserver.org/forum/viewtopic.php?f=6&t=3507&p=37084#p37084 #
# http://www.ps3mediaserver.org/forum/viewtopic.php?f=6&t=8776&p=46696#p46696 #
# #
##########################################################################################################
# image feeds
imagefeed.Web,Pictures=http://api.flickr.com/services/feeds/photos_public.gne?format=rss2
imagefeed.Web,Pictures=http://api.flickr.com/services/feeds/photos_public.gne?id=39453068@N05&format=rss2
imagefeed.Web,Pictures=http://api.flickr.com/services/feeds/photos_public.gne?id=14362684@N08&format=rss2
imagefeed.Web,Pictures=http://picasaweb.google.fr/data/feed/base/user/nefuisalbum/albumid/5218433104757705489?alt=rss&kind=photo&hl=en_US
imagefeed.Web,Pictures=http://picasaweb.google.com/data/feed/base/user/FenderStratRocker?alt=rss&kind=album&hl=en_US&access=public
# audio feeds
audiofeed.Web,Podcasts=https://rss.art19.com/caliphate
audiofeed.Web,Podcasts=https://www.nasa.gov/rss/dyn/Gravity-Assist.rss
audiofeed.Web,Podcasts=http://podcasts.joerogan.net/feed
audiofeed.Web,Podcasts=http://wakingup.libsyn.com/rss
audiofeed.Web,Podcasts=https://rss.art19.com/wolverine-the-long-night
# video feeds
videofeed.Web,Vodcasts=http://feeds.feedburner.com/tedtalks_video
videofeed.Web,Vodcasts=https://www.nasa.gov/rss/dyn/nasax_vodcast.rss
videofeed.Web,Vodcasts=https://www.unicef.org/rss/unicef_television_vodcast.xml
videofeed.Web,YouTube Channels=https://www.youtube.com/feeds/videos.xml?channel_id=UC0PEAMcRK7Mnn2G1bCBXOWQ
videofeed.Web,YouTube Channels=https://www.youtube.com/feeds/videos.xml?channel_id=UCccjdJEay2hpb5scz61zY6Q
videofeed.Web,YouTube Channels=https://www.youtube.com/feeds/videos.xml?channel_id=UCOiUKJ6lMU3yHbVNtNXJyfw
videofeed.Web,YouTube Channels=https://www.youtube.com/feeds/videos.xml?channel_id=UCqFzWxSCi39LnW1JKFR3efg
videofeed.Web,YouTube Channels=https://www.youtube.com/feeds/videos.xml?channel_id=UCfAOh2t5DpxVrgS9NQKjC7A
videofeed.Web,YouTube Channels=https://www.youtube.com/feeds/videos.xml?channel_id=UC8-Th83bH_thdKZDJCrn88g
videofeed.Web,YouTube Channels=https://www.youtube.com/feeds/videos.xml?channel_id=UCzRBkt4a2hy6HObM3cl-x7g
# video streams
# videostream.Web,TV=France 24,mms://stream1.france24.yacast.net/f24_liveen,http://www.france24.com/en/sites/france24.com.en/themes/france24/logo-fr.png
# videostream.Web,TV=BFM TV (French TV),mms://vipmms9.yacast.net/bfm_bfmtv,http://upload.wikimedia.org/wikipedia/en/6/62/BFMTV.png
# videostream.Web,Webcams=View of Shanghai Harbour,mmst://www.onedir.com/cam3,http://media-cdn.tripadvisor.com/media/photo-s/00/1d/4b/d8/pudong-from-the-bund.jpg

5
conf/app.src.default Normal file
View file

@ -0,0 +1,5 @@
SOURCE_URL=https://github.com/UniversalMediaServer/UniversalMediaServer/releases/download/10.4.1/UMS-10.4.1-__MACH__.tgz
SOURCE_SUM=__SHA256_SUM__
SOURCE_FORMAT=tgz
SOURCE_SUM_PRG=sha256sum
SOURCE_EXTRACT=false

24
conf/nginx.conf Normal file
View file

@ -0,0 +1,24 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
proxy_http_version 1.1;
proxy_read_timeout 90;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded_Proto $scheme;
proxy_set_header X-Scheme $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
more_set_headers "X-Frame-Options: SAMEORIGIN";
proxy_pass http://localhost:__PORT_WEB__/;
proxy_set_header Host $host;
# Force usage of https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}

15
conf/systemd.service Normal file
View file

@ -0,0 +1,15 @@
[Unit]
Description=A DLNA UPnP and HTTP(S) Media Server
After=network.target
[Service]
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__/
ExecStart=__FINALPATH__/UMS.sh headless
StandardOutput=append:/var/log/__APP__/__APP__.log
StandardError=inherit
[Install]
WantedBy=multi-user.target

55
issue_template.md Normal file
View 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 ums 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 ums
```
- *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.*

53
manifest.json Normal file
View file

@ -0,0 +1,53 @@
{
"name": "Universal Media Server",
"id": "ums",
"packaging_format": 1,
"description": {
"en": "A DLNA, UPnP and HTTP(S) Media Server",
"fr": "Un Serveur Multimedia DLNA, UPnP et HTTP(S)"
},
"version": "10.4.1~ynh1",
"url": "www.universalmediaserver.com",
"license": "GPL-2.0-or-later",
"maintainer": {
"name": "Krakinou",
"email": "misterl56@hotmail.com"
},
"requirements": {
"yunohost": ">= 4.1.7"
},
"multi_instance": false,
"services": [
"nginx"
],
"arguments": {
"install" : [
{
"name": "domain",
"type": "domain",
"example": "example.com"
},
{
"name": "is_public",
"type": "boolean",
"default": true,
"help": {
"en" : "Everybody will be able to access your media on the internet without connecting to Yunohost",
"fr" : "Tout le monde pourra voir vos media sans se connecter à Yunohost"
}
},
{
"name":"vlc",
"type": "boolean",
"ask": {
"en" : "Do you want to install vlc? It may be useful for web content streaming",
"fr" : "Voulez vous installer vlc? Cela peut etre utile pour streamer du contenu web"
},
"help": {
"en": "This will use approx 600GB more and will install a LOT of dependencies - NOT RECOMMENDED",
"fr": "Cela va utiliser environ 600GB supplémentaires et installera BEAUCOUP de dépendances - NON RECOMMANDE"
}
}
]
}
}

16
pull_request_template.md Normal file
View 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.
- [ ] Tested with Package_check.
- [ ] Fix or enhancement tested.
- [ ] Upgrade from last version tested.
- [ ] Can be reviewed and tested.
## Package_check results
---
* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"*

110
scripts/_common.sh Normal file
View file

@ -0,0 +1,110 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES
#=================================================
# dependencies used by the app
pkg_dependencies="mediainfo dcraw p7zip"
MACH=`uname -m`
case "$MACH" in
"armv6l" ) MACH="armel"
SHA256=1051fd725ff2c8da469fd9c0d1331e3c8ec031194303a8c79f7fad80c70e4a5e ;;
"armv7l" ) if [ $(dpkg --print-architecture) = "armhf" ]; then
MACH="armhf"
SHA256=194686fb5af695112485780b2cb89af2ec7cb675f166ff2717c7fc66eac958c0
else
MACH="armel"
SHA256=1051fd725ff2c8da469fd9c0d1331e3c8ec031194303a8c79f7fad80c70e4a5e
fi ;;
"armv8l" ) MACH="arm64"
SHA256=179ad2ff3800001b8e51d21776426d88c72c1ca1e4030363f3e9b4820d0919cc ;;
"x86_64" ) MACH="x86_64"
SHA256=7fbed13a5c5f8eb01f6f1b4815c73fb4b21b81b4affff29b5185715fa76f841b ;;
* ) MACH="x86"
SHA256=ec8e67e3b03300857116ebb9ddfe1bd938b506e9ba603df02f3c8d38bf9bb7be ;;
esac
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================
# Need also the helper https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_handle_getopts_args/ynh_handle_getopts_args
# Install or update the main directory yunohost.multimedia
#
# usage: ynh_multimedia_build_main_dir
ynh_multimedia_build_main_dir () {
local ynh_media_release="v1.2"
local checksum="806a827ba1902d6911095602a9221181"
# Download yunohost.multimedia scripts
wget -nv https://github.com/Yunohost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz 2>&1
# Check the control sum
echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \
|| ynh_die "Corrupt source"
# Check if the package acl is installed. Or install it.
ynh_package_is_installed 'acl' \
|| ynh_package_install acl
# Extract
mkdir yunohost.multimedia-master
tar -xf ${ynh_media_release}.tar.gz -C yunohost.multimedia-master --strip-components 1
./yunohost.multimedia-master/script/ynh_media_build.sh
}
# Add a directory in yunohost.multimedia
# This "directory" will be a symbolic link to a existing directory.
#
# usage: ynh_multimedia_addfolder "Source directory" "Destination directory"
#
# | arg: -s, --source_dir= - Source directory - The real directory which contains your medias.
# | arg: -d, --dest_dir= - Destination directory - The name and the place of the symbolic link, relative to "/home/yunohost.multimedia"
ynh_multimedia_addfolder () {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [s]=source_dir= [d]=dest_dir= )
local source_dir
local dest_dir
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source="$source_dir" --dest="$dest_dir"
}
# Move a directory in yunohost.multimedia, and replace by a symbolic link
#
# usage: ynh_multimedia_movefolder "Source directory" "Destination directory"
#
# | arg: -s, --source_dir= - Source directory - The real directory which contains your medias.
# It will be moved to "Destination directory"
# A symbolic link will replace it.
# | arg: -d, --dest_dir= - Destination directory - The new name and place of the directory, relative to "/home/yunohost.multimedia"
ynh_multimedia_movefolder () {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [s]=source_dir= [d]=dest_dir= )
local source_dir
local dest_dir
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
./yunohost.multimedia-master/script/ynh_media_addfolder.sh --inv --source="$source_dir" --dest="$dest_dir"
}
# Allow an user to have an write authorisation in multimedia directories
#
# usage: ynh_multimedia_addaccess user_name
#
# | arg: -u, --user_name= - The name of the user which gain this access.
ynh_multimedia_addaccess () {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [u]=user_name=)
local user_name
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
groupadd -f multimedia
usermod -a -G multimedia $user_name
}

86
scripts/backup Executable file
View file

@ -0,0 +1,86 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# 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 () {
### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
ynh_print_warn --message="This script will only backup the app, no media will be saved"
ynh_print_warn --message="To save your media, please use a backup tool such as borg"
#=================================================
# 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)
#=================================================
# 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"
#=================================================
# BACKUP FAIL2BAN CONFIGURATION
#=================================================
#ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
#ynh_backup --src_path="/etc/fail2ban/filter.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
#=================================================
ynh_backup --src_path="/home/$app/"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

134
scripts/change_url Normal file
View file

@ -0,0 +1,134 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Add settings here as needed by your application
#db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#db_user=$db_name
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --time --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --time --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the NGINX config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated NGINX config
ynh_add_nginx_config
fi
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# ...
#=================================================
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
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..." --time --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --time --last

232
scripts/install Executable file
View file

@ -0,0 +1,232 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url=/
is_public=$YNH_APP_ARG_IS_PUBLIC
vlc_required=$YNH_APP_ARG_VLC
app=$YNH_APP_INSTANCE_NAME
if [ "$vlc_required" -eq 1 ] ; then
pkg_dependencies="$pkg_dependencies vlc"
fi
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
#will be used when restoring
ynh_app_setting_set --app=$app --key=vlc --value=$vlc_required
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port..." --weight=1
# Find an available port
#port_web is used for the web interface while port_rend is used by video renderer
port_web=$(ynh_find_port --port=9001)
ynh_app_setting_set --app=$app --key=port_web --value=$port_web
port_rend=$(ynh_find_port --port=5001)
ynh_app_setting_set --app=$app --key=port_rend --value=$port_rend
# Open the port -- TO BE CHECKED IF REQUIRED
ynh_script_progression --message="Configuring firewall..." --weight=3
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port_web
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port_rend
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=30
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
#UMS require a home path for the user as config files are stored in there
ynh_system_user_create --username=$app --home_dir=/home/$app
#=================================================
#SETTING MULTIMEDIA DIRECTORY
#=================================================
ynh_script_progression --message="Setting up Multimedia directory..." --weight=9
ynh_multimedia_build_main_dir
ynh_multimedia_addaccess $app
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=12
# Download, check integrity, uncompress and patch the source from app.src
# Create an app.src for the correct compiled version of UMS
# match string are fulfilled in _common.sh
cp ../conf/app.src.default ../conf/app.src
ynh_replace_string --match_string="__MACH__" --replace_string="$MACH" --target_file="../conf/app.src"
ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$SHA256" --target_file="../conf/app.src"
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"
tar xfvz $final_path/app.tgz --strip-component=1 --directory=$final_path/
rm $final_path/app.tgz
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R root:$app "$final_path"
chown root:$app "$final_path/UMS.sh"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=4
### `ynh_add_nginx_config` will use the file conf/nginx.conf
# Create a dedicated NGINX config
ynh_add_nginx_config "port_web"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Setting up configuration file.." --weight=5
#UMS read config file from .config/UMS folder
mkdir -p "/home/$app/.config/UMS"
ynh_add_config --template="UMS.conf.default" --destination="/home/$app/.config/UMS/UMS.conf"
ynh_add_config --template="WEB.conf.default" --destination="/home/$app/.config/UMS/WEB.conf"
ynh_add_config --template="VirtualFolders.conf.default" --destination="/home/$app/.config/UMS/VirtualFolders.conf"
chown -R $app:$app "/home/$app/.config"
chmod -R 700 "/home/$app/.config"
#chmod 600 "/home/$app/.config/UMS/*"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
#TO BE CHECKED : debug.log file in ~/.config/UMS/
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="A DLNA, UPnP and HTTP(S) Media Server." --log="/var/log/$app/$app.log" --needs_exposed_ports "$port_web" "$port_rend"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# SETUP FAIL2BAN
#=================================================
#ynh_script_progression --message="Configuring Fail2Ban..." --time --weight=1
# Create a dedicated Fail2Ban config
#ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
# 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
### N.B. : the following extra permissions only make sense if your app
### does have for example an admin interface or an api.
# Only the admin can access the admin panel of the app (if the app has an admin panel)
#ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin
# Everyone can access to the api part
# We don't want to display the tile in the sso so we put --show_tile="false"
# And we don't want that the YunoHost Admin can remove visitors group to this permission, so we put --protected="true"
#ynh_permission_create --permission="api" --url "/api" --allowed="visitors" --show_tile="false" --protected="true"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last

117
scripts/remove Executable file
View file

@ -0,0 +1,117 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port_web=$(ynh_app_setting_get --app=$app --key=port_web)
port_rend=$(ynh_app_setting_get --app=$app --key=port_rend)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# 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..." --weight=2
yunohost service remove $app
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=3
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=5
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=2
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# CLOSE PORTS
#=================================================
if yunohost firewall list | grep -q "\- $port_web$"
then
ynh_script_progression --message="Closing port $port_web..." --weight=2
ynh_exec_warn_less yunohost firewall disallow TCP $port_web
fi
if yunohost firewall list | grep -q "\- $port_rend$"
then
ynh_script_progression --message="Closing port $port_rend..." --weight=2
ynh_exec_warn_less yunohost firewall disallow TCP $port_rend
fi
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
# 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..." --weight=1
# Delete a system user
ynh_system_user_delete --username=$app
ynh_secure_remove --file="/home/$app"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last

162
scripts/restore Executable file
View file

@ -0,0 +1,162 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# 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 () {
#### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
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)
port_web=$(ynh_app_setting_get --app=$app --key=port_web)
port_rend=$(ynh_app_setting_get --app=$app --key=port_rend)
vlc_required=$(ynh_app_setting_get --app=$app --key=vlc)
if [ "$vlc_required" -eq 1 ] ; then
pkg_dependencies="$pkg_dependencies vlc"
fi
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
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 "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=5
ynh_restore_file --origin_path="$final_path"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=3
# Create the dedicated user (if not existing)
#UMS require a home path for the user as config files are stored in there
ynh_system_user_create --username=$app --home_dir=/home/$app
#=================================================
#SETTING MULTIMEDIA DIRECTORY
#=================================================
ynh_multimedia_build_main_dir
ynh_multimedia_addaccess $app
#=================================================
# RESTORE USER RIGHTS
#=================================================
# Restore permissions on app files
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R root:$app "$final_path"
chown root:$app "$final_path/UMS.sh"
#=================================================
# RESTORE FAIL2BAN CONFIGURATION
#=================================================
#ynh_script_progression --message="Restoring the Fail2Ban configuration..." --time --weight=1
#ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
#ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
#ynh_systemd_action --action=restart --service_name=fail2ban
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=15
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=2
yunohost service add $app --description="A DLNA, UPnP and HTTP(S) Media Server." --log=/var/log/$app/$app.log --needs_exposed_ports $port_web $port_rend
#=================================================
# RESTORE VARIOUS FILES
#=================================================
mkdir -p /var/log/$app
ynh_restore_file --origin_path="/home/$app/"
chown -R $app:$app "/home/$app/.config"
chmod -R 700 "/home/$app/.config"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last

194
scripts/upgrade Normal file
View file

@ -0,0 +1,194 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
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)
port_web=$(ynh_app_setting_get --app=$app --key=port_web)
port_rend=$(ynh_app_setting_get --app=$app --key=port_rend)
vlc_required=$(ynh_app_setting_get --app=$app --key=vlc)
if [ "$vlc_required" -eq 1 ] ; then
pkg_dependencies="$pkg_dependencies vlc"
fi
#=================================================
# CHECK VERSION
#=================================================
### This helper will compare the version of the currently installed app and the version of the upstream package.
### $upgrade_type can have 2 different values
### - UPGRADE_APP if the upstream app version has changed
### - UPGRADE_PACKAGE if only the YunoHost package has changed
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=10
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=2
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=5
# Download, check integrity, uncompress and patch the source from app.src
cp ../conf/app.src.default ../conf/app.src
ynh_replace_string --match_string="__MACH__" --replace_string="$MACH" --target_file="../conf/app.src"
ynh_replace_string --match_string="__SHA256_SUM__" --replace_string="$SHA256" --target_file="../conf/app.src"
ynh_setup_source --dest_dir="$final_path"
tar xfvz $final_path/app.tgz --strip-component=1 --directory=$final_path/
rm $final_path/app.tgz
fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config "port_web"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=4
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=/home/$app
#=================================================
# SPECIFIC UPGRADE
#=================================================
# ...
#=================================================
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Setting up configuration file..." --weight=3
### Same as during install
###
### The file will automatically be backed-up if it's found to be manually modified (because
### ynh_add_config keeps track of the file's checksum)
mkdir -p "/home/$app/.config/UMS"
ynh_add_config --template="UMS.conf.default" --destination="/home/$app/.config/UMS/UMS.conf"
ynh_add_config --template="WEB.conf.default" --destination="/home/$app/.config/UMS/WEB.conf"
ynh_add_config --template="VirtualFolders.conf.default" --destination="/home/$app/.config/UMS/VirtualFolders.conf"
chown -R $app:$app "/home/$app/.config"
chmod -R 700 "/home/$app/.config"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions on app files
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R root:$app "$final_path"
chown root:$app "$final_path/UMS.sh"
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=2
yunohost service add $app --description="A DLNA, UPnP and HTTP(S) Media Server." --log=/var/log/$app/$app.log --needs_exposed_ports $port_web $port_rend
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# UPGRADE FAIL2BAN
#=================================================
#ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=1
# Create a dedicated Fail2Ban config
#ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last

2
sources/extra_files/app/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*~
*.sw[op]

2
sources/patches/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*~
*.sw[op]