diff --git a/README.md b/README.md index bfc75d7..42033b0 100644 --- a/README.md +++ b/README.md @@ -16,31 +16,17 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -Play music, podcasts and radio programs from local disk and various streaming services +Mopidy is an extensible music server written in Python. -**Shipped version:** 3.4.2~ynh3 +Mopidy plays music from local disk, Spotify, SoundCloud, Google Play Music, and more. You edit the playlist from any phone, tablet, or computer using a variety of MPD and web clients. + + +**Shipped version:** 3.4.2~ynh4 ## Screenshots ![Screenshot of Mopidy](./doc/screenshots/mopidy_screenshot1.png) -## Disclaimers / important information - -* This installation is shipped with various extensions: - * [MusicBox-Webclient](https://mopidy.com/ext/musicbox-webclient/) to control mopidy from your web browser - * [local](https://mopidy.com/ext/local/) to make your private music collection on `/home/yunohost.multimedia/share/Music/` browseable and searchable - * [YouTube](https://pypi.org/project/Mopidy-YouTube/) to play sound from YouTube - * [YTMusic](https://music.youtube.com/) to access Google’s streaming music named [YouTube Music](https://music.youtube.com/) - * [Podcast-iTunes](https://mopidy.com/ext/podcast-itunes/) to search and browse podcasts from the Apple iTunes Store. - * [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.) -* All streams are played on the servers local audio hardware. The web interface is only a kind of remote control. Threrefore it should not be used with VPS or other servers that have no real audio hardware -* To rebuild the database of your local music collection enter `sudo mopidyctl local scan`. -* To list current settings enter `sudo mopidyctl config`. -* Edit the file `/opt/yunohost/mopidy/mopidy.conf` to adjust Mopidy's configuration. - ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index f0a200b..63cf3c5 100644 --- a/README_fr.md +++ b/README_fr.md @@ -16,31 +16,17 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po ## Vue d’ensemble -Écouter de la musique, des podcasts et des programmes radio depuis le disque local et divers services de streaming +Mopidy is an extensible music server written in Python. -**Version incluse :** 3.4.2~ynh3 +Mopidy plays music from local disk, Spotify, SoundCloud, Google Play Music, and more. You edit the playlist from any phone, tablet, or computer using a variety of MPD and web clients. + + +**Version incluse :** 3.4.2~ynh4 ## Captures d’écran ![Capture d’écran de Mopidy](./doc/screenshots/mopidy_screenshot1.png) -## Avertissements / informations importantes - -* This installation is shipped with various extensions: - * [MusicBox-Webclient](https://mopidy.com/ext/musicbox-webclient/) to control mopidy from your web browser - * [local](https://mopidy.com/ext/local/) to make your private music collection on `/home/yunohost.multimedia/share/Music/` browseable and searchable - * [YouTube](https://pypi.org/project/Mopidy-YouTube/) to play sound from YouTube - * [YTMusic](https://music.youtube.com/) to access Google’s streaming music named [YouTube Music](https://music.youtube.com/) - * [Podcast-iTunes](https://mopidy.com/ext/podcast-itunes/) to search and browse podcasts from the Apple iTunes Store. - * [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.) -* All streams are played on the servers local audio hardware. The web interface is only a kind of remote control. Threrefore it should not be used with VPS or other servers that have no real audio hardware -* To rebuild the database of your local music collection enter `sudo mopidyctl local scan`. -* To list current settings enter `sudo mopidyctl config`. -* Edit the file `/opt/yunohost/mopidy/mopidy.conf` to adjust Mopidy's configuration. - ## Documentations et ressources * Site officiel de l’app : diff --git a/check_process b/check_process deleted file mode 100644 index f973dc4..0000000 --- a/check_process +++ /dev/null @@ -1,25 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - path="/path" - is_public=1 - mpd_ext=1 - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - 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 diff --git a/conf/app.conf b/conf/app.conf index 1c51c13..9384c02 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -2,9 +2,9 @@ # http://docs.mopidy.com/ [core] -cache_dir = __DATADIR__/cache +cache_dir = __DATA_DIR__/cache #config_dir = -data_dir = __DATADIR__/data +data_dir = __DATA_DIR__/data #max_tracklist_length = 10000 #restore_state = false @@ -159,7 +159,7 @@ favorite_stations = 'bbcworldservice, bbcradio4, bbcradio3, bbcradio2, bbcradio1 enabled = true base_url = http://itunes.apple.com/ country = DE -explicit = +explicit = charts = audioPodcasts charts_limit = 20 search_limit = 20 @@ -168,7 +168,7 @@ retries = 3 [podcast] enabled = true -browse_root = __DATADIR__/data/podcast/bbc.opml +browse_root = __DATA_DIR__/data/podcast/bbc.opml #browse_order = desc #lookup_order = asc #cache_size = 64 @@ -185,4 +185,4 @@ auth_token = ? [mpd] enabled = __MPD_STATE__ hostname = 0.0.0.0 -port = __MPD_PORT__ +port = __PORT_MPD__ diff --git a/conf/nginx.conf b/conf/nginx.conf index a434d4a..1f093f0 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,41 +1,41 @@ location /mopidy/ws { - proxy_pass http://127.0.0.1:__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://127.0.0.1:__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__/ { - proxy_pass http://127.0.0.1:__PORT__/musicbox_webclient/; - proxy_http_version 1.1; - proxy_set_header Host $host; + proxy_pass http://127.0.0.1:__PORT__/musicbox_webclient/; + proxy_http_version 1.1; + proxy_set_header Host $host; - # Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; } location /musicbox_webclient/ { - proxy_pass http://127.0.0.1:__PORT__; - proxy_http_version 1.1; - proxy_set_header Host $host; + proxy_pass http://127.0.0.1:__PORT__; + proxy_http_version 1.1; + proxy_set_header Host $host; - # Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; } location /local/ { - proxy_pass http://127.0.0.1:__PORT__; - proxy_http_version 1.1; - proxy_set_header Host $host; + proxy_pass http://127.0.0.1:__PORT__; + proxy_http_version 1.1; + proxy_set_header Host $host; - # Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; } diff --git a/conf/raspberry.conf b/conf/raspberry.conf index a07007d..e329294 100644 --- a/conf/raspberry.conf +++ b/conf/raspberry.conf @@ -1,8 +1,6 @@ - [raspberry-gpio] enabled = false bcm5 = play_pause,active_low,250 bcm6 = volume_down,active_low,250 bcm16 = next,active_low,250 bcm20 = volume_up,active_low,250 - diff --git a/conf/systemd.service b/conf/systemd.service index de7d4be..95c2c82 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -11,7 +11,7 @@ After=sound.target [Service] User=__APP__ PermissionsStartOnly=true -ExecStart=__FINALPATH__/env/bin/__APP__ --config __FINALPATH__/__APP__.conf +ExecStart=__INSTALL_DIR__/venv/bin/__APP__ --config __INSTALL_DIR__/__APP__.conf [Install] WantedBy=multi-user.target diff --git a/doc/ADMIN.md b/doc/ADMIN.md new file mode 100644 index 0000000..82ed68d --- /dev/null +++ b/doc/ADMIN.md @@ -0,0 +1,14 @@ +* This installation is shipped with various extensions: + * [MusicBox-Webclient](https://mopidy.com/ext/musicbox-webclient/) to control mopidy from your web browser + * [local](https://mopidy.com/ext/local/) to make your private music collection on `/home/yunohost.multimedia/share/Music/` browseable and searchable + * [YouTube](https://pypi.org/project/Mopidy-YouTube/) to play sound from YouTube + * [YTMusic](https://music.youtube.com/) to access Google’s streaming music named [YouTube Music](https://music.youtube.com/) + * [Podcast-iTunes](https://mopidy.com/ext/podcast-itunes/) to search and browse podcasts from the Apple iTunes Store. + * [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.) +* All streams are played on the servers local audio hardware. The web interface is only a kind of remote control. Threrefore it should not be used with VPS or other servers that have no real audio hardware +* To rebuild the database of your local music collection enter `sudo mopidyctl local scan`. +* To list current settings enter `sudo mopidyctl config`. +* Edit the file `/opt/yunohost/mopidy/mopidy.conf` to adjust Mopidy's configuration. diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..6f9a967 --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1,3 @@ +Mopidy is an extensible music server written in Python. + +Mopidy plays music from local disk, Spotify, SoundCloud, Google Play Music, and more. You edit the playlist from any phone, tablet, or computer using a variety of MPD and web clients. diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index e7c4149..0000000 --- a/doc/DISCLAIMER.md +++ /dev/null @@ -1,14 +0,0 @@ -* This installation is shipped with various extensions: - * [MusicBox-Webclient](https://mopidy.com/ext/musicbox-webclient/) to control mopidy from your web browser - * [local](https://mopidy.com/ext/local/) to make your private music collection on `/home/yunohost.multimedia/share/Music/` browseable and searchable - * [YouTube](https://pypi.org/project/Mopidy-YouTube/) to play sound from YouTube - * [YTMusic](https://music.youtube.com/) to access Google’s streaming music named [YouTube Music](https://music.youtube.com/) - * [Podcast-iTunes](https://mopidy.com/ext/podcast-itunes/) to search and browse podcasts from the Apple iTunes Store. - * [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.) -* All streams are played on the servers local audio hardware. The web interface is only a kind of remote control. Threrefore it should not be used with VPS or other servers that have no real audio hardware -* To rebuild the database of your local music collection enter `sudo mopidyctl local scan`. -* To list current settings enter `sudo mopidyctl config`. -* Edit the file `/opt/yunohost/mopidy/mopidy.conf` to adjust Mopidy's configuration. diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 148eb31..0000000 --- a/manifest.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "id": "mopidy", - "name": "Mopidy", - "packaging_format": 1, - "description": { - "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.4.2~ynh3", - "url": "https://www.mopidy.com", - "upstream": { - "license": "Apache-2.0", - "website": "https://www.mopidy.com", - "admindoc": "https://docs.mopidy.com/en/latest", - "code": "https://github.com/mopidy/mopidy" - }, - "license": "Apache-2.0", - "maintainer": { - "name": "siwinter", - "email": "siegfried.winter@arcor.de" - }, - "previous_maintainer": { - "name": "cyp", - "email": "cyp@rouquin.me" - }, - "requirements": { - "yunohost": ">= 11.2" - }, - "multi_instance": false, - "services": [ - "nginx" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "path", - "type": "path", - "example": "/mopidy", - "default": "/mopidy" - }, - { - "name": "is_public", - "type": "boolean", - "help": { - "en": "Public app can be used by anonymous visitors.", - "fr": "L'application publique peut être utilisée par des visiteurs anonymes." - }, - "default": false - }, - { - "name": "mpd_ext", - "type": "boolean", - "ask": { - "en": "Activate MPD extension (this will open port 6600)", - "fr": "Activer l'extension MPD (cela ouvrira le port 6600)" - }, - "default": false - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..55a707b --- /dev/null +++ b/manifest.toml @@ -0,0 +1,96 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + +packaging_format = 2 + +id = "mopidy" +name = "Mopidy" +description.en = "Play music, podcasts and radio programs from local disk and various streaming services" +description.fr = "Écouter de la musique, des podcasts et des programmes radio depuis le disque local et divers services de streaming" + +version = "3.4.2~ynh4" + +maintainers = ["siwinter"] + +[upstream] +license = "Apache-2.0" +website = "https://www.mopidy.com" +admindoc = "https://docs.mopidy.com/en/latest" +code = "https://github.com/mopidy/mopidy" + +[integration] +yunohost = ">= 11.2" +architectures = "all" +multi_instance = false +ldap = false +sso = false +disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... +ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... + +[install] + [install.domain] + type = "domain" + + [install.path] + type = "path" + default = "/mopidy" + + [install.init_main_permission] + help.en = "Public app can be used by anonymous visitors." + help.fr = "L'application publique peut être utilisée par des visiteurs anonymes." + type = "group" + default = false + + [install.mpd_ext] + ask.en = "Activate MPD extension (this will open port 6600)" + ask.fr = "Activer l'extension MPD (cela ouvrira le port 6600)" + type = "boolean" + default = false + +[resources] + [resources.sources.main] + url = "http://none" + prefetch = false + autoupdate.strategy = "latest_github_release" + + [resources.system_user] + + [resources.install_dir] + + [resources.data_dir] + subdirs = ["data", "cache"] + + [resources.permissions] + main.url = "/" + + [resources.ports] + main.default = 6680 + mpd.default = 6600 + + [resources.apt] + packages = [ + "acl", + "build-essential", + "debconf", + "gir1.2-gst-plugins-base-1.0", + "gir1.2-gstreamer-1.0", + "git", + "gstreamer1.0-alsa", + "gstreamer1.0-plugins-good", + "gstreamer1.0-plugins-ugly", + "gstreamer1.0-pulseaudio", + "gstreamer1.0-tools", + "libcairo2-dev", + "libgirepository1.0-dev", + "lsb-base", + "postgresql-contrib", + "postgresql", + "python3-dev", + "python3-gst-1.0", + "python3-pip", + "python3-pkg-resources", + "python3-pykka", + "python3-requests", + "python3-tornado", + "python3-venv", + ] diff --git a/scripts/_common.sh b/scripts/_common.sh index 5c74c49..acef04d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,46 +4,38 @@ # 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 libgirepository1.0-dev libcairo2-dev" +boolstr=(false true) + +cmd_file="/usr/local/bin/mopidyctl" + +media_dir="/home/yunohost.multimedia/share/Music" #================================================= # PERSONAL HELPERS #================================================= -python_version="$(python3 -V | cut -d' ' -f2 | cut -d. -f1-2)" +_mopidy_install() { + python3 -m venv --upgrade "$install_dir/venv" + chown -R "$app" "$install_dir" -myynh_install() { - python3 -m venv "${final_path}/env" - chown -R "$app" "$final_path" + venvpy="$install_dir/venv/bin/python3" - #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_exec_as "$app" "$venvpy" -m 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 - $final_path/env/bin/python3 -m pip install PyGObject + ynh_exec_as "$app" "$venvpy" -m pip install PyGObject - # install essential packages - 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.7 - ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy-YTMusic==0.3.8 - ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy-RadioNet==0.2.2 - ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy-Podcast==3.0.1 - ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy-Podcast-iTunes==3.0.1 - ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy-SoundCloud==3.0.2 - ynh_exec_as $app $final_path/env/bin/python3 -m pip install --no-cache-dir Mopidy-MPD==3.3.0 - ) + # install essential packages + ynh_exec_as "$app" "$venvpy" -m pip install --no-cache-dir \ + Mopidy=="$(ynh_app_upstream_version)" \ + Mopidy-local==3.2.1 \ + Mopidy-MusicBox-Webclient==3.1.0 \ + Mopidy-YouTube==3.7 \ + Mopidy-YTMusic==0.3.8 \ + Mopidy-RadioNet==0.2.2 \ + Mopidy-Podcast==3.0.1 \ + Mopidy-Podcast-iTunes==3.0.1 \ + Mopidy-SoundCloud==3.0.2 \ + Mopidy-MPD==3.3.0 } #================================================= diff --git a/scripts/backup b/scripts/backup index 610ad7e..74c91d2 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,24 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -domain=$(ynh_app_setting_get --app=$app --key=domain) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -37,13 +19,13 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE DATA DIR #================================================= -ynh_backup --src_path="$datadir" --is_big +ynh_backup --src_path="$data_dir" --is_big #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index 4cf96d3..4f2e450 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,62 +9,6 @@ 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..." --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) - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=15 - -# 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 #================================================= @@ -79,33 +23,14 @@ ynh_systemd_action --service_name=$app --action="stop" #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." --weight=15 -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 +ynh_change_url_nginx_config # 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" - - #adapt permissions for additional URIs - ynh_permission_url --permission="main" --add_url="$new_domain/mopidy/ws" --remove_url="$old_domain/mopidy/ws" - ynh_permission_url --permission="main" --add_url="$new_domain/local" --remove_url="$old_domain/local" - ynh_permission_url --permission="main" --add_url="$new_domain/musicbox_webclient" --remove_url="$old_domain/musicbox_webclient" +if [ $change_domain -eq 1 ]; then + #adapt permissions for additional URIs + ynh_permission_url --permission="main" --add_url="$new_domain/mopidy/ws" --remove_url="$old_domain/mopidy/ws" + ynh_permission_url --permission="main" --add_url="$new_domain/local" --remove_url="$old_domain/local" + ynh_permission_url --permission="main" --add_url="$new_domain/musicbox_webclient" --remove_url="$old_domain/musicbox_webclient" fi #================================================= @@ -115,14 +40,7 @@ fi #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name="$app" --action="start" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 45d67a5..98b5cbb 100755 --- a/scripts/install +++ b/scripts/install @@ -10,100 +10,53 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# MANAGE SCRIPT FAILURE +# INITIALIZE AND STORE SETTINGS #================================================= -ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors +mpd_state="${boolstr[mpd_ext]}" +ynh_app_setting_set --app="$app" --key=mpd_state --value="$mpd_state" #================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST +# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC) #================================================= - -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 - +# DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -ynh_script_progression --message="Validating installation parameters..." +ynh_script_progression --message="Setting up source files..." --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..." - -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# FIND AND OPEN A PORT -#================================================= -ynh_script_progression --message="Finding an available port..." - -# Find 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_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 - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=30 - -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -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" #================================================= # 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 +_mopidy_install +# patch -u $install_dir/venv/lib/python$python_version/site-packages/mopidy/__main__.py -i ../sources/patches/__main__.patch --forward -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R "$app:www-data" "$install_dir" + +chmod -R o-rwx "$data_dir" +chown -R "$app:www-data" "$data_dir" #================================================= -# NGINX CONFIGURATION +# ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." +ynh_script_progression --message="Adding a configuration file..." -# Create a dedicated NGINX config -ynh_add_nginx_config +ynh_add_config --template="app.conf" --destination="$install_dir/$app.conf" + +chmod 400 "$install_dir/$app.conf" +chown "$app:$app" "$install_dir/$app.conf" + +#================================================= +# PROVIDE ADDITIONAL SHELL COMMAND +#================================================= +ynh_script_progression --message="Provide additional shell command..." + +ynh_add_config --template="../sources/extra_files/mopidyctl" --destination="$cmd_file" + +chmod +x "$cmd_file" #================================================= # SPECIFIC SETUP @@ -112,123 +65,74 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Building multimedia directory..." -media_dir="/home/yunohost.multimedia/share/Music" ynh_multimedia_build_main_dir # /home/yunohost.multimedia -#================================================= -# 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 -#================================================= -ynh_script_progression --message="Configuring a systemd service..." - -# Create a dedicated systemd config -ynh_add_systemd_config - -#================================================= -# PROVIDE ADDITIONAL SHELL COMMAND -#================================================= -ynh_script_progression --message="Provide additional shell command..." - -cmd_file="/usr/local/bin/mopidyctl" -ynh_add_config --template="../sources/extra_files/mopidyctl" --destination="$cmd_file" - -chmod +x "$cmd_file" - #================================================= # PROVIDE EXAMPLES #================================================= -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" +mkdir -p "$data_dir/data/m3u/" +cp -a ../sources/extra_files/radio_international.m3u "$data_dir/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" +mkdir -p "$data_dir/data/podcast" +cp -a ../sources/extra_files/bbc.opml "$data_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) +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 +#================================================= +# SYSTEM CONFIGURATION +#================================================= +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 + +# Create a dedicated NGINX config +ynh_add_nginx_config + +# Create a dedicated systemd config +ynh_add_systemd_config +if [ "$mpd_ext" -eq 1 ]; then + yunohost service add "$app" --description="Mopidy music server" --needs_exposed_ports="$port_mpd" +else + yunohost service add "$app" --description="Mopidy music server" +fi + +#================================================= +# OPEN PORT +#================================================= +if [ "$mpd_ext" -eq 1 ]; then + ynh_script_progression --message="Opening MPD-port $port_mpd..." --weight=1 + ynh_exec_warn_less yunohost firewall allow --no-upnp TCP "$port_mpd" +fi + +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Configuring domain-wide permissions..." + +ynh_permission_url --permission="main" --add_url="$domain/mopidy/ws" +ynh_permission_url --permission="main" --add_url="$domain/musicbox_webclient" +ynh_permission_url --permission="main" --add_url="$domain/local" + +#================================================= +# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...) #================================================= # SCAN LOCAL MEDIA DIRECTORY #================================================= -ynh_script_progression --message="Scan local media directory..." +ynh_script_progression --message="Running the initial local media directory..." "$cmd_file" local scan 2>&1 -#================================================= -# GENERIC FINALIZATION -#================================================= -# 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" --needs_exposed_ports=$mpd_port -else - yunohost service add $app --description="Mopidy music server" -fi - #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" - -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring permissions..." - -# 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 - -ynh_permission_url --permission="main" --add_url="$domain/mopidy/ws" -ynh_permission_url --permission="main" --add_url="$domain/musicbox_webclient" -ynh_permission_url --permission="main" --add_url="$domain/local" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." - -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name="$app" --action="start" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index d78bc55..395a06a 100755 --- a/scripts/remove +++ b/scripts/remove @@ -10,91 +10,24 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=4 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -port=$(ynh_app_setting_get --app=$app --key=port) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -mpd_port=$(ynh_app_setting_get --app=$app --key=mpd_port) - -#================================================= -# STANDARD REMOVE -#================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST +# REMOVE SYSTEM CONFIGURATIONS #================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # 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=1 - yunohost service remove $app +if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then + ynh_script_progression --message="Removing $app service integration..." --weight=1 + yunohost service remove "$app" fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=4 - # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# 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=2 - # 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 -#================================================= - -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 -#================================================= -# REMOVE VARIOUS FILES -#================================================= -ynh_script_progression --message="Removing various files..." - ynh_secure_remove --file="/usr/local/bin/mopidyctl" -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=2 - -# Delete a system user -ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 72c6366..6084a3f 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,133 +10,62 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# 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) -mpd_port=$(ynh_app_setting_get --app=$app --key=mpd_port) -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 " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# 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" - #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=1 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= ynh_script_progression --message="Restoring the data directory..." -ynh_restore_file --origin_path="$datadir" --not_mandatory +ynh_restore_file --origin_path="$data_dir" --not_mandatory -mkdir -p $datadir - -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:www-data "$datadir" +chmod 750 "$data_dir" +chmod -R o-rwx "$data_dir" +chown -R "$app:www-data" "$data_dir" #================================================= -# SPECIFIC RESTORATION +# RESTORE SYSTEM CONFIGURATIONS #================================================= -# 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_script_progression --message="Restoring system configurations related to $app..." --weight=1 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore_file --origin_path="/usr/local/bin/mopidyctl" # /usr/local/bin/mopidyctl + +ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +systemctl enable "$app.service" --quiet +if [ "$mpd_ext" -eq 1 ]; then + yunohost service add "$app" --description="Mopidy music server" --needs_exposed_ports=$port_mpd +else + yunohost service add "$app" --description="Mopidy music server" +fi + #================================================= # 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 +if [ "$mpd_ext" -eq 1 ]; then + ynh_script_progression --message="Opening MPD-port $port_mpd..." --weight=1 + ynh_exec_warn_less yunohost firewall allow --no-upnp TCP "$port_mpd" fi -#================================================= -# RESTORE VARIOUS FILES -#================================================= -ynh_script_progression --message="Restoring various files..." - -ynh_restore_file --origin_path="/usr/local/bin/mopidyctl" # /usr/local/bin/mopidyctl - -#================================================= -# 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=1 - -if [ $mpd_port -ne 0 ]; then - yunohost service add $app --description="Mopidy music server" --needs_exposed_ports=$mpd_port -else - yunohost service add $app --description="Mopidy music server" -fi - -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 - -ynh_systemd_action --service_name=$app --action="start" - #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX AND PHP-FPM +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 + +ynh_systemd_action --service_name="$app" --action="start" ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index cd479b8..03799ae 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -10,43 +10,13 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# LOAD SETTINGS +# STANDARD UPGRADE STEPS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=2 - -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=$(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" -cmd_file="/usr/local/bin/mopidyctl" - +# ENSURE DOWNWARD COMPATIBILITY #================================================= -# CHECK VERSION -#================================================= -ynh_script_progression --message="Checking version..." +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -upgrade_type=$(ynh_check_app_version_changed) - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=7 - -# 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 +ynh_secure_remove "$install_dir/env" #================================================= # STANDARD UPGRADE STEPS @@ -55,108 +25,59 @@ ynh_abort_if_errors #================================================= 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_systemd_action --service_name="$app" --action="stop" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Upgrading source files..." -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Upgrading source files..." - myynh_install -fi +_mopidy_install -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R "$app:www-data" "$install_dir" -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=11 - -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 - -# Create a dedicated NGINX config -ynh_add_nginx_config - -#================================================= -# SPECIFIC UPGRADE #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Updating a configuration file..." -ynh_add_config --template="../conf/app.conf" --destination="$final_path/$app.conf" +ynh_add_config --template="../conf/app.conf" --destination="$install_dir/$app.conf" -chmod 400 "$final_path/$app.conf" -chown $app:$app "$final_path/$app.conf" +chmod 400 "$install_dir/$app.conf" +chown "$app:$app" "$install_dir/$app.conf" #================================================= -# PROVIDE ADDITIONAL SHELL COMMAND +# 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 +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=3 +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 + +# Create a dedicated NGINX config +ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config - -#================================================= -# 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" --needs_exposed_ports=$mpd_port +if [ "$mpd_ext" -eq 1 ]; then + yunohost service add "$app" --description="Mopidy music server" --needs_exposed_ports="$port_mpd" else - yunohost service add $app --description="Mopidy music server" + yunohost service add "$app" --description="Mopidy music server" +fi + +#================================================= +# OPEN PORT +#================================================= +if [ "$mpd_ext" -eq 1 ]; then + ynh_script_progression --message="Opening MPD-port $port_mpd..." --weight=1 + ynh_exec_warn_less yunohost firewall allow --no-upnp TCP "$port_mpd" fi #================================================= @@ -164,14 +85,7 @@ fi #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." - -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name="$app" --action="start" #================================================= # END OF SCRIPT diff --git a/sources/extra_files/mopidyctl b/sources/extra_files/mopidyctl index debe6e0..8131497 100644 --- a/sources/extra_files/mopidyctl +++ b/sources/extra_files/mopidyctl @@ -1,9 +1,9 @@ #!/bin/sh SELF=$(basename $0) -DAEMON="__FINAL_PATH__/env/bin/mopidy" +DAEMON="__INSTALL_DIR__/venv/bin/mopidy" DAEMON_USER="__APP__" -CONFIG_FILES="__FINAL_PATH__/__APP__.conf" +CONFIG_FILES="__INSTALL_DIR__/__APP__.conf" CMD="$DAEMON --config $CONFIG_FILES $@" if [ $# -eq 0 ]; then diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..fe402f3 --- /dev/null +++ b/tests.toml @@ -0,0 +1,11 @@ +test_format = 1.0 + +[default] + + # ------------ + # Tests to run + # ------------ + + args.superuser = "package_checker" + + test_upgrade_from.cfc42dd5.name = "Last manifestv1 package"