2022-05-22 20:54:12 +02:00
#!/bin/bash
source _common.sh
source /usr/share/yunohost/helpers
2024-08-31 03:06:04 +02:00
ynh_app_setting_set --key=php_upload_max_filesize --value=256M
#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | fpm_footprint="low"
#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | fpm_free_footprint=0
#REMOVEME? Everything about fpm_usage is removed in helpers2.1... | fpm_usage="low"
2023-03-01 15:15:43 +01:00
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
2024-08-31 03:06:04 +02:00
#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_footprint --value=$fpm_footprint
#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_free_footprint --value=$fpm_free_footprint
#REMOVEME? Everything about fpm_usage is removed in helpers2.1... | ynh_app_setting_set --key=fpm_usage --value=$fpm_usage
2023-03-01 15:15:43 +01:00
2022-05-22 20:54:12 +02:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2024-08-31 03:06:04 +02:00
ynh_script_progression "Setting up source files..."
2022-05-22 20:54:12 +02:00
# Download, check integrity, uncompress and patch the source from app.src
2023-05-12 20:38:15 +02:00
source_id_to_use="main"
2023-05-12 21:04:57 +02:00
if [[ "$release_cycle" == "longterm" ]]
2023-05-12 20:38:15 +02:00
then
source_id_to_use="lts"
fi
ynh_setup_source --dest_dir="$install_dir" --source_id="$source_id_to_use"
2022-05-22 20:54:12 +02:00
2024-08-31 03:06:04 +02:00
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir"
2022-05-22 20:54:12 +02:00
#=================================================
# NGINX CONFIGURATION
#=================================================
2024-08-31 03:06:04 +02:00
ynh_script_progression "Configuring NGINX web server..."
2022-05-22 20:54:12 +02:00
# Create a dedicated NGINX config
2024-08-31 03:06:04 +02:00
ynh_config_add_nginx
2022-05-22 20:54:12 +02:00
# Create a dedicated PHP-FPM config
2024-08-31 03:06:04 +02:00
ynh_config_add_phpfpm
2022-05-22 20:54:12 +02:00
#=================================================
2023-02-21 21:51:30 +01:00
# ADD INITIAL CONFIGURATION
2022-05-22 20:54:12 +02:00
#=================================================
2024-08-31 03:06:04 +02:00
ynh_script_progression "Configuring $app..."
2022-05-22 20:54:12 +02:00
2023-02-21 21:51:30 +01:00
# Define a function to execute commands with proper permissions
exec_as_app() {
2024-08-31 03:06:04 +02:00
(cd "$install_dir" && ynh_exec_as_app \
php${php_version} --define apc.enable_cli=1 "$@")
2023-02-21 21:51:30 +01:00
}
2023-03-01 15:18:04 +01:00
# Create database configuration file
2024-08-31 03:06:04 +02:00
ynh_hide_warnings exec_as_app console.php database:configure "$app" "$db_pwd" "$app"
2023-02-21 21:51:30 +01:00
2023-03-01 15:15:43 +01:00
# Create database contents
2024-08-31 03:06:04 +02:00
ynh_hide_warnings exec_as_app console.php database:install
2023-02-21 21:51:30 +01:00
2023-06-06 20:53:53 +02:00
# Set default database directory
2023-06-06 21:31:30 +02:00
cd "$install_dir"
2023-06-09 22:34:03 +02:00
sed -i -e "s#storage/fgal#$data_dir#" lib/prefs/fgal.php
2023-03-01 15:15:43 +01:00
# Lock installer
2024-08-31 03:06:04 +02:00
ynh_hide_warnings exec_as_app console.php installer:lock
2022-05-22 20:54:12 +02:00
2023-03-01 15:15:43 +01:00
# Create data index
2024-08-31 03:06:04 +02:00
ynh_hide_warnings exec_as_app console.php index:rebuild
2022-05-22 20:54:12 +02:00
2023-03-01 15:15:43 +01:00
# Set on Long Term Support versions
2023-06-06 20:53:53 +02:00
if [[ "$release_cycle" == "longterm" ]]
then
2024-08-31 03:06:04 +02:00
ynh_hide_warnings exec_as_app console.php preferences:set tiki_release_cycle longterm
2023-06-06 20:53:53 +02:00
fi
2022-05-22 20:54:12 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2024-08-31 03:06:04 +02:00
ynh_script_progression "Installation of $app completed"