2017-07-12 01:45:37 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
2023-10-30 09:43:36 +01:00
|
|
|
email=$(ynh_user_get_info --username="$admin" --key="mail")
|
2022-03-23 08:21:02 +01:00
|
|
|
secret=$(ynh_string_random --length="16")
|
|
|
|
|
2017-07-12 01:45:37 +02:00
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
2023-10-30 09:43:36 +01:00
|
|
|
ynh_script_progression --message="Storing installation settings..."
|
2017-07-12 01:45:37 +02:00
|
|
|
|
2022-03-23 08:21:02 +01:00
|
|
|
ynh_app_setting_set --app=$app --key=secret --value=$secret
|
2017-07-12 01:45:37 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2022-01-22 20:55:44 +01:00
|
|
|
ynh_script_progression --message="Setting up source files..."
|
2017-07-12 01:45:37 +02:00
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2023-10-30 09:29:45 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2017-07-12 01:45:37 +02:00
|
|
|
|
2023-10-30 09:29:45 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2017-07-12 01:45:37 +02:00
|
|
|
|
|
|
|
#=================================================
|
2022-01-22 20:55:44 +01:00
|
|
|
# PHP-FPM CONFIGURATION
|
2017-07-12 01:45:37 +02:00
|
|
|
#=================================================
|
2022-01-22 20:55:44 +01:00
|
|
|
ynh_script_progression --message="Configuring PHP-FPM..."
|
2017-07-12 01:45:37 +02:00
|
|
|
|
2022-01-22 20:55:44 +01:00
|
|
|
# Create a dedicated PHP-FPM config
|
|
|
|
ynh_add_fpm_config
|
2022-08-27 21:52:03 +02:00
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
2017-07-12 01:45:37 +02:00
|
|
|
#=================================================
|
2022-01-22 20:55:44 +01:00
|
|
|
# SPECIFIC SETUP
|
2017-07-12 01:45:37 +02:00
|
|
|
#=================================================
|
2022-01-22 20:55:44 +01:00
|
|
|
# ADD A CONFIGURATION
|
2017-07-12 01:45:37 +02:00
|
|
|
#=================================================
|
2022-01-22 20:55:44 +01:00
|
|
|
ynh_script_progression --message="Adding a configuration file..."
|
2017-07-12 01:45:37 +02:00
|
|
|
|
2023-10-30 09:43:36 +01:00
|
|
|
ynh_add_config --template="configuration.php" --destination="$install_dir/configuration.php"
|
2022-01-22 20:55:44 +01:00
|
|
|
|
2023-10-30 09:29:45 +01:00
|
|
|
chmod 400 "$install_dir/configuration.php"
|
|
|
|
chown $app:$app "$install_dir/configuration.php"
|
2017-07-12 01:45:37 +02:00
|
|
|
|
|
|
|
#=================================================
|
2022-01-22 20:55:44 +01:00
|
|
|
# SETUP DATABASE
|
2017-07-12 01:45:37 +02:00
|
|
|
#=================================================
|
2022-01-22 20:55:44 +01:00
|
|
|
ynh_script_progression --message="Setuping database..."
|
|
|
|
|
2023-12-04 21:06:23 +01:00
|
|
|
ynh_mysql_execute_file_as_root --file="$install_dir/installation/sql/mysql/base.sql" --database=$db_name
|
|
|
|
ynh_mysql_execute_file_as_root --file="$install_dir/installation/sql/mysql/extensions.sql" --database=$db_name
|
|
|
|
ynh_mysql_execute_file_as_root --file="$install_dir/installation/sql/mysql/supports.sql" --database=$db_name
|
2023-10-30 10:25:20 +01:00
|
|
|
|
2023-12-04 21:06:23 +01:00
|
|
|
ynh_secure_remove --file="$install_dir/installation"
|
2023-10-30 10:25:20 +01:00
|
|
|
|
2023-12-04 21:06:23 +01:00
|
|
|
pushd "$install_dir"
|
|
|
|
php$phpversion cli/joomla.php user:add --username "$admin" --name "$admin" --password "$password" --email "$email" --usergroup "Super Users" -n
|
|
|
|
popd
|
2022-03-23 08:21:02 +01:00
|
|
|
|
2022-01-22 20:55:44 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# SETUP LOGROTATE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring log rotation..."
|
|
|
|
|
2022-03-23 08:21:02 +01:00
|
|
|
mkdir -p "/var/log/$app"
|
|
|
|
chmod 750 "/var/log/$app"
|
|
|
|
chmod -R o-rwx "/var/log/$app"
|
|
|
|
chown -R $app:www-data "/var/log/$app"
|
|
|
|
|
2022-01-22 20:55:44 +01:00
|
|
|
# Use logrotate to manage application logfile(s)
|
|
|
|
ynh_use_logrotate
|
2017-07-12 01:45:37 +02:00
|
|
|
|
2022-01-22 20:55:44 +01:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2017-07-12 01:45:37 +02:00
|
|
|
|
2022-01-22 20:55:44 +01:00
|
|
|
ynh_script_progression --message="Installation of $app completed"
|