1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ampache_ynh.git synced 2024-09-03 18:15:55 +02:00

add ynh_*_nginx_config, ynh_local_curl, ynh_setup_source #21

This commit is contained in:
aymhce 2017-10-04 01:43:17 +02:00
parent 291b88961b
commit 0b3f9e2611
10 changed files with 42 additions and 68 deletions

3
conf/app.src Normal file
View file

@ -0,0 +1,3 @@
SOURCE_URL=https://github.com/ampache/ampache/archive/3.8.3.zip
SOURCE_SUM=1bfd98defb5e4451443b899504a59ceb97e12dd2c36804318e6bfdda7a76d60d
SOURCE_FORMAT=zip

View file

@ -1,6 +1,6 @@
location PATHTOCHANGE { location __PATH__ {
alias ALIASTOCHANGE; alias __FINALPATH__/;
if ($scheme = http) { if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent; rewrite ^ https://$server_name$request_uri? permanent;
@ -8,13 +8,13 @@ location PATHTOCHANGE {
#enable subsonic api #enable subsonic api
if ( !-d $request_filename ) { if ( !-d $request_filename ) {
rewrite ^PATH2TOCHANGE/rest/(.*)\.view$ PATH2TOCHANGE/rest/index.php?action=$1 last; rewrite ^__PATH__rest/(.*)\.view$ __PATH__rest/index.php?action=$1 last;
rewrite ^PATH2TOCHANGE/rest/fake/(.+)$ PATH2TOCHANGE/play/$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 ^__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 ^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 ^__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 ^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])/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; index index.php;
try_files $uri $uri/ index.php; try_files $uri $uri/ index.php;
@ -28,20 +28,20 @@ location PATHTOCHANGE {
fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_param SCRIPT_FILENAME $request_filename;
} }
location ^~ PATH2TOCHANGE/bin/ { location ^~ __PATH__bin/ {
deny all; deny all;
return 403; return 403;
} }
location ^~ PATH2TOCHANGE/config/ { location ^~ __PATH__config/ {
deny all; deny all;
return 403; 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 ^__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 ^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]+)/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 { limit_except GET POST {
deny all; deny all;
} }

View file

@ -5,6 +5,7 @@
"en": "A web based audio/video streaming application", "en": "A web based audio/video streaming application",
"fr": "Une application de streaming audio et vidéo" "fr": "Une application de streaming audio et vidéo"
}, },
"version": "1.0",
"url": "http://ampache.org", "url": "http://ampache.org",
"packaging_format": 1, "packaging_format": 1,
"license": "free", "license": "free",

View file

@ -2,14 +2,10 @@
# Copy files to the right place # Copy files to the right place
ampache_ynh_getsources () { ampache_ynh_getsources () {
version=$(cat upstream_version)
final_path=/var/www/$app final_path=/var/www/$app
mkdir -p $final_path/log mkdir -p $final_path/log
wget -O ../ampache.tar.gz https://github.com/ampache/ampache/archive/$version.tar.gz > /dev/null 2>&1 ynh_setup_source $final_path
tar xvzf ../ampache.tar.gz -C .. > /dev/null 2>&1
cp -ar ../ampache-$version/. $final_path
cp ../conf/ampache.cfg.php $final_path/config/ampache.cfg.php 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 "yunouser" "$app" $final_path/config/ampache.cfg.php
ynh_replace_string "yunopass" "$db_pwd" $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 "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 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 installation
ampache_ynh_install () { ampache_ynh_install () {
ORIPATH=$(pwd) ORIPATH=$(pwd)
@ -44,19 +31,15 @@ ampache_ynh_install () {
cd $ORIPATH cd $ORIPATH
} }
# Reload Nginx and regenerate SSOwat conf # Regenerate SSOwat conf
ampache_ynh_reloadservices () { ampache_ynh_reloadservices () {
systemctl reload nginx
ynh_app_setting_set $app skipped_uris "/" ynh_app_setting_set $app skipped_uris "/"
yunohost app ssowatconf yunohost app ssowatconf
} }
# Pre config ampache # Pre config ampache
ampache_ynh_doconfig () { ampache_ynh_doconfig () {
echo "127.0.0.1 $domain #yunoampache" | tee -a /etc/hosts
sleep 1 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 sleep 5
sed '/yunoampache/d' /etc/hosts > /tmp/hosts.tmp
cp /tmp/hosts.tmp /etc/hosts ; ynh_secure_remove /tmp/hosts.tmp
} }

View file

@ -20,7 +20,7 @@ ynh_abort_if_errors
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain) 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) admin=$(ynh_app_setting_get "$app" admin)
final_path=/var/www/$app final_path=/var/www/$app

View file

@ -9,7 +9,7 @@ set -eu
# Retrieve arguments # Retrieve arguments
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
admin_ampache=$YNH_APP_ARG_ADMIN admin_ampache=$YNH_APP_ARG_ADMIN
#================================================= #=================================================
@ -31,9 +31,9 @@ ynh_abort_if_errors
#================================================= #=================================================
# Check domain/path availability # Check domain/path availability
path=$(ynh_normalize_url_path $path) path_url=$(ynh_normalize_url_path $path_url)
ynh_webpath_available $domain $path ynh_webpath_available $domain $path_url
ynh_webpath_register $app $domain $path ynh_webpath_register $app $domain $path_url
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
@ -76,15 +76,14 @@ ynh_replace_string "RANDOMKEYTOCHANGE" "$random_key" $final_path/config/ampache.
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
# Modify Nginx configuration file and copy it to Nginx conf directory ynh_add_nginx_config
ampache_ynh_preparenginx
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
# Install dependency # Install dependency
ynh_install_dependencies libav-tools ynh_install_app_dependencies libav-tools
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
@ -94,10 +93,10 @@ ynh_install_dependencies libav-tools
ampache_ynh_install ampache_ynh_install
#================================================= #=================================================
# RELOAD NGINX # RELOAD SSOWAT
#================================================= #=================================================
# Reload Nginx and regenerate SSOwat conf # Regenerate SSOwat conf
ampache_ynh_reloadservices ampache_ynh_reloadservices
#================================================= #=================================================

View file

@ -35,18 +35,11 @@ ynh_secure_remove $final_path
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
# Remove Nginx configuration and reload Nginx conf ynh_remove_nginx_config
ynh_secure_remove /etc/nginx/conf.d/$domain.d/$app.conf
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
# Remove dependency # Remove dependencies
ynh_remove_dependencies libav-tools ynh_remove_app_dependencies
#=================================================
# RELOAD NGINX
#=================================================
systemctl reload nginx

View file

@ -25,7 +25,7 @@ ynh_abort_if_errors
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain) 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) admin=$(ynh_app_setting_get "$app" admin)
final_path=/var/www/$app final_path=/var/www/$app
@ -42,14 +42,14 @@ test ! -d $final_path \
# CHECK THE PATH # CHECK THE PATH
#================================================= #=================================================
path=$(ynh_normalize_url_path $path) path_url=$(ynh_normalize_url_path $path_url)
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
# Install dependency # Install dependency
ynh_install_dependencies libav-tools ynh_install_app_dependencies libav-tools
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # 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" ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
systemctl reload nginx
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # 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_setup_db $app $app $db_pwd
ynh_mysql_connect_as $app $db_pwd $app < ./db.sql ynh_mysql_connect_as $app $db_pwd $app < ./db.sql
#=================================================
# RELOAD NGINX
#=================================================
systemctl reload nginx

View file

@ -22,7 +22,7 @@ ynh_abort_if_errors
# Retrieve arguments # Retrieve arguments
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) 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) db_pwd=$(ynh_app_setting_get $app mysqlpwd)
admin_ampache=$(ynh_app_setting_get $app admin) admin_ampache=$(ynh_app_setting_get $app admin)
@ -30,7 +30,7 @@ admin_ampache=$(ynh_app_setting_get $app admin)
# CHECK THE PATH # CHECK THE PATH
#================================================= #=================================================
path=$(ynh_normalize_url_path $path) path_url=$(ynh_normalize_url_path $path_url)
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -47,14 +47,14 @@ ampache_ynh_prepareconfig
#================================================= #=================================================
# Modify Nginx configuration file and copy it to Nginx conf directory # Modify Nginx configuration file and copy it to Nginx conf directory
ampache_ynh_preparenginx ynh_add_nginx_config
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
# Install dependency # Install dependency
ynh_install_dependencies libav-tools ynh_install_app_dependencies libav-tools
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
@ -64,10 +64,10 @@ ynh_install_dependencies libav-tools
ampache_ynh_install ampache_ynh_install
#================================================= #=================================================
# RELOAD NGINX # RELOAD SSOWAT
#================================================= #=================================================
# Reload Nginx and regenerate SSOwat conf # Regenerate SSOwat conf
ampache_ynh_reloadservices ampache_ynh_reloadservices
#================================================= #=================================================

View file

@ -1 +0,0 @@
3.8.3