mirror of
https://github.com/YunoHost-Apps/zusam_ynh.git
synced 2024-09-03 18:05:54 +02:00
102 lines
3.8 KiB
Bash
Executable file
102 lines
3.8 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# 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
|
|
|
|
#=================================================
|
|
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Setting up source files..." --weight=1
|
|
|
|
# Download, check integrity, uncompress and patch the source
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
|
|
# Let's copy the webapp in the public directory
|
|
cp -R $install_dir/app/dist/* $install_dir/public/
|
|
|
|
ynh_script_progression --message="Pulling in external libraries with Composer..."
|
|
|
|
ynh_install_composer -c "2.4.2" -w $install_dir/api/
|
|
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
#=================================================
|
|
# SYSTEM CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
|
|
|
# Create a dedicated PHP-FPM config using conf/extra_php-fpm.conf
|
|
ynh_add_fpm_config
|
|
|
|
# Create a dedicated NGINX config using the conf/nginx.conf template
|
|
ynh_add_nginx_config
|
|
|
|
# Create a dedicated Fail2Ban config
|
|
# 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"
|
|
|
|
#=================================================
|
|
# APP INITIAL CONFIGURATION
|
|
#=================================================
|
|
# ADD A CONFIGURATION
|
|
#=================================================
|
|
# ynh_script_progression --message="Adding a configuration file..." --weight=1
|
|
|
|
# We'll take care of language later
|
|
# ynh_add_config --template="../conf/sample.env" --destination="$install_dir/api/.env"
|
|
|
|
chmod 600 "$install_dir/api/.env"
|
|
chown $app:www-data "$install_dir/api/.env"
|
|
|
|
#=================================================
|
|
# DATABASE
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Initialiazing the database..." --weight=1
|
|
/usr/bin/php$phpversion $install_dir/api/bin/console zusam:init $email "$first_group" $first_user_pass
|
|
|
|
chown -R $app:www-data $install_dir
|
|
|
|
#=================================================
|
|
# GENERIC FINALIZATION
|
|
#=================================================
|
|
|
|
ynh_add_config --template="../conf/cronjob" --destination="/etc/cron.d/$app"
|
|
chown root: "/etc/cron.d/$app"
|
|
chmod 644 "/etc/cron.d/$app"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
ynh_script_progression --message="Installation of $app completed" --last
|