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,18 +1,20 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env 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)
|
# 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__
|
# member=__MEMBER__
|
||||||
|
|
||||||
# Sync users
|
# Sync users
|
||||||
if sudo php "$src_path/scripts/user/sync_users_ldap2dolibarr.php" commitiferror --server=localhost -y; then
|
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
|
else
|
||||||
echo ldap user update ended with error
|
echo "LDAP user update ended with error"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If YNH users should also be members, sync members
|
# If YNH users should also be members, sync members
|
||||||
# if [ $member -eq 1 ];
|
# if [ $member -eq 1 ]; then
|
||||||
# then
|
|
||||||
# if sudo php "$src_path/scripts/members/sync_members_ldap2dolibarr.php" commitiferror 1 --server=localhost -y; then
|
# if sudo php "$src_path/scripts/members/sync_members_ldap2dolibarr.php" commitiferror 1 --server=localhost -y; then
|
||||||
# echo ldap member update ok
|
# echo ldap member update ok
|
||||||
# else
|
# else
|
||||||
|
|
|
@ -69,6 +69,7 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen
|
||||||
"php8.1-soap",
|
"php8.1-soap",
|
||||||
"php8.1-curl",
|
"php8.1-curl",
|
||||||
"php8.1-intl",
|
"php8.1-intl",
|
||||||
|
"php8.1-ldap",
|
||||||
"php8.1-opcache",
|
"php8.1-opcache",
|
||||||
"php8.1-calendar",
|
"php8.1-calendar",
|
||||||
"php8.1-zip",
|
"php8.1-zip",
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -10,25 +8,6 @@
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
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
|
# 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"
|
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"
|
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"
|
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC BACKUP
|
|
||||||
#=================================================
|
|
||||||
# BACKUP LOGROTATE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC STARTING
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -9,61 +7,6 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
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
|
# MODIFY URL IN NGINX CONF
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -71,46 +14,13 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
|
||||||
|
|
||||||
ynh_change_url_nginx_config
|
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
|
# 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"
|
ynh_replace_string --target_file="$install_dir/htdocs/conf/conf.php" \
|
||||||
|
--match_string="$old_domain$old_path" \
|
||||||
#=================================================
|
--replace_string="$new_domain$new_path"
|
||||||
# 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
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# 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
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source --source_id="main" --dest_dir="$install_dir"
|
ynh_setup_source --source_id="main" --dest_dir="$install_dir"
|
||||||
|
|
||||||
# Create necessary files
|
chmod 750 "$install_dir"
|
||||||
touch $install_dir/htdocs/conf/conf.php
|
chown -R "$app:www-data" "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PREPARE AND INSTALL APP
|
# PREPARE AND INSTALL APP
|
||||||
|
@ -55,104 +55,67 @@ ynh_use_logrotate --logfile="$install_dir/documents/dolibarr.log"
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP APPLICATION WITH CURL
|
# 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="Finalizing installation..." --weight=1
|
||||||
|
|
||||||
ynh_script_progression --message="Generate fileconf" --weight=1
|
# Create necessary files
|
||||||
ynh_local_curl "/install/fileconf.php" \
|
touch "$install_dir/htdocs/conf/conf.php"
|
||||||
"testpost=ok"
|
|
||||||
|
|
||||||
|
ynh_script_progression --message="Generate fileconf" --weight=1
|
||||||
|
ynh_local_curl "/install/fileconf.php" "testpost=ok"
|
||||||
ynh_exec_fully_quiet sleep 5
|
ynh_exec_fully_quiet sleep 5
|
||||||
|
|
||||||
ynh_script_progression --message="installation - step 1" --weight=3
|
ynh_script_progression --message="installation - step 1" --weight=3
|
||||||
ynh_local_curl "/install/step1.php" \
|
ynh_local_curl "/install/step1.php" "testpost=ok" "action=set"
|
||||||
"testpost=ok" \
|
|
||||||
"action=set" > /var/log/$app/install1.html
|
|
||||||
|
|
||||||
ynh_exec_fully_quiet sleep 5
|
ynh_exec_fully_quiet sleep 5
|
||||||
|
|
||||||
ynh_script_progression --message="installation - step 2 (may take a while)..." --weight=72
|
ynh_script_progression --message="installation - step 2 (may take a while)..." --weight=72
|
||||||
ynh_local_curl "/install/step2.php" \
|
ynh_local_curl "/install/step2.php" "testpost=ok" "action=set"
|
||||||
"testpost=ok" \
|
|
||||||
"action=set" > /var/log/$app/install2.html
|
|
||||||
|
|
||||||
ynh_exec_fully_quiet sleep 5
|
ynh_exec_fully_quiet sleep 5
|
||||||
|
|
||||||
ynh_script_progression --message="installation - step 4" --weight=3
|
ynh_script_progression --message="installation - step 4" --weight=3
|
||||||
ynh_local_curl "/install/step4.php" \
|
ynh_local_curl "/install/step4.php" "testpost=ok" "action=set"
|
||||||
"testpost=ok" \
|
|
||||||
"action=set" > /var/log/$app/install3.html
|
|
||||||
|
|
||||||
ynh_exec_fully_quiet sleep 5
|
ynh_exec_fully_quiet sleep 5
|
||||||
|
|
||||||
# Generate a random password for the admin user (will be ignored because of LDAP)
|
# Generate a random password for the admin user (will be ignored because of LDAP)
|
||||||
password=$(ynh_string_random 8)
|
password=$(ynh_string_random 8)
|
||||||
|
|
||||||
ynh_script_progression --message="installation - step 5" --weight=4
|
ynh_script_progression --message="installation - step 5" --weight=4
|
||||||
ynh_local_curl "/install/step5.php" \
|
ynh_local_curl "/install/step5.php" "testpost=ok" "action=set" "pass=$password" "pass_verif=$password"
|
||||||
"testpost=ok" \
|
|
||||||
"action=set" \
|
|
||||||
"pass=$password" \
|
|
||||||
"pass_verif=$password" > /var/log/$app/install4.html
|
|
||||||
|
|
||||||
ynh_exec_fully_quiet sleep 5
|
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
|
# 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"
|
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
|
# Calculate and store the config file checksum into the app settings
|
||||||
ynh_store_file_checksum --file="$install_dir/htdocs/conf/conf.php"
|
ynh_store_file_checksum --file="$install_dir/htdocs/conf/conf.php"
|
||||||
|
chmod 644 "$install_dir/htdocs/conf/conf.php"
|
||||||
|
|
||||||
#=================================================
|
if [ ! -f "$install_dir/documents/install.lock" ]; then
|
||||||
# SECURE FILES AND DIRECTORIES
|
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"
|
||||||
#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1
|
chmod 440 "$install_dir/documents/install.lock"
|
||||||
|
|
||||||
# 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"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod 750 "$install_dir"
|
|
||||||
chmod -R o-rwx "$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 "$install_dir/documents"
|
||||||
mkdir -p "$data_dir"
|
chown -R "$app:" "$install_dir/documents"
|
||||||
chown -R $app: "$data_dir"
|
chmod go-w "$install_dir/documents"
|
||||||
chmod go-w $data_dir
|
|
||||||
|
#=================================================
|
||||||
|
# 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
|
# END OF SCRIPT
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -10,78 +8,27 @@ source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# REMOVE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
ynh_script_progression --message="Removing system configurations related to $app..." --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
|
|
||||||
|
|
||||||
# Remove the dedicated nginx config
|
# Remove the dedicated nginx config
|
||||||
ynh_remove_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
|
# Remove the dedicated php-fpm config
|
||||||
ynh_remove_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
|
# Remove the app-specific logrotate config
|
||||||
ynh_remove_logrotate
|
ynh_remove_logrotate
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC REMOVE
|
# REMOVE OLD FILES
|
||||||
#=================================================
|
|
||||||
# REMOVE APP FOLDERS
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
# 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
|
# Remove a directory securely
|
||||||
ynh_secure_remove --file="/etc/$app"
|
ynh_secure_remove --file="/etc/$app"
|
||||||
|
@ -89,16 +36,6 @@ ynh_secure_remove --file="/etc/$app"
|
||||||
# Remove the log files
|
# Remove the log files
|
||||||
ynh_secure_remove --file="/var/log/$app"
|
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
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
107
scripts/restore
107
scripts/restore
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -10,49 +8,6 @@
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
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
|
# 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"
|
ynh_restore_file --origin_path="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
chmod 750 "$install_dir"
|
||||||
# SPECIFIC RESTORATION
|
chmod -R o-rwx "$install_dir"
|
||||||
#=================================================
|
chown -R "$app:www-data" "$install_dir"
|
||||||
# REINSTALL DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
|
||||||
|
|
||||||
# Define and install dependencies
|
chmod 644 "$install_dir/htdocs/conf/conf.php"
|
||||||
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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
|
# 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"
|
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
# Recreate a dedicated php-fpm config
|
# Recreate a dedicated php-fpm config
|
||||||
ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint
|
ynh_add_fpm_config --phpversion="$phpversion"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE THE NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
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"
|
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
|
# RELOAD NGINX AND PHP-FPM
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
|
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=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
|
# END OF SCRIPT
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -9,49 +7,8 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
update_version=$(ynh_app_upstream_version)
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=2
|
|
||||||
|
|
||||||
#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
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Reference in a new issue