1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/dolibarr_ynh.git synced 2024-09-03 18:35:53 +02:00

Remove src_path reference

This commit is contained in:
mastereur 2019-06-27 22:44:38 +02:00
parent ac1e171f6d
commit ac29cb1b27
6 changed files with 51 additions and 62 deletions

View file

@ -2,7 +2,7 @@
location __PATH__/ { location __PATH__/ {
# Path to source # Path to source
alias __FINALPATH__/ ; alias __FINALPATH__/htdocs/ ;
# Force usage of https # Force usage of https
if ($scheme = http) { if ($scheme = http) {

View file

@ -24,7 +24,6 @@ ynh_script_progression --message="Loading installation settings..." --time --wei
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
src_path=$(ynh_app_setting_get --app=$app --key=src_path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
@ -36,7 +35,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#================================================= #=================================================
ynh_script_progression --message="Backing up the main app directory..." --time --weight=1 ynh_script_progression --message="Backing up the main app directory..." --time --weight=1
ynh_backup --src_path="$src_path" ynh_backup --src_path="$final_path"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION

View file

@ -55,13 +55,9 @@ ynh_script_progression --message="Validating installation parameters..." --time
### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". ### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app" ### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
final_path=/var/www/$app final_path=/var/www/$app
src_path=$final_path
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Then adjust to dolibarr specificity (app is in htdocs sub-directory)
final_path=/var/www/$app/htdocs/
# Register (book) web path # Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
@ -107,15 +103,14 @@ ynh_script_progression --message="Setting up source files..." --time --weight=1
### `ynh_setup_source` use the file conf/app.src ### `ynh_setup_source` use the file conf/app.src
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
ynh_app_setting_set --app=$app --key=src_path --value=$src_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_script_progression --message="Download source files..." --time --weight=1 ynh_script_progression --message="Download source files..." --time --weight=1
ynh_setup_source --dest_dir="$src_path" ynh_setup_source --dest_dir="$final_path"
# Create necessary files # Create necessary files
datadir=$src_path/documents datadir=$final_path/documents
touch $final_path/conf/conf.php touch $final_path/htdocs/conf/conf.php
mkdir -p $datadir mkdir -p $datadir
chmod go-w $datadir chmod go-w $datadir
@ -162,7 +157,7 @@ ynh_add_fpm_config
# PREPARE AND INSTALL APP # PREPARE AND INSTALL APP
#================================================= #=================================================
finstall="$final_path/install/install.forced.php" finstall="$final_path/htdocs/install/install.forced.php"
cp ../conf/install.forced.php "$finstall" cp ../conf/install.forced.php "$finstall"
# Change variables in Wordpress configuration # Change variables in Wordpress configuration
@ -180,7 +175,7 @@ fi
fhook=../hooks/post_user_create fhook=../hooks/post_user_create
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$fhook" ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$fhook"
ynh_replace_string --match_string="__MEMBER__" --replace_string="$member" --target_file="$fhook" ynh_replace_string --match_string="__MEMBER__" --replace_string="$member" --target_file="$fhook"
ynh_replace_string --match_string="__SRCPATH__" --replace_string="$src_path" --target_file="$fhook" ynh_replace_string --match_string="__SRCPATH__" --replace_string="$final_path" --target_file="$fhook"
#================================================= #=================================================
@ -193,7 +188,7 @@ ynh_replace_string --match_string="__SRCPATH__" --replace_string="$src_path" --t
### forms. ### forms.
# Set right permissions for curl install # Set right permissions for curl install
chown -R $app "$src_path" chown -R $app "$final_path"
# Set the app as temporarily public for curl call # Set the app as temporarily public for curl call
@ -245,7 +240,7 @@ ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ..
# Populate the database with YNH users. # Populate the database with YNH users.
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ../conf/sql/ldap_user.sql ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ../conf/sql/ldap_user.sql
if php $src_path/scripts/user/sync_users_ldap2dolibarr.php commitiferror --server=localhost -y; then if php $final_path/scripts/user/sync_users_ldap2dolibarr.php commitiferror --server=localhost -y; then
ynh_print_info --message="ldap user update ok" ynh_print_info --message="ldap user update ok"
else else
ynh_print_warn --message="ldap user update ended with error" ynh_print_warn --message="ldap user update ended with error"
@ -256,7 +251,7 @@ if [ $member -eq 1 ]
then then
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ../conf/sql/ldap_member.sql ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ../conf/sql/ldap_member.sql
if php $src_path/scripts/members/sync_members_ldap2dolibarr.php commitiferror 1 --server=localhost -y; then if php $final_path/scripts/members/sync_members_ldap2dolibarr.php commitiferror 1 --server=localhost -y; then
ynh_print_info --message="ldap member update ok" ynh_print_info --message="ldap member update ok"
else else
ynh_print_warn --message="ldap member update ended with error" ynh_print_warn --message="ldap member update ended with error"
@ -278,7 +273,7 @@ fi
# Setup HTTP auth in conf # Setup HTTP auth in conf
ynh_script_progression --message="configuring config file" --time --weight=4 ynh_script_progression --message="configuring config file" --time --weight=4
ynh_replace_string --match_string="dolibarr_main_authentication='dolibarr'" --replace_string="dolibarr_main_authentication='http'" --target_file="$final_path/conf/conf.php" ynh_replace_string --match_string="dolibarr_main_authentication='dolibarr'" --replace_string="dolibarr_main_authentication='http'" --target_file="$final_path/htdocs/conf/conf.php"
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # STORE THE CONFIG FILE CHECKSUM
@ -289,7 +284,7 @@ ynh_replace_string --match_string="dolibarr_main_authentication='dolibarr'" --re
### you can make a backup of this file before modifying it again if the admin had modified it. ### you can make a backup of this file before modifying it again if the admin had modified it.
# 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="$final_path/conf/conf.php" ynh_store_file_checksum --file="$final_path/htdocs/conf/conf.php"
#================================================= #=================================================
# ADD A CRON JOB # ADD A CRON JOB
@ -308,9 +303,9 @@ touch $cron_path
### that really need such authorization. ### that really need such authorization.
# Set permissions to app files # Set permissions to app files
chown -R root "$src_path" chown -R root "$final_path"
chown -R $app "$datadir" chown -R $app "$datadir"
chmod 644 "$final_path/conf/conf.php" chmod 644 "$final_path/htdocs/conf/conf.php"
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
@ -326,7 +321,7 @@ ynh_script_progression --message="Configuring log rotation..." --time --weight=1
### - And the section "SETUP LOGROTATE" in the upgrade script ### - And the section "SETUP LOGROTATE" in the upgrade script
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate --logfile="$src_path/documents/dolibarr.log" ynh_use_logrotate --logfile="$final_path/documents/dolibarr.log"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT

View file

@ -21,7 +21,6 @@ port=$(ynh_app_setting_get --app=$app --key=port)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
src_path=$(ynh_app_setting_get --app=$app --key=src_path)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
@ -58,7 +57,7 @@ ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
ynh_script_progression --message="Removing app main directory..." --time --weight=1 ynh_script_progression --message="Removing app main directory..." --time --weight=1
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$src_path" ynh_secure_remove --file="$final_path"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION

View file

@ -30,7 +30,6 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) path_url=$(ynh_app_setting_get --app=$app --key=path)
src_path=$(ynh_app_setting_get --app=$app --key=src_path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
@ -42,8 +41,8 @@ ynh_script_progression --message="Validating restoration parameters..." --time -
ynh_webpath_available --domain=$domain --path_url=$path_url \ ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die --message="Path not available: ${domain}${path_url}" || ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d $src_path \ test ! -d $final_path \
|| ynh_die --message="There is already a directory: $src_path " || ynh_die --message="There is already a directory: $final_path "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
@ -58,7 +57,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 ynh_script_progression --message="Restoring the app main directory..." --time --weight=1
ynh_restore_file --origin_path="$src_path" ynh_restore_file --origin_path="$final_path"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
@ -73,7 +72,7 @@ ynh_system_user_create --username=$app
#================================================= #=================================================
# Restore permissions on app files # Restore permissions on app files
chown -R root: $src_path chown -R root: $final_path
#================================================= #=================================================
# RESTORE THE PHP-FPM CONFIGURATION # RESTORE THE PHP-FPM CONFIGURATION

View file

@ -21,12 +21,11 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin) admin=$(ynh_app_setting_get --app=$app --key=admin)
is_public=$(ynh_app_setting_get --app=$app --key=is_public) is_public=$(ynh_app_setting_get --app=$app --key=is_public)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
src_path=$(ynh_app_setting_get --app=$app --key=src_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)
current_version=$(ynh_app_setting_get --app=$app --key=version) current_version=$(ynh_app_setting_get --app=$app --key=version)
update_version=$(ynh_app_upstream_version "../manifest.json") update_version=$(ynh_app_upstream_version "../manifest.json")
datadir=$src_path/documents datadir=$final_path/documents
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -62,13 +61,9 @@ fi
# If final_path doesn't exist, create it # If final_path doesn't exist, create it
if [ -z "$final_path" ]; then if [ -z "$final_path" ]; then
src_path=/var/www/$app final_path=/var/www/$app
# Then adjust to dolibarr specificity (app is in htdocs sub-directory)
final_path=$src_path/htdocs/
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
ynh_app_setting_set --app=$app --key=src_path --value=$src_path
fi fi
#================================================= #=================================================
@ -108,7 +103,7 @@ then
ynh_script_progression --message="Upgrading source files..." --time --weight=1 ynh_script_progression --message="Upgrading source files..." --time --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 --dest_dir="$src_path" ynh_setup_source --dest_dir="$final_path"
fi fi
#================================================= #=================================================
@ -140,32 +135,34 @@ ynh_add_fpm_config
#================================================= #=================================================
# LAUNCH UPGRADE # LAUNCH UPGRADE
#================================================= #=================================================
ynh_script_progression --message="Upgrading app from $current_version to $update_version" --time --weight=1
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading app from $current_version to $update_version" --time --weight=1
chown -R $app "$src_path" chown -R $app "$final_path"
# Remove the lock if it exists
lock=$final_path/documents/install.lock
[[ -f $lock ]] && sudo rm $lock
# Remove the lock if it exists # Upgrade with CURL
lock=$src_path/documents/install.lock cd $final_path/htdocs/install/
[[ -f $lock ]] && sudo rm $lock if php upgrade.php $current_version $update_version > /var/log/$app/upgrade.html; then
# Upgrade with CURL
cd $final_path/install/
if php upgrade.php $current_version $update_version > /var/log/$app/upgrade.html; then
ynh_print_info --message="Step 1 upgrading ended successfully" ynh_print_info --message="Step 1 upgrading ended successfully"
else else
ynh_print_warn --message="Step 1 upgrading ended with error" ynh_print_warn --message="Step 1 upgrading ended with error"
fi fi
if php upgrade2.php $current_version $update_version > /var/log/$app/upgrade2.html; then if php upgrade2.php $current_version $update_version > /var/log/$app/upgrade2.html; then
ynh_print_info --message="Step 2 upgrading ended successfully" ynh_print_info --message="Step 2 upgrading ended successfully"
else else
ynh_print_warn --message="Step 2 upgrading ended with error" ynh_print_warn --message="Step 2 upgrading ended with error"
fi fi
if php step5.php $current_version $update_version > /var/log/$app/upgrade3.html; then if php step5.php $current_version $update_version > /var/log/$app/upgrade3.html; then
ynh_print_info --message="Step 3 upgrading ended successfully" ynh_print_info --message="Step 3 upgrading ended successfully"
else else
ynh_print_warn --message="Step 3 upgrading ended with error" ynh_print_warn --message="Step 3 upgrading ended with error"
fi
fi fi
#================================================= #=================================================
@ -174,9 +171,9 @@ fi
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. ### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
ynh_backup_if_checksum_is_different --file="$final_path/conf/conf.php" ynh_backup_if_checksum_is_different --file="$final_path/htdocs/conf/conf.php"
# Recalculate and store the checksum of the file for the next upgrade. # Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$final_path/conf/conf.php" ynh_store_file_checksum --file="$final_path/htdocs/conf/conf.php"
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
@ -194,8 +191,8 @@ ynh_use_logrotate --non-append
# Set permissions on app files # Set permissions on app files
# Set permissions to app files # Set permissions to app files
chown -R root "$src_path" chown -R root "$final_path"
chmod 644 "$final_path/conf/conf.php" chmod 644 "$final_path/htdocs/conf/conf.php"
chown -R $app "$datadir" chown -R $app "$datadir"
chmod go-w $datadir chmod go-w $datadir