diff --git a/conf/Tryad_Beauty.mp3 b/conf/Tryad_Beauty.mp3 old mode 100755 new mode 100644 diff --git a/conf/nginx.conf b/conf/nginx.conf index 04f8edc..c8dc0d4 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,9 +1,10 @@ location __PATHTOCHANGE__ { - alias __FINALPATH__; - # index index.html - rewrite ^ http://__DOMAINNAME__:6680/musicbox_webclient permanent; - - #--PRIVATE--# Include SSOWAT user panel. - #--PRIVATE--include conf.d/yunohost_panel.conf.inc; + proxy_pass http://127.0.0.1:6680/mopidy; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + #--PRIVATE--# Include SSOWAT user panel. + #--PRIVATE--include conf.d/yunohost_panel.conf.inc; } diff --git a/scripts/.fonctions b/scripts/.fonctions index 541fbed..7c3041d 100644 --- a/scripts/.fonctions +++ b/scripts/.fonctions @@ -115,4 +115,68 @@ SECURE_REMOVE () { # Suppression de dossier avec vérification des variable echo "No detected variable." >&2 return 1 fi +} + +# Remove fake package and its dependencies +# +# Dependencies will removed only if no other package need them. +# +# usage: ynh_remove_app_dependencies +ynh_remove_app_dependencies () { + dep_app=${app/_/-} # Replace all '_' by '-' + ynh_package_autoremove ${dep_app}-ynh-deps # Remove the fake package and its dependencies if they not still used. +} + +# Use logrotate to manage the logfile +# +# usage: ynh_use_logrotate [logfile] +# | arg: logfile - absolute path of logfile +# +# If no argument provided, a standard directory will be use. /var/log/${app} +# You can provide a path with the directory only or with the logfile. +# /parentdir/logdir/ +# /parentdir/logdir/logfile.log +# +# It's possible to use this helper several times, each config will added to same logrotate config file. +ynh_use_logrotate () { + if [ -n "$1" ]; then + if [ "$(echo ${1##*.})" == "log" ]; then # Keep only the extension to check if it's a logfile + logfile=$1 # In this case, focus logrotate on the logfile + else + logfile=$1/.log # Else, uses the directory and all logfile into it. + fi + else + logfile="/var/log/${app}/.log" # Without argument, use a defaut directory in /var/log + fi + cat > ./${app}-logrotate << EOF # Build a config file for logrotate +$logfile { + # Rotate if the logfile exceeds 100Mo + size 100M + # Keep 12 old log maximum + rotate 12 + # Compress the logs with gzip + compress + # Compress the log at the next cycle. So keep always 2 non compressed logs + delaycompress + # Copy and truncate the log to allow to continue write on it. Instead of move the log. + copytruncate + # Do not do an error if the log is missing + missingok + # Not rotate if the log is empty + notifempty + # Keep old logs in the same dir + noolddir +} +EOF + sudo mkdir -p $(dirname "$logfile") # Create the log directory, if not exist + cat ${app}-logrotate | sudo tee -a /etc/logrotate.d/$app > /dev/null # Append this config to the others for this app. If a config file already exist +} + +# Remove the app's logrotate config. +# +# usage: ynh_remove_logrotate +ynh_remove_logrotate () { + if [ -e "/etc/logrotate.d/$app" ]; then + sudo rm "/etc/logrotate.d/$app" + fi } \ No newline at end of file diff --git a/scripts/install b/scripts/install index 2f32d9f..68b78b4 100644 --- a/scripts/install +++ b/scripts/install @@ -136,18 +136,17 @@ sudo git clone https://github.com/pimusicbox/mopidy-musicbox-webclient cd mopidy-musicbox-webclient sudo python setup.py install -# Allow port -sudo yunohost firewall allow TCP 6600 -sudo yunohost firewall allow TCP 6680 - # Access public for curl ynh_app_setting_set $app unprotected_uris "/" -# Reload Nginx and regenerate SSOwat conf -sudo service nginx reload +# Reload Nginx +sudo systemctl reload nginx # Add Mopidy into YunoHost services sudo yunohost service add mopidy --log "/var/log/mopidy/mopidy.log" +# Add logrotate +ynh_use_logrotate + # Reload SSOwat configuration sudo yunohost app ssowatconf \ No newline at end of file diff --git a/scripts/remove b/scripts/remove index af5e356..78a90d0 100644 --- a/scripts/remove +++ b/scripts/remove @@ -40,13 +40,15 @@ SECURE_REMOVE '/tmp/$app-musicbox-webclient' SECURE_REMOVE '/var/www/$app' sudo rm -fr '/usr/local/lib/python2.7/dist-packages/Mopidy_MusicBox_Webclient-2.3.0-py2.7.egg' -# disallow firewall port -sudo yunohost firewall disallow TCP 6600 -sudo yunohost firewall disallow TCP 6680 - REMOVE_NGINX_CONF # Suppression de la configuration nginx +# remove logrotate +ynh_remove_logrotate + # Régénère la configuration de SSOwat sudo yunohost app ssowatconf +# reload nginx +sudo systemctl reload nginx + echo -e "\e[0m" # Restore normal color \ No newline at end of file diff --git a/scripts/restore b/scripts/restore index 1c8b9b7..70df11b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -55,5 +55,4 @@ sudo service mopidy restart sudo yunohost service add mopidy --log "/var/log/mopidy/mopidy.log" # Reload services -sudo service php5-fpm reload || true -sudo service nginx reload || true \ No newline at end of file +sudo systemctl reload nginx \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index e3b75e0..48e3849 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -30,4 +30,4 @@ sed -i "s@__FINALPATH__@$final_path/@g" ../conf/nginx.conf* sed -i "s@__DOMAINNAME__@$domain/@g" ../conf/nginx.conf* # Reload Nginx -sudo service nginx reload +sudo systemctl reload nginx \ No newline at end of file