diff --git a/conf/app.src b/conf/app.src new file mode 100644 index 0000000..248d26c --- /dev/null +++ b/conf/app.src @@ -0,0 +1,3 @@ +SOURCE_URL=https://github.com/ampache/ampache/archive/3.8.3.zip +SOURCE_SUM=1bfd98defb5e4451443b899504a59ceb97e12dd2c36804318e6bfdda7a76d60d +SOURCE_FORMAT=zip diff --git a/conf/nginx.conf b/conf/nginx.conf index a969e5b..043db70 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,6 +1,6 @@ -location PATHTOCHANGE { +location __PATH__ { - alias ALIASTOCHANGE; + alias __FINALPATH__/; if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; @@ -8,13 +8,13 @@ location PATHTOCHANGE { #enable subsonic api if ( !-d $request_filename ) { - rewrite ^PATH2TOCHANGE/rest/(.*)\.view$ PATH2TOCHANGE/rest/index.php?action=$1 last; - rewrite ^PATH2TOCHANGE/rest/fake/(.+)$ PATH2TOCHANGE/play/$1 last; + rewrite ^__PATH__rest/(.*)\.view$ __PATH__rest/index.php?action=$1 last; + rewrite ^__PATH__rest/fake/(.+)$ __PATH__play/$1 last; } - rewrite ^PATH2TOCHANGE/play/ssid/(.*)/type/(.*)/oid/([0-9]+)/uid/([0-9]+)/client/(.*)/noscrobble/([0-1])/player/(.*)/name/(.*)$ PATH2TOCHANGE/play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&noscrobble=$6&player=$7&name=$8 last; - rewrite ^PATH2TOCHANGE/play/ssid/(.*)/type/(.*)/oid/([0-9]+)/uid/([0-9]+)/client/(.*)/noscrobble/([0-1])/bitrate/([0-9]+)/player/(.*)/name/(.*)$ PATH2TOCHANGE/play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&noscrobble=$6&bitrate=$7player=$8&name=$9 last; - rewrite ^PATH2TOCHANGE/play/ssid/(.*)/type/(.*)/oid/([0-9]+)/uid/([0-9]+)/client/(.*)/noscrobble/([0-1])/transcode_to/(w+)/bitrate/([0-9]+)/player/(.*)/name/(.*)$ PATH2TOCHANGE/play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&noscrobble=$6&transcode_to=$7&bitrate=$8&player=$9&name=$10 last; + rewrite ^__PATH__play/ssid/(.*)/type/(.*)/oid/([0-9]+)/uid/([0-9]+)/client/(.*)/noscrobble/([0-1])/player/(.*)/name/(.*)$ __PATH__play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&noscrobble=$6&player=$7&name=$8 last; + rewrite ^__PATH__play/ssid/(.*)/type/(.*)/oid/([0-9]+)/uid/([0-9]+)/client/(.*)/noscrobble/([0-1])/bitrate/([0-9]+)/player/(.*)/name/(.*)$ __PATH__play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&noscrobble=$6&bitrate=$7player=$8&name=$9 last; + rewrite ^__PATH__play/ssid/(.*)/type/(.*)/oid/([0-9]+)/uid/([0-9]+)/client/(.*)/noscrobble/([0-1])/transcode_to/(w+)/bitrate/([0-9]+)/player/(.*)/name/(.*)$ __PATH__play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&noscrobble=$6&transcode_to=$7&bitrate=$8&player=$9&name=$10 last; index index.php; try_files $uri $uri/ index.php; @@ -28,20 +28,20 @@ location PATHTOCHANGE { fastcgi_param SCRIPT_FILENAME $request_filename; } - location ^~ PATH2TOCHANGE/bin/ { + location ^~ __PATH__bin/ { deny all; return 403; } - location ^~ PATH2TOCHANGE/config/ { + location ^~ __PATH__config/ { deny all; return 403; } - rewrite ^PATH2TOCHANGE/play/ssid/(\w+)/type/(\w+)/oid/([0-9]+)/uid/([0-9]+)/name/(.*)$ PATH2TOCHANGE/play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&name=$5 last; - rewrite ^PATH2TOCHANGE/play/ssid/(\w+)/type/(\w+)/oid/([0-9]+)/uid/([0-9]+)/client/(.*)/noscrobble/([0-1])/name/(.*)$ PATH2TOCHANGE/play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&noscrobble=$6&name=$7 last; + rewrite ^__PATH__play/ssid/(\w+)/type/(\w+)/oid/([0-9]+)/uid/([0-9]+)/name/(.*)$ __PATH__play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&name=$5 last; + rewrite ^__PATH__play/ssid/(\w+)/type/(\w+)/oid/([0-9]+)/uid/([0-9]+)/client/(.*)/noscrobble/([0-1])/name/(.*)$ __PATH__play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&noscrobble=$6&name=$7 last; - location PATH2TOCHANGE/rest { + location __PATH__rest { limit_except GET POST { deny all; } diff --git a/manifest.json b/manifest.json index 4f32b84..7c90b4c 100644 --- a/manifest.json +++ b/manifest.json @@ -5,6 +5,7 @@ "en": "A web based audio/video streaming application", "fr": "Une application de streaming audio et vidéo" }, + "version": "1.0", "url": "http://ampache.org", "packaging_format": 1, "license": "free", diff --git a/scripts/_common.sh b/scripts/_common.sh index f602f2f..72d52a6 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -2,14 +2,10 @@ # Copy files to the right place ampache_ynh_getsources () { - version=$(cat upstream_version) - final_path=/var/www/$app mkdir -p $final_path/log - wget -O ../ampache.tar.gz https://github.com/ampache/ampache/archive/$version.tar.gz > /dev/null 2>&1 - tar xvzf ../ampache.tar.gz -C .. > /dev/null 2>&1 - cp -ar ../ampache-$version/. $final_path + ynh_setup_source $final_path cp ../conf/ampache.cfg.php $final_path/config/ampache.cfg.php } @@ -19,19 +15,10 @@ ampache_ynh_prepareconfig () { ynh_replace_string "yunouser" "$app" $final_path/config/ampache.cfg.php ynh_replace_string "yunopass" "$db_pwd" $final_path/config/ampache.cfg.php ynh_replace_string "yunobase" "$app" $final_path/config/ampache.cfg.php - ynh_replace_string "PATHTOCHANGE" "${path}" $final_path/config/ampache.cfg.php + ynh_replace_string "PATHTOCHANGE" "$path_url" $final_path/config/ampache.cfg.php ynh_replace_string "DOMAINTOCHANGE" "$domain" $final_path/config/ampache.cfg.php } -# Modify Nginx configuration file and copy it to Nginx conf directory -ampache_ynh_preparenginx () { - path2=$(if [ "$path" == "/" ] ; then echo "" ; else echo "$path" ; fi) - ynh_replace_string "PATHTOCHANGE" "${path}" ../conf/nginx.conf* - ynh_replace_string "PATH2TOCHANGE" "${path2}" ../conf/nginx.conf* - ynh_replace_string "ALIASTOCHANGE" "$final_path/" ../conf/nginx.conf* - cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf -} - # Ampache installation ampache_ynh_install () { ORIPATH=$(pwd) @@ -44,19 +31,15 @@ ampache_ynh_install () { cd $ORIPATH } -# Reload Nginx and regenerate SSOwat conf +# Regenerate SSOwat conf ampache_ynh_reloadservices () { - systemctl reload nginx ynh_app_setting_set $app skipped_uris "/" yunohost app ssowatconf } # Pre config ampache ampache_ynh_doconfig () { - echo "127.0.0.1 $domain #yunoampache" | tee -a /etc/hosts sleep 1 - curl -kL -X POST http://$domain${path%/}/update.php?action=update > /dev/null 2>&1 + ynh_local_curl /update.php?action=update sleep 5 - sed '/yunoampache/d' /etc/hosts > /tmp/hosts.tmp - cp /tmp/hosts.tmp /etc/hosts ; ynh_secure_remove /tmp/hosts.tmp } diff --git a/scripts/backup b/scripts/backup index cba12a8..45acfa8 100644 --- a/scripts/backup +++ b/scripts/backup @@ -20,7 +20,7 @@ ynh_abort_if_errors app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get "$app" domain) -path=$(ynh_app_setting_get "$app" path) +path_url=$(ynh_app_setting_get "$app" path) admin=$(ynh_app_setting_get "$app" admin) final_path=/var/www/$app diff --git a/scripts/install b/scripts/install index 65c5f63..abaae6d 100644 --- a/scripts/install +++ b/scripts/install @@ -9,7 +9,7 @@ set -eu # Retrieve arguments app=$YNH_APP_INSTANCE_NAME domain=$YNH_APP_ARG_DOMAIN -path=$YNH_APP_ARG_PATH +path_url=$YNH_APP_ARG_PATH admin_ampache=$YNH_APP_ARG_ADMIN #================================================= @@ -31,9 +31,9 @@ ynh_abort_if_errors #================================================= # Check domain/path availability -path=$(ynh_normalize_url_path $path) -ynh_webpath_available $domain $path -ynh_webpath_register $app $domain $path +path_url=$(ynh_normalize_url_path $path_url) +ynh_webpath_available $domain $path_url +ynh_webpath_register $app $domain $path_url #================================================= # STORE SETTINGS FROM MANIFEST @@ -76,15 +76,14 @@ ynh_replace_string "RANDOMKEYTOCHANGE" "$random_key" $final_path/config/ampache. # NGINX CONFIGURATION #================================================= -# Modify Nginx configuration file and copy it to Nginx conf directory -ampache_ynh_preparenginx +ynh_add_nginx_config #================================================= # INSTALL DEPENDENCIES #================================================= # Install dependency -ynh_install_dependencies libav-tools +ynh_install_app_dependencies libav-tools #================================================= # SPECIFIC SETUP @@ -94,10 +93,10 @@ ynh_install_dependencies libav-tools ampache_ynh_install #================================================= -# RELOAD NGINX +# RELOAD SSOWAT #================================================= -# Reload Nginx and regenerate SSOwat conf +# Regenerate SSOwat conf ampache_ynh_reloadservices #================================================= diff --git a/scripts/remove b/scripts/remove index 7d30d29..fecd4f6 100644 --- a/scripts/remove +++ b/scripts/remove @@ -35,18 +35,11 @@ ynh_secure_remove $final_path # REMOVE NGINX CONFIGURATION #================================================= -# Remove Nginx configuration and reload Nginx conf -ynh_secure_remove /etc/nginx/conf.d/$domain.d/$app.conf +ynh_remove_nginx_config #================================================= # REMOVE DEPENDENCIES #================================================= -# Remove dependency -ynh_remove_dependencies libav-tools - -#================================================= -# RELOAD NGINX -#================================================= - -systemctl reload nginx +# Remove dependencies +ynh_remove_app_dependencies diff --git a/scripts/restore b/scripts/restore index ebf42f2..898357a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -25,7 +25,7 @@ ynh_abort_if_errors app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get "$app" domain) -path=$(ynh_app_setting_get "$app" path) +path_url=$(ynh_app_setting_get "$app" path) admin=$(ynh_app_setting_get "$app" admin) final_path=/var/www/$app @@ -42,14 +42,14 @@ test ! -d $final_path \ # CHECK THE PATH #================================================= -path=$(ynh_normalize_url_path $path) +path_url=$(ynh_normalize_url_path $path_url) #================================================= # REINSTALL DEPENDENCIES #================================================= # Install dependency -ynh_install_dependencies libav-tools +ynh_install_app_dependencies libav-tools #================================================= # RESTORE THE APP MAIN DIR @@ -62,6 +62,7 @@ ynh_restore_file "$final_path" #================================================= ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" +systemctl reload nginx #================================================= # RESTORE THE MYSQL DATABASE @@ -71,8 +72,3 @@ db_pwd=$(ynh_app_setting_get $app mysqlpwd) ynh_mysql_setup_db $app $app $db_pwd ynh_mysql_connect_as $app $db_pwd $app < ./db.sql -#================================================= -# RELOAD NGINX -#================================================= - -systemctl reload nginx diff --git a/scripts/upgrade b/scripts/upgrade index 96e8788..549b666 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,7 +22,7 @@ ynh_abort_if_errors # Retrieve arguments app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) -path=$(ynh_app_setting_get $app path) +path_url=$(ynh_app_setting_get $app path) db_pwd=$(ynh_app_setting_get $app mysqlpwd) admin_ampache=$(ynh_app_setting_get $app admin) @@ -30,7 +30,7 @@ admin_ampache=$(ynh_app_setting_get $app admin) # CHECK THE PATH #================================================= -path=$(ynh_normalize_url_path $path) +path_url=$(ynh_normalize_url_path $path_url) #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -47,14 +47,14 @@ ampache_ynh_prepareconfig #================================================= # Modify Nginx configuration file and copy it to Nginx conf directory -ampache_ynh_preparenginx +ynh_add_nginx_config #================================================= # INSTALL DEPENDENCIES #================================================= # Install dependency -ynh_install_dependencies libav-tools +ynh_install_app_dependencies libav-tools #================================================= # SPECIFIC SETUP @@ -64,10 +64,10 @@ ynh_install_dependencies libav-tools ampache_ynh_install #================================================= -# RELOAD NGINX +# RELOAD SSOWAT #================================================= -# Reload Nginx and regenerate SSOwat conf +# Regenerate SSOwat conf ampache_ynh_reloadservices #================================================= diff --git a/scripts/upstream_version b/scripts/upstream_version deleted file mode 100644 index 269aa9c..0000000 --- a/scripts/upstream_version +++ /dev/null @@ -1 +0,0 @@ -3.8.3