1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/agendav_ynh.git synced 2024-09-03 20:36:12 +02:00
This commit is contained in:
ericgaspar 2021-06-04 16:38:44 +02:00
parent 2f73fbad89
commit 1214e1930a
No known key found for this signature in database
GPG key ID: 574F281483054D44
3 changed files with 22 additions and 78 deletions

View file

@ -1,8 +1,8 @@
;; Test complet ;; Test complet
auto_remove=1 auto_remove=1
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld"
path="/path" (PATH) path="/path"
language="en" language="en"
; pre-install ; pre-install
sudo yunohost tools update --apps sudo yunohost tools update --apps

View file

@ -74,6 +74,14 @@ db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=2
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
@ -91,14 +99,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=3
# Copy and set NGINX configuration # Copy and set NGINX configuration
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=2
# Create a system user
ynh_system_user_create --username=$app
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================ #================================================
@ -121,27 +121,14 @@ ynh_app_setting_set --app=$app --key=encryptkey --value="$encryptkey"
# Copy and set AgenDAV configuration # Copy and set AgenDAV configuration
timezone=$(cat /etc/timezone) timezone=$(cat /etc/timezone)
caldav_domain=$(ynh_app_setting_get --app=$caldav_app --key=domain) 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}" 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"
logdir=/var/log/$app logdir=/var/log/$app
ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$conf_path" ynh_add_config --template="../conf/settings.php" --destination="$conf_path"
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --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="__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="__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"
#================================================= #=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE # STORE THE CHECKSUM OF THE CONFIG FILE

View file

@ -91,6 +91,14 @@ ynh_clean_setup () {
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=2
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#================================================= #=================================================
@ -99,10 +107,10 @@ ynh_abort_if_errors
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Upgrading source files..."0 ynh_script_progression --message="Upgrading source files..." --weight=2
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path" --keep="${final_path}/web/config/settings.php"
fi fi
#================================================= #=================================================
@ -113,65 +121,14 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
# Copy and set NGINX configuration # Copy and set NGINX configuration
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..." ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2
# Create a dedicated PHP-FPM config # Create a dedicated PHP-FPM config
ynh_add_fpm_config --package="$extra_php_dependencies" ynh_add_fpm_config --package="$extra_php_dependencies"
#=================================================
# SPECIFIC SETUP
#=================================================
# CREATE SETTINGS.PHP
#=================================================
ynh_script_progression --message="Upgrading AgenDAV configuration..." --weight=2
# Generate random encryption key
encryptkey=$(ynh_app_setting_get --app=$app --key=encryptkey)
# Copy and set AgenDAV configuration
timezone=$(cat /etc/timezone)
caldav_domain=$(ynh_app_setting_get --app=$caldav_app --key=domain)
caldav_path=$(ynh_app_setting_get --app=$caldav_app --key=path)
caldav_url="https://${caldav_domain}${caldav_path%/}"
caldav_base_url="${caldav_url}${caldav_baseurl}"
conf_path="${final_path}/web/config/settings.php"
logdir=/var/log/$app
ynh_backup_if_checksum_is_different --file="$conf_path"
cp ../conf/settings.php "$conf_path"
ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$conf_path"
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --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="__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="__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"
#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
#=================================================
# ynh_store_file_checksum --file="$conf_path"
#================================================= #=================================================
# RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION) # RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION)
#================================================= #=================================================