diff --git a/README.md b/README.md index f2ef09c..e8e6c0d 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview Mopidy - is an extensible music server. It plays music, podcasts and radio programs from local disk and various streaming services. You edit the playlist from any phone, tablet, or computer. You hear the music through the speakers connected to the server. -**Shipped version:** 3.1.1 +**Shipped version:** 3.2.0 ## Screenshots @@ -32,6 +32,7 @@ This installation is shipped with various extensions: * [RadioNet](https://mopidy.com/ext/radionet/) to play radio channels from the [radio.net](https://www.radio.net/). * [Podcast](https://mopidy.com/ext/podcast/) to browse RSS feeds of podcasts and stream the episodes. * [Soundcloud](https://pypi.org/project/Mopidy-SoundCloud/) to play music from the [SoundCloud](https://soundcloud.com/) service \([authentication token](https://pypi.org/project/Mopidy-SoundCloud/) needed\). +* [MPD](https://mopidy.com/ext/mpd/) can be activated in order to use apps that control mopidy via this protocol. (This will open port 6600.) ## Documentation diff --git a/README_fr.md b/README_fr.md index c9408e3..6ba30ac 100644 --- a/README_fr.md +++ b/README_fr.md @@ -13,7 +13,7 @@ Mopidy - est un serveur de musique extensible. Mopidy lit de la musique, des pod Vous pouvez modifier la liste de lecture à partir d'un téléphone, d'une tablette ou d'un ordinateur. Vous entendez la musique via les haut-parleurs connectés au serveur. -**Version incluse :** 3.1.1 +**Version incluse :** 3.2.0 ## Captures d'écran @@ -35,6 +35,7 @@ Cette installation est livrée avec différentes extensions: * [RadioNet](https://mopidy.com/ext/radionet/) pour écouter les canaux radio de [radio.net](https://www.radio.net/) * [Podcast](https://mopidy.com/ext/podcast/) pour parcourir les flux RSS des podcasts et diffuser les épisodes * [Soundcloud](https://pypi.org/project/Mopidy-SoundCloud/) pour lire de la musique à partir du service [SoundCloud](https://soundcloud.com/) service \([jeton d'authentification](https://pypi.org/project/Mopidy-SoundCloud/) nécessaire\). +* [MPD](https://mopidy.com/ext/mpd/) peut être activé afin d'utiliser des applications qui contrôlent mpidy via ce protocole. (Cela ouvrira le port 6600 ) ## Documentation diff --git a/check_process b/check_process index 8af44f2..3f9b49c 100644 --- a/check_process +++ b/check_process @@ -1,13 +1,9 @@ -# See here for more information -# https://github.com/YunoHost/package_check#syntax-check_process-file - -# Move this file from check_process.default to check_process when you have filled it. ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) - is_public=1 (PUBLIC|public=1|private=0) + domain="domain.tld" + path="/path" + is_public=1 ; Checks pkg_linter=1 setup_sub_dir=1 @@ -28,4 +24,3 @@ Notification=none ; commit=CommitHash name=Name and date of the commit. manifest_arg=domain=DOMAIN&path=PATH&is_public=1 - diff --git a/conf/app.conf b/conf/app.conf index 58b1690..3b5185a 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -10,7 +10,7 @@ data_dir = __DATA_DIR__ [file] enabled = true -media_dirs = __MEDIADIR__ +media_dirs = __MEDIA_DIR__ #excluded_file_extensions = # .directory # .html @@ -86,7 +86,7 @@ enabled = true [local] enabled = true #max_search_results = 100 -media_dir = __MEDIADIR__ +media_dir = __MEDIA_DIR__ #scan_timeout = 1000 #scan_flush_threshold = 100 #scan_follow_symlinks = false @@ -182,9 +182,7 @@ enabled = false auth_token = ? #explore_songs = 25 -#[spotify] -#enabled = true -#username = ? #see https://github.com/mopidy/mopidy-spotify -#password = ? -#client_id = ? -#client_secret = ? +[mpd] +enabled = __MPD_STATE__ +hostname = 0.0.0.0 +port = __MPD_PORT__ diff --git a/conf/nginx.conf b/conf/nginx.conf index f2ba50c..1740a9d 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -37,7 +37,7 @@ location /musicbox_webclient/ { rewrite ^ https://$server_name$request_uri? permanent; } - proxy_pass http://localhost:6680; + proxy_pass http://localhost:__PORT__; proxy_http_version 1.1; proxy_set_header Host $host; @@ -52,7 +52,7 @@ location /local/ { rewrite ^ https://$server_name$request_uri? permanent; } - proxy_pass http://localhost:6680; + proxy_pass http://localhost:__PORT__; proxy_http_version 1.1; proxy_set_header Host $host; diff --git a/conf/systemd.service b/conf/systemd.service index c8d7366..de7d4be 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -11,7 +11,7 @@ After=sound.target [Service] User=__APP__ PermissionsStartOnly=true -ExecStart=__START_FILE__ --config __CONF_FILE__ +ExecStart=__FINALPATH__/env/bin/__APP__ --config __FINALPATH__/__APP__.conf [Install] WantedBy=multi-user.target diff --git a/manifest.json b/manifest.json index 6e00c75..b463de7 100644 --- a/manifest.json +++ b/manifest.json @@ -3,9 +3,10 @@ "id": "mopidy", "packaging_format": 1, "description": { - "en": "plays music, podcasts and radio programs from local disk and various streaming services" + "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.1.1~ynh2", + "version": "3.2.0~ynh1", "url": "https://www.mopidy.com/", "license": "Apache-2.0", "maintainer": { @@ -17,7 +18,7 @@ "email": "cyp@rouquin.me" }, "requirements": { - "yunohost": ">= 4.1.7" + "yunohost": ">= 4.2.0" }, "multi_instance": false, "services": [ @@ -44,6 +45,15 @@ "fr": "L'application publique peut être utilisée par des visiteurs anonymes " }, "default": false + }, + { + "name": "mpd_ext", + "type": "boolean", + "help": { + "en": "Activate MPD extension (this will open port 6600)", + "fr": "Activer l'extension MPD (cela ouvrira le port 6600)" + }, + "default": false } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index 5468699..dca0a40 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -16,47 +16,32 @@ 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() { -# ynh_script_progression --message="Install / upgrade mopidy via pip..." --weight=8 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 - -# ynh_script_progression --message="Installing essentials..." --weight=17 + 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 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.1.1 - -# patch -u $final_path/env/lib/python$python_version/site-packages/mopidy/__main__.py -i ../sources/patches/__main__.patch --forward - - - 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_script_progression --message="Installing Mopidy-YouTube..." --weight=7 - ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy-YouTube==3.2 -# ynh_script_progression --message="Installing Mopidy-YTMusic..." --weight=2 - ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy-YTMusic==0.2.2 -# ynh_script_progression --message="Installing Mopidy-RadioNet..." + # 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-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 -# ynh_script_progression --message="Installing Mopidy-Podcast..." ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy-Podcast==3.0.0 -# ynh_script_progression --message="Installing Mopidy-Podcast-iTunes..." --weight=2 ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy-Podcast-iTunes==3.0.0 -# ynh_script_progression --message="Installing Mopidy-SoundCloud..." --weight=6 - ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy-SoundCloud - -# set +o nounset -# source "${final_path}/env/bin/deactivate" -# set -o nounset + 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 ) } @@ -67,15 +52,3 @@ myynh_install() { #================================================= # FUTURE OFFICIAL HELPERS #================================================= - -#================================================= -# YUNOHOST MULTIMEDIA INTEGRATION -#================================================= - -# Install or update the main directory yunohost.multimedia -# see https://github.com/YunoHost-Apps/yunohost.multimedia -ynh_multimedia_build_main_dir () { - wget -nv https://github.com/maniackcrudelis/yunohost.multimedia/archive/master.zip 2>&1 - unzip master.zip - sudo ./yunohost.multimedia-master/script/ynh_media_build.sh -} diff --git a/scripts/install b/scripts/install index 303f0eb..53189b8 100755 --- a/scripts/install +++ b/scripts/install @@ -23,6 +23,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC +mpd_port=$YNH_APP_ARG_MPD_EXT app=$YNH_APP_INSTANCE_NAME @@ -62,6 +63,16 @@ ynh_script_progression --message="Finding an available port..." port=$(ynh_find_port --port=6680) ynh_app_setting_set --app=$app --key=port --value=$port +if [ $mpd_port -eq 1 ]; then + mpd_port=$(ynh_find_port --port=6600) + 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 #================================================= @@ -95,10 +106,6 @@ ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated NGINX config ynh_add_nginx_config - -#================================================= -# SPECIFIC SETUP -#================================================= #================================================= # CREATE YUNOHOST DIRECTORIES #================================================= @@ -116,20 +123,18 @@ chown -R $app: "$work_dir" ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config -start_file="$final_path/env/bin/$app" -ynh_add_systemd_config #--others_var="conf_file start_file" substitute __CONF_FILE__ by $conf_file + +ynh_add_systemd_config #================================================= # MODIFY A CONFIG FILE #================================================= ynh_script_progression --message="Setup config file..." -cp ../conf/app.conf "$conf_file" +cache_dir=$work_dir/cache +data_dir=$work_dir/data -ynh_replace_string --match_string="__PORT__" --replace_string=$port --target_file="$conf_file" -ynh_replace_string --match_string="__MEDIADIR__" --replace_string=$media_dir --target_file="$conf_file" -ynh_replace_string --match_string="__CACHE_DIR__" --replace_string=$work_dir/cache --target_file="$conf_file" -ynh_replace_string --match_string="__DATA_DIR__" --replace_string=$work_dir/data --target_file="$conf_file" +ynh_add_config --template="../conf/app.conf" --destination="$conf_file" #================================================= # STORE THE CONFIG FILE CHECKSUM @@ -142,17 +147,20 @@ ynh_store_file_checksum --file="$conf_file" #================================================= # SECURE FILES AND DIRECTORIES #================================================= - -# user mopidy needs permission to mkdir on final_path -chown -R root: $final_path -chown $app: $final_path +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..." -yunohost service add $app --description "Mopidy music server" --log="/var/log/$app/$app.log" +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 +else + yunohost service add $app --description="Mopidy music server" --log="/var/log/$app/$app.log" +fi #================================================= # START SYSTEMD SERVICE @@ -188,10 +196,7 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= ynh_script_progression --message="Provide additional shell command..." -cp -a ../sources/extra_files/mopidyctl "$cmd_file" -ynh_replace_string --match_string="__APP__" --replace_string=$app --target_file="$cmd_file" -ynh_replace_string --match_string="__FINAL_PATH__" --replace_string=$final_path --target_file="$cmd_file" -ynh_replace_string --match_string="__CONF_FILE__" --replace_string=$conf_file --target_file="$cmd_file" +ynh_add_config --template="../sources/extra_files/mopidyctl" --destination="$cmd_file" chmod +x "$cmd_file" diff --git a/scripts/remove b/scripts/remove index 06fb303..c3ff50c 100755 --- a/scripts/remove +++ b/scripts/remove @@ -17,6 +17,7 @@ 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) @@ -66,6 +67,16 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated NGINX config ynh_remove_nginx_config + +#================================================= +# CLOSE A PORT +#================================================= + +if yunohost firewall list | grep -q "\- $mpd_port$" +then + ynh_script_progression --message="Closing port $mpd_port..." --weight=1 + ynh_exec_warn_less yunohost firewall disallow TCP $mpd_port +fi #================================================= # SPECIFIC REMOVE #================================================= diff --git a/scripts/restore b/scripts/restore index 1813a3e..6c6cf8f 100755 --- a/scripts/restore +++ b/scripts/restore @@ -27,6 +27,7 @@ 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) +mpd_port=$(ynh_app_setting_get --app=$app --key=mpd_port) # other variables media_dir="/home/yunohost.multimedia/share/Music" @@ -72,17 +73,29 @@ ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell -- #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=1 -ynh_restore_file --origin_path="$final_path" # /opt/yunohost/mopidy +ynh_restore_file --origin_path="$final_path" #================================================= # RESTORE USER RIGHTS #================================================= # Restore permissions on app files -#chown -R root: $final_path + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # SPECIFIC RESTORATION +#================================================= +# OPEN PORT +#================================================= + +if [ $mpd_port -ne 0 ]; then + ynh_script_progression --message="open MPD-port $mpd_port..." --weight=1 + ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $mpd_port +fi + #================================================= # REINSTALL DEPENDENCIES #================================================= @@ -104,7 +117,11 @@ systemctl enable $app.service --quiet #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description "Mopidy music server" --log="/var/log/$app/$app.log" +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 +else + yunohost service add $app --description="Mopidy music server" --log="/var/log/$app/$app.log" +fi #================================================= # RESTORE VARIOUS FILES diff --git a/scripts/upgrade b/scripts/upgrade index 707772a..c731d92 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -5,7 +5,6 @@ #================================================= # IMPORT GENERIC HELPERS #================================================= - source _common.sh source /usr/share/yunohost/helpers @@ -20,6 +19,7 @@ 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=$(ynh_app_setting_get --app=$app --key=port) +mpd_port=$(ynh_app_setting_get --app=$app --key=mpd_port) # other variables media_dir="/home/yunohost.multimedia/share/Music" @@ -44,11 +44,17 @@ upgrade_type=$(ynh_check_app_version_changed) # some legacy installs and you therefore want to initiaze stuff during upgrade) # -# If db_name doesn't exist, create it -#if [ -z "$db_name" ]; then -# db_name=$(ynh_sanitize_dbid --db_name=$app) -# ynh_app_setting_set --app=$app --key=db_name --value=$db_name -#fi +# 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 @@ -73,6 +79,14 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="stop" +#================================================= +# 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" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -82,6 +96,10 @@ then myynh_install fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -97,14 +115,6 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=11 ynh_exec_warn_less 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="$final_path" --use_shell --groups="audio" - #================================================= # SPECIFIC UPGRADE #================================================= @@ -113,46 +123,27 @@ ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell -- ynh_script_progression --message="Upgrading systemd configuration..." --weight=3 # Create a dedicated systemd config -start_file="$final_path/env/bin/$app" ynh_add_systemd_config #================================================= # MODIFY A CONFIG FILE #================================================= -ynh_backup_if_checksum_is_different --file="$conf_file" +cache_dir=$work_dir/cache +data_dir=$work_dir/data -cp ../conf/app.conf "$conf_file" - -ynh_replace_string --match_string="__PORT__" --replace_string=$port --target_file="$conf_file" -ynh_replace_string --match_string="__MEDIADIR__" --replace_string=$media_dir --target_file="$conf_file" -ynh_replace_string --match_string="__CACHE_DIR__" --replace_string=$work_dir/cache --target_file="$conf_file" -ynh_replace_string --match_string="__DATA_DIR__" --replace_string=$work_dir/data --target_file="$conf_file" - -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= - -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$conf_file" - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -# siwi okay - -# user mopidy needs permission to mkdir on final_path -chown -R root: $final_path -chown $app: $final_path +ynh_add_config --template="../conf/app.conf" --destination="$conf_file" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description "Mopidy music server" --log="/var/log/$app/$app.log" +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 +else + yunohost service add $app --description="Mopidy music server" --log="/var/log/$app/$app.log" +fi #================================================= # START SYSTEMD SERVICE @@ -173,10 +164,7 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= ynh_script_progression --message="Provide additional shell comand..." -cp -a ../sources/extra_files/mopidyctl "$cmd_file" -ynh_replace_string --match_string="__APP__" --replace_string=$app --target_file="$cmd_file" -ynh_replace_string --match_string="__FINAL_PATH__" --replace_string=$final_path --target_file="$cmd_file" -ynh_replace_string --match_string="__CONF_FILE__" --replace_string=$conf_file --target_file="$cmd_file" +ynh_add_config --template="../sources/extra_files/mopidyctl" --destination="$cmd_file" chmod +x "$cmd_file"