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

Fiw linter warnings

This commit is contained in:
ericgaspar 2021-03-17 22:32:03 +01:00
parent d06406d500
commit d3f1f8a717
No known key found for this signature in database
GPG key ID: 574F281483054D44
6 changed files with 42 additions and 55 deletions

View file

@ -25,7 +25,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to
## Documentation
* Official documentation: https://github.com/ampache/ampache/wiki
* YunoHost documentation: https://yunohost.org/#/app_ampache
* YunoHost documentation: https://yunohost.org/en/app_ampache
## YunoHost specific features

View file

@ -23,7 +23,7 @@ config_version = 40
; If not set, retrieved automatically from client request.
; This setting is required for WebSocket server
; DEFAULT: ""
http_host = "__DOMAINTOCHANGE__"
http_host = "__DOMAIN__"
; The public http port of your server.
; If not set, retrieved automatically from client request.
@ -37,7 +37,7 @@ http_host = "__DOMAINTOCHANGE__"
; if it is located at http://localhost/music you need to
; set web_path to /music
; DEFAULT: ""
web_path = "__PATHTOCHANGE__"
web_path = "__PATH__"
; The local http url of your server.
; This is used to access the server from within the
@ -66,17 +66,17 @@ database_hostname = localhost
; Name of your ampache database
; DEFAULT: ampache
database_name = "__DBNAME__"
database_name = "__DB_NAME__"
; Username for your ampache database
; DEFAULT: ""
database_username = "__DBUSER__"
database_username = "__DB_USER__"
; Password for your ampache database, this can not be blank
; this is a 'forced' security precaution, the default value
; will not work (except if using socket authentication)
; DEFAULT: ""
database_password = "__DBPWD__"
database_password = "__DB_PWD__"
;#########################################################
@ -85,7 +85,7 @@ database_password = "__DBPWD__"
; Cryptographic secret
; This MUST BE changed with your own secret key. Ampache-specific, just pick any random string you want.
secret_key = "__RANDOMKEYTOCHANGE__"
secret_key = "__SECRET_KEY__"
; Length that a session will last expressed in seconds. Default is
; one hour.

View file

@ -14,7 +14,7 @@
"email": "aymhce@gmail.com"
},
"requirements": {
"yunohost": ">= 4.0.0"
"yunohost": ">= 4.1.7"
},
"multi_instance": true,
"services" : [
@ -27,38 +27,22 @@
{
"name": "domain",
"type": "domain",
"ask": {
"en": "Choose a domain name for Ampache",
"fr": "Choisissez un nom de domaine pour Ampache"
},
"example": "domain.org"
},
{
"name": "path",
"type": "path",
"ask": {
"en": "Choose a path for Ampache",
"fr": "Choisissez un chemin pour Ampache"
},
"example": "/ampache",
"default": "/ampache"
},
{
"name": "admin",
"type": "user",
"ask": {
"en": "Choose the Ampache administrator (must be an existing YunoHost user)",
"fr": "Administrateur du serveur Ampache (doit être un utilisateur YunoHost existant)"
},
"example": "homer"
},
{
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public application?",
"fr": "Est-ce une application publique ?"
},
"default": true
}
]

View file

@ -29,6 +29,23 @@ 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)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
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 () {
# 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"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================

View file

@ -46,7 +46,6 @@ ynh_script_progression --message="Storing installation settings..." --weight=2
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin_ampache
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
#=================================================
# STANDARD MODIFICATIONS
@ -110,11 +109,11 @@ ynh_script_progression --message="Preconfiguring Ampache..." --weight=2
conf_file="$final_path/config/ampache.cfg.php"
cp ../conf/ampache.cfg.php "$conf_file"
ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_user" --target_file="$conf_file"
ynh_replace_string --match_string="__DBPWD__" --replace_string="$db_pwd" --target_file="$conf_file"
ynh_replace_string --match_string="__DBNAME__" --replace_string="$db_name" --target_file="$conf_file"
ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$conf_file"
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$conf_file"
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$conf_file"
ynh_replace_string --match_string="__PATHTOCHANGE__" --replace_string="$path_url" --target_file="$conf_file"
ynh_replace_string --match_string="__DOMAINTOCHANGE__" --replace_string="$domain" --target_file="$conf_file"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$conf_file"
secret_key=$(ynh_string_random --length=24)
ynh_replace_string --match_string="__RANDOMKEYTOCHANGE__" --replace_string="$secret_key" --target_file="$conf_file"
ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key

View file

@ -23,6 +23,7 @@ is_public=$(ynh_app_setting_get --app=$app --key=is_public)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
secret_key=$(ynh_app_setting_get --app=$app --key=secret_key)
#=================================================
@ -37,21 +38,6 @@ upgrade_type=$(ynh_check_app_version_changed)
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# If is_public doesn't exist, create it
if [ -z $is_public ]; then
is_public=1
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
fi
# Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=1
is_public=1
elif [ "$is_public" = "No" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=0
is_public=0
fi
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid --db_name=$app)
@ -145,19 +131,20 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading Ampache configuration..."
conf_file="$final_path/config/ampache.cfg.php"
ynh_backup_if_checksum_is_different --file="$conf_file"
# conf_file="$final_path/config/ampache.cfg.php"
# ynh_backup_if_checksum_is_different --file="$conf_file"
ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_user" --target_file="$conf_file"
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_replace_string --match_string="__DBPWD__" --replace_string="$db_pwd" --target_file="$conf_file"
ynh_replace_string --match_string="__DBNAME__" --replace_string="$db_name" --target_file="$conf_file"
ynh_replace_string --match_string="__PATHTOCHANGE__" --replace_string="$path_url" --target_file="$conf_file"
ynh_replace_string --match_string="__DOMAINTOCHANGE__" --replace_string="$domain" --target_file="$conf_file"
ynh_replace_string --match_string="__RANDOMKEYTOCHANGE__" --replace_string="$secret_key" --target_file="$conf_file"
# ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$conf_file"
# ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$conf_file"
# ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$conf_file"
# ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$conf_file"
# ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$conf_file"
# ynh_replace_string --match_string="__SECRET_KEY__" --replace_string="$secret_key" --target_file="$conf_file"
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$conf_file"
# # Calculate and store the config file checksum into the app settings
# ynh_store_file_checksum --file="$conf_file"
ynh_add_config --template="../conf/ampache.cfg.php" --destination="$final_path/config/ampache.cfg.php"
#=================================================
# UPDATE AMPACHE WITH COMPOSER