From 751b36fbf6cf5f8199d94ccb9adb5b5fa7263e38 Mon Sep 17 00:00:00 2001 From: magikcypress Date: Tue, 7 Mar 2017 17:29:01 +0100 Subject: [PATCH] Ajout de la conf nginx et suppression de certaines options dans le manifest --- conf/nginx.conf | 12 +++++++++ manifest.json | 18 ------------- scripts/.fonctions | 9 +++++++ scripts/install | 63 +++++++++++++++++++++++++--------------------- 4 files changed, 55 insertions(+), 47 deletions(-) create mode 100644 conf/nginx.conf diff --git a/conf/nginx.conf b/conf/nginx.conf new file mode 100644 index 0000000..14a7687 --- /dev/null +++ b/conf/nginx.conf @@ -0,0 +1,12 @@ +location __PATHTOCHANGE__ { + alias __FINALPATH__/; + index index.php; + + if (!-e $request_filename) + { + rewrite ^(.+)$ http://__DOMAINNAME__:6680/musicbox_webclient last; + } + + #--PRIVATE--# Include SSOWAT user panel. + #--PRIVATE--include conf.d/yunohost_panel.conf.inc; +} diff --git a/manifest.json b/manifest.json index 6084bde..8711423 100644 --- a/manifest.json +++ b/manifest.json @@ -40,15 +40,6 @@ }, "example": "johndoe" }, - { - "name": "is_spotify", - "ask": { - "en": "You want to use Spotify ?", - "fr": "Voulez vous utiliser Spotify ?" - }, - "choices": ["Yes", "No"], - "default": "No" - }, { "name": "spotify_user", "type": "user", @@ -83,15 +74,6 @@ "fr": "ID client secret Spotify" } }, - { - "name": "is_soundcloud", - "ask": { - "en": "You want to use Soundcloud ?", - "fr": "Voulez vous utiliser Soundcloud ?" - }, - "choices": ["Yes", "No"], - "default": "No" - }, { "name": "soundcloud_id", "type": "id", diff --git a/scripts/.fonctions b/scripts/.fonctions index aa4a6b6..e6c8086 100644 --- a/scripts/.fonctions +++ b/scripts/.fonctions @@ -49,4 +49,13 @@ CHECK_USER () { # Vérifie la validité de l'user admin CHECK_DOMAINPATH () { # Vérifie la disponibilité du path et du domaine. sudo yunohost app checkurl $domain$path -a $app +} + +CHECK_FINALPATH () { # Vérifie que le dossier de destination n'est pas déjà utilisé. + final_path=/var/lib/mopidy/www + if [ -e "$final_path" ] + then + echo "This path already contains a folder" >&2 + false + fi } \ No newline at end of file diff --git a/scripts/install b/scripts/install index cc0fd2a..bc9b5db 100644 --- a/scripts/install +++ b/scripts/install @@ -8,20 +8,13 @@ source .fonctions # Charge les fonctions génériques habituellement utilisées TRAP_ON # Active trap pour arrêter le script si une erreur est détectée. domain=$YNH_APP_ARG_DOMAIN +path=$YNH_APP_ARG_PATH admin_mopidy=$YNH_APP_ARG_ADMIN_MOPIDY - -if [ "$is_spotify" = "Yes" ]; -then - spotify_user=$YNH_APP_ARG_SPOTIFY_USER - spotify_pass=$YNH_APP_ARG_SPOTIFY_PASS - spotify_id=$YNH_APP_ARG_SPOTIFY_ID - spotify_id_secret=$YNH_APP_ARG_SPOTIFY_ID_SECRET -fi - -if [ "$is_soundcloud" = "Yes" ]; -then - soundcloud_id=$YNH_APP_ARG_SOUNDCLOUD_ID -fi +spotify_user=$YNH_APP_ARG_SPOTIFY_USER +spotify_pass=$YNH_APP_ARG_SPOTIFY_PASS +spotify_id=$YNH_APP_ARG_SPOTIFY_ID +spotify_id_secret=$YNH_APP_ARG_SPOTIFY_ID_SECRET +soundcloud_id=$YNH_APP_ARG_SOUNDCLOUD_ID app=$YNH_APP_INSTANCE_NAME @@ -34,21 +27,16 @@ CHECK_USER "$admin_mopidy" # CHECK_DOMAINPATH +CHECK_FINALPATH + ynh_app_setting_set $app domain $domain +ynh_app_setting_set $app path $path ynh_app_setting_set $app admin $admin_mopidy - -if [ "$is_spotify" = "Yes" ]; -then - ynh_app_setting_set $app spotify_user $spotify_user - ynh_app_setting_set $app spotify_pass $spotify_pass - ynh_app_setting_set $app spotify_id $spotify_id - ynh_app_setting_set $app spotify_id_secret $spotify_id_secret -fi - -if [ "$is_soundcloud" = "Yes" ]; -then - ynh_app_setting_set $app soundcloud_id $soundcloud_id -fi +ynh_app_setting_set $app spotify_user $spotify_user +ynh_app_setting_set $app spotify_pass $spotify_pass +ynh_app_setting_set $app spotify_id $spotify_id +ynh_app_setting_set $app spotify_id_secret $spotify_id_secret +ynh_app_setting_set $app soundcloud_id $soundcloud_id # Add the archive’s GPG key: wget -q -O - https://apt.mopidy.com/mopidy.gpg | sudo apt-key add - @@ -65,7 +53,7 @@ sudo rm -fr /root/.config/mopidy/ ip_local=$(echo hostname -I | awk '{ print $1 }') sudo sed -i "s@__IPLOCAL__@$ip_local@g" ../conf/mopidy.conf -if [ "$is_spotify" = "Yes" ]; +if [ -n "$spotify_user" ]; then sudo sed -i '/[spotify]/r enabled = true' ../conf/mopidy.conf sudo sed -i "s@__USER_SPOTIFY__@$spotify_user@g" ../conf/mopidy.conf @@ -79,7 +67,7 @@ else sudo sed -i "s@__SECRET_SPOTIFY__@@g" ../conf/mopidy.conf fi -if [ "$is_soundcloud" = "Yes" ]; +if [ -n "$soundcloud_id" ]; then sudo sed -i "s@__SOUNDCLOUD__@$soundcloud_id@g" ../conf/mopidy.conf else @@ -103,4 +91,21 @@ sudo rm -fr mopidy-musicbox-webclient # Allow port sudo yunohost firewall allow TCP 6600 -sudo yunohost firewall allow TCP 6680 \ No newline at end of file +sudo yunohost firewall allow TCP 6680 + +# Copy config nginx +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf + +# Change file configuration for nginx +sudo sed -i "s@__PATHTOCHANGE__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf +sudo sed -i "s@__DOMAINNAME__@$domain@g" /etc/nginx/conf.d/$domain.d/$app.conf +sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/nginx/conf.d/$domain.d/$app.conf + +# Access public for curl +ynh_app_setting_set $app unprotected_uris "/" + +# Reload SSOwat configuration +sudo yunohost app ssowatconf + +# Reload Nginx and regenerate SSOwat conf +sudo service nginx reload \ No newline at end of file