mirror of
https://github.com/YunoHost-Apps/dolibarr_ynh.git
synced 2024-09-03 18:35:53 +02:00
Continue manifestv2
This commit is contained in:
parent
c4ed8e467e
commit
bd56d78737
8 changed files with 100 additions and 438 deletions
|
@ -1,21 +1,23 @@
|
|||
#!/bin/bash
|
||||
app="$(basename $0 | cut -d- -f 2-)" # Extract the app name from the script name, which is supposed to be something like "50-app_id"
|
||||
src_path=$(yunohost app setting $app final_path)
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Extract the app name from the script name, which is supposed to be something like "50-app_id"
|
||||
app="$(basename "$0" | cut -d- -f 2-)"
|
||||
|
||||
src_path=$(yunohost app setting "$app" install_dir)
|
||||
# member=__MEMBER__
|
||||
|
||||
|
||||
# Sync users
|
||||
if sudo php "$src_path/scripts/user/sync_users_ldap2dolibarr.php" commitiferror --server=localhost -y; then
|
||||
echo ldap user update ok
|
||||
echo "LDAP user update succeeded"
|
||||
else
|
||||
echo ldap user update ended with error
|
||||
echo "LDAP user update ended with error"
|
||||
fi
|
||||
|
||||
|
||||
# If YNH users should also be members, sync members
|
||||
# if [ $member -eq 1 ];
|
||||
# then
|
||||
# if sudo php "$src_path/scripts/members/sync_members_ldap2dolibarr.php" commitiferror 1 --server=localhost -y; then
|
||||
# echo ldap member update ok
|
||||
# else
|
||||
# echo ldap member update ended with error
|
||||
# fi
|
||||
# if [ $member -eq 1 ]; then
|
||||
# if sudo php "$src_path/scripts/members/sync_members_ldap2dolibarr.php" commitiferror 1 --server=localhost -y; then
|
||||
# echo ldap member update ok
|
||||
# else
|
||||
# echo ldap member update ended with error
|
||||
# fi
|
||||
# fi
|
||||
|
|
|
@ -69,6 +69,7 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen
|
|||
"php8.1-soap",
|
||||
"php8.1-curl",
|
||||
"php8.1-intl",
|
||||
"php8.1-ldap",
|
||||
"php8.1-opcache",
|
||||
"php8.1-calendar",
|
||||
"php8.1-zip",
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -10,25 +8,6 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
#REMOVEME? ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#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
|
||||
#=================================================
|
||||
|
@ -41,23 +20,13 @@ ynh_print_info --message="Declaring files to be backed up..."
|
|||
ynh_backup --src_path="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
# BACKUP THE SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -9,61 +7,6 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN
|
||||
#REMOVEME? old_path=$YNH_APP_OLD_PATH
|
||||
|
||||
#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN
|
||||
#REMOVEME? new_path=$YNH_APP_NEW_PATH
|
||||
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
#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
|
||||
#=================================================
|
||||
#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
|
||||
#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.
|
||||
#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
|
||||
# restore it if the upgrade fails
|
||||
#REMOVEME? ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
#=================================================
|
||||
|
||||
#REMOVEME? change_domain=0
|
||||
#REMOVEME? if [ "$old_domain" != "$new_domain" ]
|
||||
then
|
||||
#REMOVEME? change_domain=1
|
||||
fi
|
||||
|
||||
#REMOVEME? change_path=0
|
||||
#REMOVEME? if [ "$old_path" != "$new_path" ]
|
||||
then
|
||||
#REMOVEME? change_path=1
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
|
@ -71,46 +14,13 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
|
|||
|
||||
ynh_change_url_nginx_config
|
||||
|
||||
#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
|
||||
#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
|
||||
|
||||
#REMOVEME? # Change the domain for nginx
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
# Delete file checksum for the old conf file location
|
||||
#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
|
||||
#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
# UPDATE conf file
|
||||
#=================================================
|
||||
|
||||
ynh_replace_string --match_string="$old_domain$old_path" --replace_string="$new_domain$new_path" --target_file="$install_dir/htdocs/conf/conf.php"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||
|
||||
#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||
ynh_replace_string --target_file="$install_dir/htdocs/conf/conf.php" \
|
||||
--match_string="$old_domain$old_path" \
|
||||
--replace_string="$new_domain$new_path"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
105
scripts/install
105
scripts/install
|
@ -28,8 +28,8 @@ ynh_script_progression --message="Setting up source files..." --weight=1
|
|||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --source_id="main" --dest_dir="$install_dir"
|
||||
|
||||
# Create necessary files
|
||||
touch $install_dir/htdocs/conf/conf.php
|
||||
chmod 750 "$install_dir"
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# PREPARE AND INSTALL APP
|
||||
|
@ -55,104 +55,67 @@ ynh_use_logrotate --logfile="$install_dir/documents/dolibarr.log"
|
|||
#=================================================
|
||||
# SETUP APPLICATION WITH CURL
|
||||
#=================================================
|
||||
|
||||
# Set right permissions for curl install
|
||||
chown -R "$app:" "$install_dir"
|
||||
|
||||
# Installation with curl
|
||||
|
||||
mkdir -p "/var/log/$app/"
|
||||
|
||||
ynh_script_progression --message="Finalizing installation..." --weight=1
|
||||
|
||||
ynh_script_progression --message="Generate fileconf" --weight=1
|
||||
ynh_local_curl "/install/fileconf.php" \
|
||||
"testpost=ok"
|
||||
# Create necessary files
|
||||
touch "$install_dir/htdocs/conf/conf.php"
|
||||
|
||||
ynh_script_progression --message="Generate fileconf" --weight=1
|
||||
ynh_local_curl "/install/fileconf.php" "testpost=ok"
|
||||
ynh_exec_fully_quiet sleep 5
|
||||
|
||||
ynh_script_progression --message="installation - step 1" --weight=3
|
||||
ynh_local_curl "/install/step1.php" \
|
||||
"testpost=ok" \
|
||||
"action=set" > /var/log/$app/install1.html
|
||||
|
||||
ynh_local_curl "/install/step1.php" "testpost=ok" "action=set"
|
||||
ynh_exec_fully_quiet sleep 5
|
||||
|
||||
ynh_script_progression --message="installation - step 2 (may take a while)..." --weight=72
|
||||
ynh_local_curl "/install/step2.php" \
|
||||
"testpost=ok" \
|
||||
"action=set" > /var/log/$app/install2.html
|
||||
|
||||
ynh_local_curl "/install/step2.php" "testpost=ok" "action=set"
|
||||
ynh_exec_fully_quiet sleep 5
|
||||
|
||||
ynh_script_progression --message="installation - step 4" --weight=3
|
||||
ynh_local_curl "/install/step4.php" \
|
||||
"testpost=ok" \
|
||||
"action=set" > /var/log/$app/install3.html
|
||||
|
||||
ynh_local_curl "/install/step4.php" "testpost=ok" "action=set"
|
||||
ynh_exec_fully_quiet sleep 5
|
||||
|
||||
# Generate a random password for the admin user (will be ignored because of LDAP)
|
||||
password=$(ynh_string_random 8)
|
||||
|
||||
ynh_script_progression --message="installation - step 5" --weight=4
|
||||
ynh_local_curl "/install/step5.php" \
|
||||
"testpost=ok" \
|
||||
"action=set" \
|
||||
"pass=$password" \
|
||||
"pass_verif=$password" > /var/log/$app/install4.html
|
||||
|
||||
ynh_local_curl "/install/step5.php" "testpost=ok" "action=set" "pass=$password" "pass_verif=$password"
|
||||
ynh_exec_fully_quiet sleep 5
|
||||
|
||||
ynh_script_progression --message="configuring LDAP" --weight=1
|
||||
|
||||
# Populate the LDAP parameters
|
||||
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ../conf/sql/ldap.sql
|
||||
|
||||
# Populate the database with YNH users.
|
||||
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ../conf/sql/ldap_user.sql
|
||||
|
||||
if php$phpversion $install_dir/scripts/user/sync_users_ldap2dolibarr.php commitiferror --server=localhost -y; then
|
||||
ynh_print_info --message="LDAP user update ok"
|
||||
else
|
||||
ynh_print_info --message="LDAP user update ended with error"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="configuring config file" --weight=1
|
||||
|
||||
# Setup HTTP auth in conf
|
||||
ynh_replace_string --match_string="dolibarr_main_authentication='dolibarr'" --replace_string="dolibarr_main_authentication='http'" --target_file="$install_dir/htdocs/conf/conf.php"
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum --file="$install_dir/htdocs/conf/conf.php"
|
||||
chmod 644 "$install_dir/htdocs/conf/conf.php"
|
||||
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1
|
||||
|
||||
# Set permissions on app files
|
||||
if [ ! -f "$data_dir/install.lock" ]; then
|
||||
echo 'This is a lock file to prevent use of install pages (set with permission 440)' > "$data_dir/install.lock"
|
||||
chown $app:$app "$data_dir/install.lock"
|
||||
chmod 440 "$data_dir/install.lock"
|
||||
if [ ! -f "$install_dir/documents/install.lock" ]; then
|
||||
echo 'This is a lock file to prevent use of install pages (set with permission 440)' > "$install_dir/documents/install.lock"
|
||||
chown "$app:$app" "$install_dir/documents/install.lock"
|
||||
chmod 440 "$install_dir/documents/install.lock"
|
||||
fi
|
||||
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
|
||||
chmod 644 "$install_dir/htdocs/conf/conf.php"
|
||||
mkdir -p "$data_dir"
|
||||
chown -R $app: "$data_dir"
|
||||
chmod go-w $data_dir
|
||||
mkdir -p "$install_dir/documents"
|
||||
chown -R "$app:" "$install_dir/documents"
|
||||
chmod go-w "$install_dir/documents"
|
||||
|
||||
#=================================================
|
||||
# SETUP LDAP IN DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring LDAP" --weight=1
|
||||
|
||||
# Populate the LDAP parameters
|
||||
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < ../conf/sql/ldap.sql
|
||||
|
||||
# Populate the database with YNH users.
|
||||
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < ../conf/sql/ldap_user.sql
|
||||
|
||||
if "php$phpversion" "$install_dir/scripts/user/sync_users_ldap2dolibarr.php" commitiferror --server=localhost -y; then
|
||||
ynh_print_warn --message="LDAP user update ended with error"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -10,78 +8,27 @@ source _common.sh
|
|||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
# REMOVE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#REMOVEME? db_user=$db_name
|
||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
#REMOVEME? ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Removing the MySQL database..." --weight=9
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
#REMOVEME? ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||
|
||||
# Remove the app directory securely
|
||||
#REMOVEME? ynh_secure_remove --file="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1
|
||||
|
||||
# Remove the dedicated php-fpm config
|
||||
ynh_remove_fpm_config
|
||||
|
||||
# Delete old static pool.d conf
|
||||
old_php_version=7.0
|
||||
if [ -f /etc/php/$old_php_version/fpm/pool.d/$app.conf ]; then
|
||||
ynh_secure_remove --file=/etc/php/$old_php_version/fpm/pool.d/$app.conf
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE APP FOLDERS
|
||||
# REMOVE OLD FILES
|
||||
#=================================================
|
||||
# Delete old static pool.d conf
|
||||
old_php_version=7.0
|
||||
if [ -f "/etc/php/$old_php_version/fpm/pool.d/$app.conf" ]; then
|
||||
ynh_secure_remove --file="/etc/php/$old_php_version/fpm/pool.d/$app.conf"
|
||||
fi
|
||||
|
||||
# Remove a directory securely
|
||||
ynh_secure_remove --file="/etc/$app"
|
||||
|
@ -89,16 +36,6 @@ ynh_secure_remove --file="/etc/$app"
|
|||
# Remove the log files
|
||||
ynh_secure_remove --file="/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||
|
||||
# Delete a system user
|
||||
#REMOVEME? ynh_system_user_delete --username=$app
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
107
scripts/restore
107
scripts/restore
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -10,49 +8,6 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading settings..." --weight=1
|
||||
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#REMOVEME? db_user=$db_name
|
||||
#REMOVEME? data_dir=$install_dir/documents/
|
||||
|
||||
#REMOVEME? fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||
#REMOVEME? fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
||||
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||
|
||||
#REMOVEME? test ! -d $install_dir \
|
||||
|| ynh_die --message="There is already a directory: $install_dir "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=3
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
#REMOVEME? ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
@ -60,73 +15,41 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
|
|||
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
|
||||
# Define and install dependencies
|
||||
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
||||
chmod 644 "$install_dir/htdocs/conf/conf.php"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Reconfiguring PHP-FPM..."
|
||||
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
|
||||
|
||||
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||
|
||||
# Restore the file first, so it can have a backup if different
|
||||
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
|
||||
# Recreate a dedicated php-fpm config
|
||||
ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_add_fpm_config --phpversion="$phpversion"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Restoring the MySQL database..." --weight=27
|
||||
|
||||
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
#REMOVEME? ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1
|
||||
|
||||
# Set permissions on app files
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
chmod 644 "$install_dir/htdocs/conf/conf.php"
|
||||
mkdir -p "$data_dir"
|
||||
chown -R $app: "$data_dir"
|
||||
chmod go-w $data_dir
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
|
||||
ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -9,49 +7,8 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=2
|
||||
update_version=$(ynh_app_upstream_version)
|
||||
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
||||
#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||
#REMOVEME? language=$(ynh_app_setting_get --app=$app --key=language)
|
||||
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#REMOVEME? current_version=$(ynh_app_setting_get --app=$app --key=version)
|
||||
update_version=$(ynh_app_upstream_version "../manifest.json")
|
||||
#REMOVEME? data_dir=$install_dir/documents/
|
||||
|
||||
#REMOVEME? fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||
#REMOVEME? fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
||||
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=11
|
||||
|
||||
# Backup the current version of the app
|
||||
#REMOVEME? ynh_backup_before_upgrade
|
||||
#REMOVEME? ynh_clean_setup () {
|
||||
# restore it if the upgrade fails
|
||||
#REMOVEME? ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
|
@ -144,7 +101,7 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2
|
|||
# ynh_secure_remove --file="/etc/php/$phpversion/fpm/conf.d/20-$app.ini"
|
||||
# fi
|
||||
# ynh_systemd_action --service_name="php${phpversion}-fpm" --action=reload
|
||||
|
||||
|
||||
# phpversion="$YNH_PHP_VERSION"
|
||||
# fi
|
||||
|
||||
|
@ -171,7 +128,7 @@ then
|
|||
# While the current version is not the last version, do an upgrade
|
||||
while [ "$last_version" != "$current_version" ]
|
||||
do
|
||||
|
||||
|
||||
# The major version is the first part of the version number
|
||||
current_major_version=${current_version%%.*}
|
||||
|
||||
|
@ -180,7 +137,7 @@ then
|
|||
else
|
||||
source upgrade.d/upgrade.$current_major_version.sh
|
||||
fi
|
||||
|
||||
|
||||
# If the current version has the same major version than the next one,
|
||||
# then it's the last upgrade to do
|
||||
# We also cover the case where the last version is the first of the current major version series
|
||||
|
@ -188,12 +145,12 @@ then
|
|||
if [[ ("$last_major_version" -eq "$current_major_version") || ( ("$last_major_version" -eq "$((current_major_version+1))") && ("$next_version" == "$last_version") ) ]]; then
|
||||
current_major_version=last
|
||||
fi
|
||||
|
||||
|
||||
# Load the value for this version
|
||||
source upgrade.d/upgrade.$current_major_version.sh
|
||||
|
||||
ynh_print_info --message="Upgrading app from $current_version to $next_version"
|
||||
|
||||
|
||||
# Create an app.src for this version of Dolibarr
|
||||
cat > ../conf/app.src << EOF
|
||||
SOURCE_URL=https://github.com/Dolibarr/dolibarr/archive/$next_version.tar.gz
|
||||
|
@ -212,35 +169,35 @@ EOF
|
|||
then
|
||||
ynh_secure_remove $lock
|
||||
fi
|
||||
|
||||
|
||||
mkdir -p /var/log/$app/
|
||||
|
||||
|
||||
# Upgrade with CURL
|
||||
|
||||
|
||||
# Set the app as temporarily public for cURL call
|
||||
if ! ynh_permission_has_user --permission "main" --user="visitors"; then
|
||||
#REMOVEME? ynh_permission_update --permission="main" --add="visitors"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
charset=$(mysql -ss -N -e "SELECT default_character_set_name FROM information_schema.SCHEMATA WHERE schema_name = '$db_name'")
|
||||
if [ "$charset" != "utf8" ]
|
||||
then
|
||||
ynh_print_info --message="Changing Database charset to utf8"
|
||||
|
||||
|
||||
ynh_mysql_execute_as_root --database=$db_name --sql="ALTER DATABASE $db_name charset=utf8"
|
||||
|
||||
|
||||
ynh_local_curl "/install/repair.php" \
|
||||
"force_utf8_on_tables=confirmed" > /var/log/$app/repair.html
|
||||
fi
|
||||
|
||||
ynh_exec_fully_quiet sleep 5
|
||||
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
|
||||
|
||||
pushd $install_dir/htdocs/install/
|
||||
|
||||
|
||||
if php$phpversion upgrade.php $current_version $next_version > /var/log/$app/upgrade.html; then
|
||||
ynh_print_info --message="Step 1 upgrading ended successfully"
|
||||
else
|
||||
|
@ -262,24 +219,24 @@ EOF
|
|||
else
|
||||
ynh_die --message="Step 3 upgrading ended with error"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
popd
|
||||
|
||||
|
||||
#REMOVEME? ynh_permission_update --permission="main" --remove="visitors"
|
||||
|
||||
|
||||
# Get the new current version number
|
||||
current_version=$next_version
|
||||
current_major_version=${current_version%%.*}
|
||||
|
||||
|
||||
done
|
||||
|
||||
|
||||
if php$phpversion $install_dir/scripts/user/sync_users_ldap2dolibarr.php commitiferror --server=localhost -y; then
|
||||
ynh_print_info --message="LDAP user update ok"
|
||||
else
|
||||
ynh_print_info --message="LDAP user update ended with error"
|
||||
fi
|
||||
|
||||
|
||||
ynh_app_setting_set --app=$app --key=version --value=$update_version
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in a new issue