2023-08-06 18:49:51 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2023-08-08 19:02:23 +02:00
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
email=$(ynh_user_get_info --username=$first_user --key=mail)
|
|
|
|
random_string="$(ynh_string_random --length=48)"
|
|
|
|
fpm_footprint="medium"
|
|
|
|
fpm_free_footprint=0
|
|
|
|
fpm_usage="medium"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Storing installation settings..." --weight=1
|
|
|
|
|
|
|
|
ynh_app_setting_set --app=$app --key=email --value=$email
|
|
|
|
ynh_app_setting_set --app=$app --key=first_user_pass --value=$first_user_pass
|
|
|
|
ynh_app_setting_set --app=$app --key=first_group --value=$first_group
|
|
|
|
ynh_app_setting_set --app=$app --key=random_string --value=$random_string
|
|
|
|
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
|
|
|
|
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
|
|
|
|
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
|
|
|
|
|
2023-08-06 18:49:51 +02:00
|
|
|
#=================================================
|
|
|
|
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=1
|
|
|
|
|
2023-08-07 00:49:35 +02:00
|
|
|
# Download, check integrity, uncompress and patch the source
|
2023-08-06 18:49:51 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
|
|
|
2023-08-07 00:49:35 +02:00
|
|
|
# Let's copy the webapp in the public directory
|
2023-08-07 00:57:41 +02:00
|
|
|
cp -R $install_dir/app/dist/* $install_dir/public/
|
2023-08-07 00:49:35 +02:00
|
|
|
|
|
|
|
ynh_script_progression --message="Pulling in external libraries with Composer..."
|
2023-08-07 01:02:32 +02:00
|
|
|
|
2023-08-10 01:28:14 +02:00
|
|
|
ynh_install_composer -c "2.4.2" -w $install_dir/api/
|
2023-08-07 00:49:35 +02:00
|
|
|
|
2023-08-06 18:49:51 +02:00
|
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SYSTEM CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
|
|
|
|
2023-08-08 21:45:35 +02:00
|
|
|
# Create a dedicated PHP-FPM config using conf/extra_php-fpm.conf
|
2023-08-06 18:49:51 +02:00
|
|
|
ynh_add_fpm_config
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config using the conf/nginx.conf template
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
# Create a dedicated Fail2Ban config
|
2023-08-08 21:45:35 +02:00
|
|
|
# We'll see that in later versions
|
|
|
|
# ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
|
2023-08-06 18:49:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# APP INITIAL CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
# ADD A CONFIGURATION
|
|
|
|
#=================================================
|
2023-08-07 00:49:35 +02:00
|
|
|
# ynh_script_progression --message="Adding a configuration file..." --weight=1
|
2023-08-06 18:49:51 +02:00
|
|
|
|
2023-08-10 01:28:14 +02:00
|
|
|
# We'll take care of language later
|
|
|
|
# ynh_add_config --template="../conf/sample.env" --destination="$install_dir/api/.env"
|
2023-08-06 18:49:51 +02:00
|
|
|
|
2023-08-08 21:45:35 +02:00
|
|
|
chmod 600 "$install_dir/api/.env"
|
|
|
|
chown $app:www-data "$install_dir/api/.env"
|
2023-08-06 18:49:51 +02:00
|
|
|
|
2023-08-08 21:45:35 +02:00
|
|
|
#=================================================
|
2023-08-07 00:49:35 +02:00
|
|
|
# DATABASE
|
2023-08-08 21:45:35 +02:00
|
|
|
#=================================================
|
2023-08-06 18:49:51 +02:00
|
|
|
|
2023-08-07 00:49:35 +02:00
|
|
|
ynh_script_progression --message="Initialiazing the database..." --weight=1
|
2023-08-10 01:28:14 +02:00
|
|
|
/usr/bin/php$phpversion $install_dir/api/bin/console zusam:init $email "$first_group" $first_user_pass
|
2023-08-06 18:49:51 +02:00
|
|
|
|
2023-08-07 00:49:35 +02:00
|
|
|
chown -R $app:www-data $install_dir
|
2023-08-06 18:49:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
|
2023-08-07 00:49:35 +02:00
|
|
|
ynh_add_config --template="../conf/cronjob" --destination="/etc/cron.d/$app"
|
|
|
|
chown root: "/etc/cron.d/$app"
|
|
|
|
chmod 644 "/etc/cron.d/$app"
|
2023-08-06 18:49:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|