1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mopidy_ynh.git synced 2024-09-03 19:46:21 +02:00

Merge pull request #38 from YunoHost-Apps/upgrade

Upgrade
This commit is contained in:
yalh76 2022-06-23 13:23:16 +02:00 committed by GitHub
commit f831308e36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 272 additions and 274 deletions

View file

@ -5,7 +5,7 @@ It shall NOT be edited by hand.
# Mopidy for YunoHost
[![Integration level](https://dash.yunohost.org/integration/mopidy.svg)](https://dash.yunohost.org/appci/app/mopidy) ![](https://ci-apps.yunohost.org/ci/badges/mopidy.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mopidy.maintain.svg)
[![Integration level](https://dash.yunohost.org/integration/mopidy.svg)](https://dash.yunohost.org/appci/app/mopidy) ![Working status](https://ci-apps.yunohost.org/ci/badges/mopidy.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/mopidy.maintain.svg)
[![Install Mopidy with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mopidy)
*[Lire ce readme en français.](./README_fr.md)*
@ -17,13 +17,11 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
Play music, podcasts and radio programs from local disk and various streaming services
**Shipped version:** 3.2.0~ynh1
**Shipped version:** 3.2.0~ynh2
## Screenshots
![](./doc/screenshots/mopidy_screenshot1.png)
![Screenshot of Mopidy](./doc/screenshots/mopidy_screenshot1.png)
## Disclaimers / important information
@ -44,21 +42,22 @@ Play music, podcasts and radio programs from local disk and various streaming se
## Documentation and resources
* Official app website: https://www.mopidy.com
* Official admin documentation: https://docs.mopidy.com/en/latest
* Upstream app code repository: https://github.com/mopidy/mopidy
* YunoHost documentation for this app: https://yunohost.org/app_mopidy
* Report a bug: https://github.com/YunoHost-Apps/mopidy_ynh/issues
* Official app website: <https://www.mopidy.com>
* Official admin documentation: <https://docs.mopidy.com/en/latest>
* Upstream app code repository: <https://github.com/mopidy/mopidy>
* YunoHost documentation for this app: <https://yunohost.org/app_mopidy>
* Report a bug: <https://github.com/YunoHost-Apps/mopidy_ynh/issues>
## Developer info
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/mopidy_ynh/tree/testing).
To try the testing branch, please proceed like that.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/mopidy_ynh/tree/testing --debug
or
sudo yunohost app upgrade mopidy -u https://github.com/YunoHost-Apps/mopidy_ynh/tree/testing --debug
```
**More info regarding app packaging:** https://yunohost.org/packaging_apps
**More info regarding app packaging:** <https://yunohost.org/packaging_apps>

View file

@ -1,10 +1,14 @@
<!--
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.
-->
# Mopidy pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/mopidy.svg)](https://dash.yunohost.org/appci/app/mopidy) ![](https://ci-apps.yunohost.org/ci/badges/mopidy.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mopidy.maintain.svg)
[![Niveau d'intégration](https://dash.yunohost.org/integration/mopidy.svg)](https://dash.yunohost.org/appci/app/mopidy) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/mopidy.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/mopidy.maintain.svg)
[![Installer Mopidy avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mopidy)
*[Read this readme in english.](./README.md)*
*[Lire ce readme en français.](./README_fr.md)*
> *Ce package vous permet d'installer Mopidy 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.*
@ -13,13 +17,11 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
Écouter de la musique, des podcasts et des programmes radio depuis le disque local et divers services de streaming
**Version incluse :** 3.2.0~ynh1
**Version incluse :** 3.2.0~ynh2
## Captures d'écran
![](./doc/screenshots/mopidy_screenshot1.png)
![Capture d'écran de Mopidy](./doc/screenshots/mopidy_screenshot1.png)
## Avertissements / informations importantes
@ -40,21 +42,22 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
## Documentations et ressources
* Site officiel de l'app : https://www.mopidy.com
* Documentation officielle de l'admin : https://docs.mopidy.com/en/latest
* Dépôt de code officiel de l'app : https://github.com/mopidy/mopidy
* Documentation YunoHost pour cette app : https://yunohost.org/app_mopidy
* Signaler un bug : https://github.com/YunoHost-Apps/mopidy_ynh/issues
* Site officiel de l'app : <https://www.mopidy.com>
* Documentation officielle de l'admin : <https://docs.mopidy.com/en/latest>
* Dépôt de code officiel de l'app : <https://github.com/mopidy/mopidy>
* Documentation YunoHost pour cette app : <https://yunohost.org/app_mopidy>
* Signaler un bug : <https://github.com/YunoHost-Apps/mopidy_ynh/issues>
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/mopidy_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/mopidy_ynh/tree/testing --debug
ou
sudo yunohost app upgrade mopidy -u https://github.com/YunoHost-Apps/mopidy_ynh/tree/testing --debug
```
**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps
**Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps>

View file

@ -1,9 +1,9 @@
;; Test complet
; Manifest
domain="domain.tld"
path="/path"
is_public=1
mpd_ext=1
; Checks
pkg_linter=1
setup_sub_dir=1
@ -12,14 +12,14 @@
setup_private=1
setup_public=1
upgrade=1
# 3.1.1~ynh2
upgrade=1 from_commit=bc421d01d57a273a59287cf7500e94a89de0abed
# 3.2.0~ynh1
upgrade=1 from_commit=31c5de684273794e4f4837d5dccc5a663ce9fb45
backup_restore=1
multi_instance=0
port_already_use=0
change_url=1
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=CommitHash
name=Name and date of the commit.
manifest_arg=domain=DOMAIN&path=PATH&is_public=1

View file

@ -2,9 +2,9 @@
# http://docs.mopidy.com/
[core]
cache_dir = __CACHE_DIR__
cache_dir = __DATADIR__/cache
#config_dir =
data_dir = __DATA_DIR__
data_dir = __DATADIR__/data
#max_tracklist_length = 10000
#restore_state = false
@ -168,7 +168,7 @@ retries = 3
[podcast]
enabled = true
browse_root = __DATA_DIR__/podcast/bbc.opml
browse_root = __DATADIR__/data/podcast/bbc.opml
#browse_order = desc
#lookup_order = asc
#cache_size = 64

View file

@ -1,56 +1,41 @@
location /mopidy/ws {
proxy_pass http://localhost:__PORT__;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 604800;
proxy_send_timeout 604800;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:__PORT__;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 604800;
proxy_send_timeout 604800;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location __PATH__/ {
# Force usage of https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
proxy_pass http://localhost:__PORT__/musicbox_webclient/;
proxy_http_version 1.1;
proxy_set_header Host $host;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
proxy_pass http://localhost:__PORT__/musicbox_webclient/;
proxy_http_version 1.1;
proxy_set_header Host $host;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}
location /musicbox_webclient/ {
# Force usage of https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
proxy_pass http://localhost:__PORT__;
proxy_http_version 1.1;
proxy_set_header Host $host;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
proxy_pass http://localhost:__PORT__;
proxy_http_version 1.1;
proxy_set_header Host $host;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}
location /local/ {
# Force usage of https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
proxy_pass http://localhost:__PORT__;
proxy_http_version 1.1;
proxy_set_header Host $host;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
proxy_pass http://localhost:__PORT__;
proxy_http_version 1.1;
proxy_set_header Host $host;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}

View file

@ -5,3 +5,4 @@ bcm5 = play_pause,active_low,250
bcm6 = volume_down,active_low,250
bcm16 = next,active_low,250
bcm20 = volume_up,active_low,250

View file

@ -6,7 +6,7 @@
"en": "Play music, podcasts and radio programs from local disk and various streaming services",
"fr": "Écouter de la musique, des podcasts et des programmes radio depuis le disque local et divers services de streaming"
},
"version": "3.2.0~ynh1",
"version": "3.2.0~ynh2",
"url": "https://www.mopidy.com",
"upstream": {
"license": "Apache-2.0",
@ -31,7 +31,7 @@
"nginx"
],
"arguments": {
"install" : [
"install": [
{
"name": "domain",
"type": "domain"

View file

@ -3,12 +3,13 @@
#=================================================
# COMMON VARIABLES
#=================================================
# dependencies used by the app
pkg_dependencies="acl build-essential python3-dev python3-pip python3-venv git postgresql postgresql-contrib \
gir1.2-gst-plugins-base-1.0 gir1.2-gstreamer-1.0 gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly lsb-base \
python3-gst-1.0 python3-tornado debconf python3-pkg-resources python3-pykka python3-requests \
gstreamer1.0-alsa gstreamer1.0-pulseaudio gstreamer1.0-tools"
gir1.2-gst-plugins-base-1.0 gir1.2-gstreamer-1.0 gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly lsb-base \
python3-gst-1.0 python3-tornado debconf python3-pkg-resources python3-pykka python3-requests \
gstreamer1.0-alsa gstreamer1.0-pulseaudio gstreamer1.0-tools"
#=================================================
# PERSONAL HELPERS
#=================================================
@ -16,25 +17,24 @@ pkg_dependencies="acl build-essential python3-dev python3-pip python3-venv git p
python_version="$(python3 -V | cut -d' ' -f2 | cut -d. -f1-2)"
myynh_install() {
python3 -m venv "${final_path}/env"
chown -R "$app" "$final_path"
python3 -m venv "${final_path}/env"
chown -R "$app" "$final_path"
#run source in a 'sub shell'
(
#run source in a 'sub shell'
(
set +o nounset
source "${final_path}/env/bin/activate"
set -o nounset
ynh_exec_as $app $final_path/env/bin/pip install --upgrade --no-cache-dir pip
# to make Gstreamer visible in Python environment
$final_path/env/bin/python3 -m pip install vext
$final_path/env/bin/python3 -m pip install --no-binary=:all: vext.gi
# install essential packages
ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy==3.2.0
ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy-local==3.2.1
ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy-MusicBox-Webclient==3.1.0
ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy==$(ynh_app_upstream_version)
ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy-local==3.2.1
ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy-MusicBox-Webclient==3.1.0
ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy-YouTube==3.3
ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir mopidy-ytmusic==0.3.0
ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy-RadioNet==0.2.2
@ -42,7 +42,7 @@ myynh_install() {
ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy-Podcast-iTunes==3.0.0
ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy-SoundCloud==3.0.1
ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy-MPD==3.1.0
)
)
}
#=================================================

View file

@ -26,12 +26,7 @@ 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)
work_dir=$(ynh_app_setting_get --app=$app --key=work_dir)
# other variables
media_dir="/home/yunohost.multimedia/share/Music"
work_dir="/home/yunohost.app/$app"
cmd_file="/usr/local/bin/mopidyctl"
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
@ -44,6 +39,12 @@ ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="$final_path"
#=================================================
# BACKUP THE DATA DIR
#=================================================
ynh_backup --src_path="$datadir" --is_big
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
@ -62,9 +63,7 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path=$work_dir
ynh_backup --src_path="$cmd_file"
ynh_backup --src_path="/usr/local/bin/mopidyctl"
#=================================================
# END OF SCRIPT

View file

@ -28,6 +28,8 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=path)
# Add settings here as needed by your application
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
@ -70,7 +72,7 @@ fi
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app --action="stop"
#=================================================
# MODIFY URL IN NGINX CONF
@ -94,7 +96,6 @@ 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
@ -107,12 +108,6 @@ then
ynh_permission_url --permission="main" --add_url="$new_domain/musicbox_webclient" --remove_url="$old_domain/musicbox_webclient"
fi
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# ...
#=================================================
#=================================================
# GENERIC FINALISATION
#=================================================
@ -121,6 +116,7 @@ fi
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start"
#=================================================
# RELOAD NGINX
#=================================================

View file

@ -13,6 +13,9 @@ 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
@ -27,18 +30,12 @@ mpd_port=$YNH_APP_ARG_MPD_EXT
app=$YNH_APP_INSTANCE_NAME
# other variables
final_path="/opt/yunohost/$app"
media_dir="/home/yunohost.multimedia/share/Music"
work_dir="/home/yunohost.app/$app"
conf_file="$final_path/$app.conf"
cmd_file="/usr/local/bin/mopidyctl"
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..."
final_path=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
@ -65,14 +62,13 @@ ynh_app_setting_set --app=$app --key=port --value=$port
if [ $mpd_port -eq 1 ]; then
mpd_port=$(ynh_find_port --port=6600)
ynh_app_setting_set --app=$app --key=mpd_port --value=$mpd_port
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $mpd_port
mpd_state="true"
else
mpd_state="false"
fi
ynh_app_setting_set --app=$app --key=mpd_port --value=$mpd_port
#=================================================
# INSTALL DEPENDENCIES
#=================================================
@ -86,17 +82,20 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell --groups="audio"
ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell --groups="audio"
#=================================================
# INSTALL MOPIDY IN PYTHON ENVIRONMENT
#=================================================
ynh_script_progression --message="Install in Python environment..." --weight=30
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
myynh_install
patch -u $final_path/env/lib/python$python_version/site-packages/mopidy/__main__.py -i ../sources/patches/__main__.patch --forward
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
@ -107,15 +106,40 @@ ynh_script_progression --message="Configuring NGINX web server..."
ynh_add_nginx_config
#=================================================
# CREATE YUNOHOST DIRECTORIES
# SPECIFIC SETUP
#=================================================
ynh_script_progression --message="Creating YunoHost directories..."
# BUILD MULTIMEDIA
#=================================================
ynh_script_progression --message="Building multimedia directory..."
media_dir="/home/yunohost.multimedia/share/Music"
ynh_multimedia_build_main_dir # /home/yunohost.multimedia
mkdir -p "$work_dir/data" # /home/yunohost.app/mopidy/data
mkdir -p "$work_dir/cache" # /home/yunohost.app/mopidy/cache
chown -R $app: "$work_dir"
#=================================================
# CREATE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Creating a data directory..."
datadir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
mkdir -p $datadir
mkdir -p "$datadir/data" # /home/yunohost.app/mopidy/data
mkdir -p "$datadir/cache" # /home/yunohost.app/mopidy/cache
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..."
ynh_add_config --template="../conf/app.conf" --destination="$final_path/$app.conf"
chmod 400 "$final_path/$app.conf"
chown $app:$app "$final_path/$app.conf"
#=================================================
# SETUP SYSTEMD
@ -123,43 +147,55 @@ chown -R $app: "$work_dir"
ynh_script_progression --message="Configuring a systemd service..."
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# MODIFY A CONFIG FILE
# PROVIDE ADDITIONAL SHELL COMMAND
#=================================================
ynh_script_progression --message="Setup config file..."
ynh_script_progression --message="Provide additional shell command..."
cache_dir=$work_dir/cache
data_dir=$work_dir/data
cmd_file="/usr/local/bin/mopidyctl"
ynh_add_config --template="../sources/extra_files/mopidyctl" --destination="$cmd_file"
ynh_add_config --template="../conf/app.conf" --destination="$conf_file"
chmod +x "$cmd_file"
#=================================================
# STORE THE CONFIG FILE CHECKSUM
# PROVIDE EXAMPLES
#=================================================
ynh_store_file_checksum --file="$conf_file"
media_dir="/home/yunohost.multimedia/share/Music"
# provide example m3u-playlist
mkdir -p "$datadir/data/m3u/"
cp -a ../sources/extra_files/radio_international.m3u "$datadir/data/m3u/radio_international.m3u"
#provide example podcasts
mkdir -p "$datadir/data/podcast"
cp -a ../sources/extra_files/bbc.opml "$datadir/data/podcast/bbc.opml"
#provide example local music file
if [ "$(ls -A "$media_dir" 2> /dev/null)" == "" ]; then # copy example.mp3 to mediadir if empty (for test purpose)
cp -a ../sources/extra_files/Tryad_Beauty.mp3 "$media_dir"
fi
#=================================================
# SCAN LOCAL MEDIA DIRECTORY
#=================================================
ynh_script_progression --message="Scan local media directory..."
"$cmd_file" local scan 2>&1
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
if [ $mpd_port -ne 0 ]; then
yunohost service add $app --description="Mopidy music server" --log="/var/log/$app/$app.log" --needs_exposed_ports=$mpd_port
yunohost service add $app --description="Mopidy music server" --needs_exposed_ports=$mpd_port
else
yunohost service add $app --description="Mopidy music server" --log="/var/log/$app/$app.log"
yunohost service add $app --description="Mopidy music server"
fi
#=================================================
@ -176,7 +212,10 @@ ynh_systemd_action --service_name=$app --action="start"
ynh_script_progression --message="Configuring permissions..."
# Make app public if necessary
if [ $is_public -eq 1 ]; then
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
@ -191,39 +230,6 @@ ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# PROVIDE ADDITIONAL SHELL COMAND
#=================================================
ynh_script_progression --message="Provide additional shell command..."
ynh_add_config --template="../sources/extra_files/mopidyctl" --destination="$cmd_file"
chmod +x "$cmd_file"
#=================================================
# PROVIDE EXAMPLES
#=================================================
# provide example m3u-playlist
mkdir -p "$work_dir/data/m3u/"
cp -a ../sources/extra_files/radio_international.m3u "$work_dir/data/m3u/radio_international.m3u"
#provide example podcasts
mkdir -p "$work_dir/data/podcast"
cp -a ../sources/extra_files/bbc.opml "$work_dir/data/podcast/bbc.opml"
#provide example local music file
if [ "$(ls -A "$media_dir" 2> /dev/null)" == "" ]; then # copy example.mp3 to mediadir if empty (for test purpose)
cp -a ../sources/extra_files/Tryad_Beauty.mp3 "$media_dir"
fi
#=================================================
# SCAN LOCAL MEDIA DIRECTORY
#=================================================
ynh_script_progression --message="Scan local media directory..."
"$cmd_file" local scan 2>&1
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -17,12 +17,10 @@ ynh_script_progression --message="Loading installation settings..." --weight=4
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
mpd_port=$(ynh_app_setting_get --app=$app --key=mpd_port)
port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
mpd_port=$(ynh_app_setting_get --app=$app --key=mpd_port)
# other variables
cmd_file="/usr/local/bin/mopidyctl"
#=================================================
# STANDARD REMOVE
#=================================================
@ -44,14 +42,6 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=42
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE APP MAIN DIR
#=================================================
@ -68,6 +58,14 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=42
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# CLOSE A PORT
#=================================================
@ -77,14 +75,15 @@ then
ynh_script_progression --message="Closing port $mpd_port..." --weight=1
ynh_exec_warn_less yunohost firewall disallow TCP $mpd_port
fi
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..."
# Remove a cron file
ynh_secure_remove --file="$cmd_file"
ynh_secure_remove --file="/usr/local/bin/mopidyctl"
#=================================================
# GENERIC FINALIZATION

View file

@ -28,34 +28,25 @@ 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)
mpd_port=$(ynh_app_setting_get --app=$app --key=mpd_port)
# other variables
media_dir="/home/yunohost.multimedia/share/Music"
work_dir="/home/yunohost.app/$app"
cmd_file="/usr/local/bin/mopidyctl"
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=3
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
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"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell --groups="audio"
ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell --groups="audio"
#=================================================
# RESTORE THE APP MAIN DIR
@ -64,18 +55,40 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$final_path"
#=================================================
# RESTORE USER RIGHTS
#=================================================
# Restore permissions on app files
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the data directory..."
ynh_restore_file --origin_path="$datadir" --not_mandatory
mkdir -p $datadir
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=50
# Define and install dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
# 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"
#=================================================
# OPEN PORT
#=================================================
@ -86,12 +99,11 @@ if [ $mpd_port -ne 0 ]; then
fi
#=================================================
# REINSTALL DEPENDENCIES
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=50
ynh_script_progression --message="Restoring various files..."
# Define and install dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_restore_file --origin_path="/usr/local/bin/mopidyctl" # /usr/local/bin/mopidyctl
#=================================================
# RESTORE SYSTEMD
@ -107,19 +119,11 @@ systemctl enable $app.service --quiet
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
if [ $mpd_port -ne 0 ]; then
yunohost service add $app --description="Mopidy music server" --log="/var/log/$app/$app.log" --needs_exposed_ports=$mpd_port
yunohost service add $app --description="Mopidy music server" --needs_exposed_ports=$mpd_port
else
yunohost service add $app --description="Mopidy music server" --log="/var/log/$app/$app.log"
yunohost service add $app --description="Mopidy music server"
fi
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_restore_file --origin_path="$work_dir" # /home/yunohost.app/mopidy
ynh_restore_file --origin_path="$cmd_file" # /usr/local/bin/mopidyctl
#=================================================
# START SYSTEMD SERVICE
#=================================================

View file

@ -5,6 +5,7 @@
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -20,42 +21,19 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
mpd_port=$(ynh_app_setting_get --app=$app --key=mpd_port)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
# other variables
media_dir="/home/yunohost.multimedia/share/Music"
work_dir="/home/yunohost.app/$app"
conf_file="$final_path/$app.conf"
cmd_file="/usr/local/bin/mopidyctl"
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
#ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
#
# N.B. : the followings setting migrations snippets are provided as *EXAMPLES*
# of what you may want to do in some cases (e.g. a setting was not defined on
# some legacy installs and you therefore want to initiaze stuff during upgrade)
#
# If mpd_port doesn't exist, create it
if [ -z "$mpd_port" ]; then
mpd_port=0
ynh_app_setting_set --app=$app --key=mpd_port --value=$mpd_port
fi
if [ $mpd_port -eq 0 ]; then
mpd_state="false"
else
mpd_state="true"
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
@ -79,13 +57,36 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# If mpd_port doesn't exist, create it
if [ -z "$mpd_port" ]; then
mpd_port=0
ynh_app_setting_set --app=$app --key=mpd_port --value=$mpd_port
fi
if [ $mpd_port -eq 0 ]; then
mpd_state="false"
else
mpd_state="true"
fi
# If datadir doesn't exist, create it
if [ -z "$datadir" ]; then
datadir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
fi
#=================================================
# 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="$final_path" --use_shell --groups="audio"
ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell --groups="audio"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -93,6 +94,7 @@ ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell --
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..."
myynh_install
fi
@ -100,6 +102,13 @@ chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=11
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
# NGINX CONFIGURATION
#=================================================
@ -108,15 +117,28 @@ 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..." --weight=11
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
media_dir="/home/yunohost.multimedia/share/Music"
ynh_add_config --template="../conf/app.conf" --destination="$final_path/$app.conf"
chmod 400 "$final_path/$app.conf"
chown $app:$app "$final_path/$app.conf"
#=================================================
# PROVIDE ADDITIONAL SHELL COMMAND
#=================================================
ynh_script_progression --message="Provide additional shell comand..."
ynh_add_config --template="../sources/extra_files/mopidyctl" --destination="$cmd_file"
chmod +x "$cmd_file"
#=================================================
# SETUP SYSTEMD
#=================================================
@ -126,23 +148,16 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=3
ynh_add_systemd_config
#=================================================
# MODIFY A CONFIG FILE
#=================================================
cache_dir=$work_dir/cache
data_dir=$work_dir/data
ynh_add_config --template="../conf/app.conf" --destination="$conf_file"
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
if [ $mpd_port -ne 0 ]; then
yunohost service add $app --description="Mopidy music server" --log="/var/log/$app/$app.log" --needs_exposed_ports=$mpd_port
yunohost service add $app --description="Mopidy music server" --needs_exposed_ports=$mpd_port
else
yunohost service add $app --description="Mopidy music server" --log="/var/log/$app/$app.log"
yunohost service add $app --description="Mopidy music server"
fi
#=================================================
@ -159,15 +174,6 @@ ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# PROVIDE ADDITIONAL SHELL COMAND
#=================================================
ynh_script_progression --message="Provide additional shell comand..."
ynh_add_config --template="../sources/extra_files/mopidyctl" --destination="$cmd_file"
chmod +x "$cmd_file"
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -3,7 +3,7 @@
SELF=$(basename $0)
DAEMON="__FINAL_PATH__/env/bin/mopidy"
DAEMON_USER="__APP__"
CONFIG_FILES="__CONF_FILE__"
CONFIG_FILES="__FINAL_PATH__/__APP__.conf"
CMD="$DAEMON --config $CONFIG_FILES $@"
if [ $# -eq 0 ]; then