2017-10-22 01:11:59 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
2022-07-15 17:38:25 +02:00
|
|
|
admin_pwd=$(openssl passwd -1 -salt xyz $password)
|
2019-04-05 20:58:52 +02:00
|
|
|
|
2017-10-22 01:11:59 +02:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2021-01-26 09:03:08 +01:00
|
|
|
ynh_script_progression --message="Setting up source files..."
|
2017-10-22 01:11:59 +02:00
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2023-09-01 22:10:13 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2017-10-22 01:11:59 +02:00
|
|
|
|
2023-09-01 22:18:33 +02:00
|
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
|
2018-06-04 14:51:37 +02:00
|
|
|
#=================================================
|
|
|
|
# PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
2021-01-26 09:41:19 +01:00
|
|
|
ynh_script_progression --message="Configuring PHP-FPM..."
|
2018-06-04 14:51:37 +02:00
|
|
|
|
|
|
|
# Create a dedicated php-fpm config
|
2023-09-01 22:18:33 +02:00
|
|
|
ynh_add_fpm_config --usage=low --footprint=low
|
2022-07-15 17:38:25 +02:00
|
|
|
|
|
|
|
# Create a dedicated nginx config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
2017-10-22 01:11:59 +02:00
|
|
|
#=================================================
|
|
|
|
# MODIFY A CONFIG FILE
|
|
|
|
#=================================================
|
2022-07-15 17:38:25 +02:00
|
|
|
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
2017-10-22 01:11:59 +02:00
|
|
|
|
2023-09-01 22:10:13 +02:00
|
|
|
ynh_add_config --template="../conf/config.php" --destination="$install_dir/config.php"
|
2021-02-07 11:17:07 +01:00
|
|
|
|
2023-09-01 22:10:13 +02:00
|
|
|
chmod 400 "$install_dir/config.php"
|
|
|
|
chown $app:$app "$install_dir/config.php"
|
2021-02-07 10:41:09 +01:00
|
|
|
|
2023-09-01 22:10:13 +02:00
|
|
|
ynh_replace_string --match_string="\$enabled = false;" --replace_string="\$enabled = true;" --target_file="$install_dir/scripts/setup.php"
|
2021-02-07 10:41:09 +01:00
|
|
|
|
|
|
|
# Replace variables in SQL scripts
|
2021-02-07 12:01:38 +01:00
|
|
|
ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="../conf/admin.sql"
|
|
|
|
ynh_replace_string --match_string="__ADMIN_PWD__" --replace_string="$admin_pwd" --target_file="../conf/admin.sql"
|
2017-10-22 01:11:59 +02:00
|
|
|
|
2021-01-26 09:17:31 +01:00
|
|
|
#=================================================
|
|
|
|
# SETUP APPLICATION WITH CURL
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Finalizing installation..."
|
2019-04-12 20:21:58 +02:00
|
|
|
|
2021-01-26 09:17:31 +01:00
|
|
|
ynh_local_curl "/scripts/setup.php" "command=setup"
|
2019-04-12 20:21:58 +02:00
|
|
|
|
2017-10-22 01:11:59 +02:00
|
|
|
#Add the admin account to the database
|
2022-07-15 17:38:25 +02:00
|
|
|
ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name < "../conf/admin.sql"
|
2017-10-22 01:11:59 +02:00
|
|
|
#Disable setup for security
|
2023-09-01 22:10:13 +02:00
|
|
|
ynh_replace_string --match_string="^\$enabled = true;" --replace_string="\$enabled = false;" --target_file="$install_dir/scripts/setup.php"
|
2017-10-22 01:11:59 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# SECURE FILES AND DIRECTORIES
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Set permissions to app files
|
2023-09-01 22:18:33 +02:00
|
|
|
#chmod 755 -R $install_dir
|
|
|
|
#chmod -R o-rwx $install_dir
|
|
|
|
#chown -R $app:www-data $install_dir
|
2019-04-05 20:58:52 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2021-01-26 09:03:08 +01:00
|
|
|
ynh_script_progression --message="Installation of $app completed"
|