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

update again

This commit is contained in:
Salamandar 2024-03-25 23:52:00 +01:00
parent f0c9b095f7
commit 133de8d19d

View file

@ -52,69 +52,37 @@ ynh_use_logrotate --logfile="$install_dir/documents/dolibarr.log"
#================================================= #=================================================
# SETUP APPLICATION WITH CURL # SETUP APPLICATION WITH CURL
#================================================= #=================================================
# Installation with curl
ynh_script_progression --message="Configuring $app..." --weight=1
# Create necessary files # Create necessary files
touch "$install_dir/htdocs/conf/conf.php" touch "$install_dir/htdocs/conf/conf.php"
# chown -R "$app:www-data" "$install_dir"
# Set right permissions for curl install # Set right permissions for curl install
chown -R "$app:" "$install_dir" chown -R "$app:" "$install_dir"
# Installation with curl
ynh_script_progression --message="Finalizing installation..." --weight=1
ynh_script_progression --message="Generate fileconf" --weight=1 ynh_script_progression --message="Generate fileconf" --weight=1
ynh_local_curl "/install/fileconf.php" "testpost=ok" 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" "testpost=ok" "action=set" ynh_local_curl "/install/step1.php" "testpost=ok" "action=set"
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" "testpost=ok" "action=set" ynh_local_curl "/install/step2.php" "testpost=ok" "action=set"
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" "testpost=ok" "action=set" ynh_local_curl "/install/step4.php" "testpost=ok" "action=set"
ynh_exec_fully_quiet sleep 5 ynh_exec_fully_quiet sleep 5
cp "$install_dir/htdocs/conf/conf.php" "$install_dir/htdocs/conf/conf.php.intermediate"
# 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" "testpost=ok" "action=set" "pass=$password" "pass_verif=$password" ynh_local_curl "/install/step5.php" "testpost=ok" "action=set" "pass=$password" "pass_verif=$password"
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 --target_file="$install_dir/htdocs/conf/conf.php" \ ynh_replace_string --target_file="$install_dir/htdocs/conf/conf.php" \
--match_string="dolibarr_main_authentication='dolibarr'" \ --match_string="dolibarr_main_authentication='dolibarr'" \
@ -122,24 +90,41 @@ ynh_replace_string --target_file="$install_dir/htdocs/conf/conf.php" \
# 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"
# Set permissions on app files
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
#=================================================
# SETUP LDAP
#=================================================
ynh_script_progression --message="Configuring LDAP for $app..." --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
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 #REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1
# Set permissions on app files
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 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 "$install_dir/documents"
chown -R "$app:" "$install_dir/documents" chown -R "$app:" "$install_dir/documents"
chmod go-w "$install_dir/documents" chmod go-w "$install_dir/documents"