Skip to content

Commit

Permalink
v2
Browse files Browse the repository at this point in the history
  • Loading branch information
ericgaspar committed Jun 11, 2023
1 parent 671b7d2 commit 498836d
Show file tree
Hide file tree
Showing 10 changed files with 239 additions and 180 deletions.
7 changes: 0 additions & 7 deletions conf/app.src

This file was deleted.

2 changes: 1 addition & 1 deletion conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
location __PATH__/ {

# Path to source
alias __FINALPATH__/public/;
alias __INSTALL_DIR__/public/;

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;
Expand Down
64 changes: 64 additions & 0 deletions manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
packaging_format = 2

id = "ampache"
name = "Ampache"
description.en = "Web based audio/video streaming application"
description.fr = "Application de streaming audio et vidéo"

version = "5.6.0~ynh1"

maintainers = []

[upstream]
license = "AGPL-3.0"
website = "http://ampache.org"
demo = "https://ampache.org/demo.html"
admindoc = "https://github.com/ampache/ampache/wiki"
code = "https://github.com/ampache/ampache"
cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number)
fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin.

[integration]
yunohost = ">= 11.0.9"
architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"]
multi_instance = true
ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials.
sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal.
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]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "domain"

[install.path]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "path"
default = "/ampache"

[install.init_main_permission]
type = "group"
default = "visitors"

[install.admin]
# this is a generic question - ask strings are automatically handled by Yunohost's core
type = "user"

[resources]
[resources.sources.main]
url = "https://github.com/ampache/ampache/releases/download/5.6.0/ampache-5.6.0_all_php8.0.zip"
sha256 = "f200067b5b7c753ed9660991d484a2e20b87afb0dffb16d5c3a54bb6a23cb963"
in_subdir = false


[resources.system_user]

[resources.install_dir]

[resources.permissions]
main.url = "/"

[resources.database]
type = "mysql"
6 changes: 3 additions & 3 deletions scripts/_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
# COMMON VARIABLES
#=================================================

YNH_PHP_VERSION=8.0
#REMOVEME? YNH_PHP_VERSION=8.0

# Composer version
YNH_COMPOSER_VERSION="2.3.5"

php_dependencies="php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-simplexml php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-intl"
#REMOVEME? php_dependencies="php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-simplexml php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-intl"

# dependencies used by the app (must be on a single line)
pkg_dependencies="libav-tools|ffmpeg $php_dependencies"
#REMOVEME? pkg_dependencies="libav-tools|ffmpeg $php_dependencies"

#=================================================
# PERSONAL HELPERS
Expand Down
18 changes: 9 additions & 9 deletions scripts/backup
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================

ynh_clean_setup () {
#REMOVEME? ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors

#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
#REMOVEME? ynh_print_info --message="Loading installation settings..."

app=$YNH_APP_INSTANCE_NAME
#REMOVEME? 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)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)

#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
Expand All @@ -41,7 +41,7 @@ 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 NGINX CONFIGURATION
Expand Down
74 changes: 38 additions & 36 deletions scripts/change_url
Original file line number Diff line number Diff line change
Expand Up @@ -13,53 +13,53 @@ source /usr/share/yunohost/helpers
# RETRIEVE ARGUMENTS
#=================================================

old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN
#REMOVEME? old_path=$YNH_APP_OLD_PATH

new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH
#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN
#REMOVEME? new_path=$YNH_APP_NEW_PATH

app=$YNH_APP_INSTANCE_NAME
#REMOVEME? app=$YNH_APP_INSTANCE_NAME

#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
#REMOVEME? ynh_script_progression --message="Loading installation settings..."

# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#REMOVEME? # Needed for helper "ynh_add_nginx_config"
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)

#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1

# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
#REMOVEME? ynh_backup_before_upgrade
#REMOVEME? 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"
#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"

# Restore it if the upgrade fails
ynh_restore_upgradebackup
#REMOVEME? ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors

#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================

change_domain=0
if [ "$old_domain" != "$new_domain" ]
#REMOVEME? change_domain=0
#REMOVEME? if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
#REMOVEME? change_domain=1
fi

change_path=0
if [ "$old_path" != "$new_path" ]
#REMOVEME? change_path=0
#REMOVEME? if [ "$old_path" != "$new_path" ]
then
change_path=1
#REMOVEME? change_path=1
fi

#=================================================
Expand All @@ -69,28 +69,30 @@ fi
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2

nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
ynh_change_url_nginx_config

# Change the path in the nginx config file
#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf

#REMOVEME? # 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
#REMOVEME? # Make a backup of the original nginx config file if modified
#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
#REMOVEME? # Set global variables for nginx helper
#REMOVEME? domain="$old_domain"
#REMOVEME? path="$new_path"
#REMOVEME? # Create a dedicated nginx config
#REMOVEME? ynh_add_nginx_config
fi

# Change the domain for nginx
#REMOVEME? # 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
#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path"
#REMOVEME? 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"
#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi

#=================================================
Expand All @@ -100,7 +102,7 @@ fi
#=================================================
ynh_script_progression --message="Updating Ampache configuration..."

conf_file="$final_path/config/ampache.cfg.php"
conf_file="$install_dir/config/ampache.cfg.php"

ynh_replace_string --match_string="\(web_path.*=.*\)\"$old_path\"" --replace_string="\1\"$new_path\"" --target_file="$conf_file"
ynh_replace_string --match_string="\(http_host.*=.*\)\"$old_domain\"" --replace_string="\1\"$new_domain\"" --target_file="$conf_file"
Expand All @@ -110,9 +112,9 @@ ynh_replace_string --match_string="\(http_host.*=.*\)\"$old_domain\"" --replace_
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."

ynh_systemd_action --service_name=nginx --action=reload
#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload

#=================================================
# END OF SCRIPT
Expand Down
Loading

0 comments on commit 498836d

Please sign in to comment.