1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/agendav_ynh.git synced 2024-09-03 20:36:12 +02:00

Add ynh_add_config

This commit is contained in:
ericgaspar 2021-03-17 21:50:32 +01:00
parent db9af56fc9
commit b0220105e2
No known key found for this signature in database
GPG key ID: 574F281483054D44
5 changed files with 50 additions and 60 deletions

View file

@ -20,9 +20,9 @@ $app['proxies'] = [];
// Database settings // Database settings
$app['db.options'] = [ $app['db.options'] = [
'dbname' => '__DBNAME__', 'dbname' => '__DB_NAME__',
'user' => '__DBUSER__', 'user' => '__DB_USER__',
'password' => '__DBPASS__', 'password' => '__DBPWD__',
'host' => 'localhost', 'host' => 'localhost',
'driver' => 'pdo_mysql' 'driver' => 'pdo_mysql'
]; ];
@ -34,7 +34,7 @@ $app['csrf.secret'] = '__ENCRYPTKEY__';
$app['log.path'] = '__LOGDIR__/'; $app['log.path'] = '__LOGDIR__/';
// Base URL // Base URL
$app['caldav.baseurl'] = '__CALDAV_BASEURL__'; $app['caldav.baseurl'] = '__CALDAV_BASE_URL__';
// Authentication method required by CalDAV server (basic or digest) // Authentication method required by CalDAV server (basic or digest)
$app['caldav.authmethod'] = 'basic'; $app['caldav.authmethod'] = 'basic';

View file

@ -15,11 +15,11 @@
}, },
"multi_instance": false, "multi_instance": false,
"requirements": { "requirements": {
"yunohost": ">= 3.8.1" "yunohost": ">= 4.1.7"
}, },
"services": [ "services": [
"nginx", "nginx",
"php7.0-fpm", "php7.3-fpm",
"mysql" "mysql"
], ],
"arguments": { "arguments": {
@ -27,19 +27,11 @@
{ {
"name": "domain", "name": "domain",
"type": "domain", "type": "domain",
"ask": {
"en": "Choose a domain for AgenDAV",
"fr": "Choisissez un domaine pour AgenDAV"
},
"example": "domain.org" "example": "domain.org"
}, },
{ {
"name": "path", "name": "path",
"type": "path", "type": "path",
"ask": {
"en": "Choose a path for AgenDAV",
"fr": "Choisissez un chemin pour AgenDAV"
},
"example": "/agendav", "example": "/agendav",
"default": "/agendav" "default": "/agendav"
}, },

View file

@ -11,14 +11,6 @@
- [ ] Upgrade from last version tested. - [ ] Upgrade from last version tested.
- [ ] Can be reviewed and tested. - [ ] Can be reviewed and tested.
## Validation ## Package_check results
--- ---
*Minor decision* * An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"*
- **Upgrade previous version** :
- [ ] **Code review** :
- [ ] **Approval (LGTM)** :
- [ ] **Approval (LGTM)** :
- **CI succeeded** :
[![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/agendav_ynh%20PR-NUM-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/agendav_ynh%20PR-NUM-/)
*Please replace '-NUM-' in this link by the PR number.*
When the PR is marked as ready to merge, you have to wait for 3 days before really merging it.

View file

@ -116,7 +116,6 @@ ynh_script_progression --message="Configuring AgenDAV..." --weight=2
# Generate random encryption key # Generate random encryption key
encryptkey=$(ynh_string_random --length=24) encryptkey=$(ynh_string_random --length=24)
ynh_app_setting_set --app=$app --key=encryptkey --value="$encryptkey" ynh_app_setting_set --app=$app --key=encryptkey --value="$encryptkey"
# Copy and set AgenDAV configuration # Copy and set AgenDAV configuration
@ -126,26 +125,30 @@ caldav_domain=$(ynh_app_setting_get --app=$caldav_app --key=domain)
caldav_path=$(ynh_app_setting_get --app=$caldav_app --key=path) caldav_path=$(ynh_app_setting_get --app=$caldav_app --key=path)
caldav_url="https://${caldav_domain}${caldav_path%/}" caldav_url="https://${caldav_domain}${caldav_path%/}"
caldav_base_url="${caldav_url}${caldav_baseurl}"
conf_path="${final_path}/web/config/settings.php" conf_path="${final_path}/web/config/settings.php"
cp ../conf/settings.php "$conf_path" # cp ../conf/settings.php "$conf_path"
logdir=/var/log/$app logdir=/var/log/$app
ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_name" --target_file="$conf_path" # ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$conf_path"
ynh_replace_string --match_string="__DBPASS__" --replace_string="$db_pwd" --target_file="$conf_path" # ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$conf_path"
ynh_replace_string --match_string="__DBNAME__" --replace_string="$db_name" --target_file="$conf_path" # ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$conf_path"
ynh_replace_string --match_string="__ENCRYPTKEY__" --replace_string="$encryptkey" --target_file="$conf_path" # ynh_replace_string --match_string="__ENCRYPTKEY__" --replace_string="$encryptkey" --target_file="$conf_path"
ynh_replace_string --match_string="__LOGDIR__" --replace_string="$logdir" --target_file="$conf_path" # ynh_replace_string --match_string="__LOGDIR__" --replace_string="$logdir" --target_file="$conf_path"
ynh_replace_string --match_string="__TIMEZONE__" --replace_string="$timezone" --target_file="$conf_path" # ynh_replace_string --match_string="__TIMEZONE__" --replace_string="$timezone" --target_file="$conf_path"
ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$conf_path" # ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$conf_path"
ynh_replace_string --match_string="__CALDAV_BASEURL__" --replace_string="${caldav_url}${caldav_baseurl}" --target_file="$conf_path" # ynh_replace_string --match_string="__CALDAV_BASE_URL__" --replace_string="${caldav_url}${caldav_baseurl}" --target_file="$conf_path"
ynh_replace_string --match_string="__CALDAV_DOMAIN__" --replace_string="$caldav_domain" --target_file="$conf_path" # ynh_replace_string --match_string="__CALDAV_DOMAIN__" --replace_string="$caldav_domain" --target_file="$conf_path"
ynh_add_config --template="../conf/settings.php" --destination="$conf_path"
#================================================= #=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE # STORE THE CHECKSUM OF THE CONFIG FILE
#================================================= #=================================================
ynh_store_file_checksum --file="$conf_path" # ynh_store_file_checksum --file="$conf_path"
#================================================= #=================================================
# RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION) # RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION)

View file

@ -21,6 +21,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
language=$(ynh_app_setting_get --app=$app --key=language) language=$(ynh_app_setting_get --app=$app --key=language)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
@ -34,15 +35,6 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." ynh_script_progression --message="Ensuring downward compatibility..."
# 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 db_name doesn't exist, create it
if [ -z "$db_name" ]; then if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid --db_name=$app) db_name=$(ynh_sanitize_dbid --db_name=$app)
@ -55,6 +47,13 @@ if [ -z "$final_path" ]; then
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#================================================= #=================================================
# GET THE CALDAV APP # GET THE CALDAV APP
#================================================= #=================================================
@ -147,30 +146,34 @@ caldav_domain=$(ynh_app_setting_get --app=$caldav_app --key=domain)
caldav_path=$(ynh_app_setting_get --app=$caldav_app --key=path) caldav_path=$(ynh_app_setting_get --app=$caldav_app --key=path)
caldav_url="https://${caldav_domain}${caldav_path%/}" caldav_url="https://${caldav_domain}${caldav_path%/}"
caldav_base_url="${caldav_url}${caldav_baseurl}"
conf_path="${final_path}/web/config/settings.php" conf_path="${final_path}/web/config/settings.php"
ynh_backup_if_checksum_is_different --file="$conf_path"
cp ../conf/settings.php "$conf_path"
logdir=/var/log/$app logdir=/var/log/$app
ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_name" --target_file="$conf_path" # ynh_backup_if_checksum_is_different --file="$conf_path"
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_replace_string --match_string="__DBPASS__" --replace_string="$db_pwd" --target_file="$conf_path" # cp ../conf/settings.php "$conf_path"
ynh_replace_string --match_string="__DBNAME__" --replace_string="$db_name" --target_file="$conf_path"
ynh_replace_string --match_string="__ENCRYPTKEY__" --replace_string="$encryptkey" --target_file="$conf_path" # ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$conf_path"
ynh_replace_string --match_string="__LOGDIR__" --replace_string="$logdir" --target_file="$conf_path" # ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$conf_path"
ynh_replace_string --match_string="__TIMEZONE__" --replace_string="$timezone" --target_file="$conf_path" # ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$conf_path"
ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$conf_path" # ynh_replace_string --match_string="__ENCRYPTKEY__" --replace_string="$encryptkey" --target_file="$conf_path"
ynh_replace_string --match_string="__CALDAV_BASEURL__" --replace_string="${caldav_url}${caldav_baseurl}" --target_file="$conf_path" # ynh_replace_string --match_string="__LOGDIR__" --replace_string="$logdir" --target_file="$conf_path"
ynh_replace_string --match_string="__CALDAV_DOMAIN__" --replace_string="$caldav_domain" --target_file="$conf_path" # ynh_replace_string --match_string="__TIMEZONE__" --replace_string="$timezone" --target_file="$conf_path"
# ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$conf_path"
# ynh_replace_string --match_string="__CALDAV_BASE_URL__" --replace_string="${caldav_url}${caldav_baseurl}" --target_file="$conf_path"
# ynh_replace_string --match_string="__CALDAV_DOMAIN__" --replace_string="$caldav_domain" --target_file="$conf_path"
ynh_add_config --template="../conf/settings.php" --destination="$conf_path"
#================================================= #=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE # STORE THE CHECKSUM OF THE CONFIG FILE
#================================================= #=================================================
ynh_store_file_checksum --file="$conf_path" # ynh_store_file_checksum --file="$conf_path"
#================================================= #=================================================
# RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION) # RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION)