2020-11-15 21:54:22 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
2023-11-16 20:25:15 +01:00
|
|
|
# GENERATE KEYS AND RETRIEVE ADMIN USER INFO
|
2020-11-15 21:54:22 +01:00
|
|
|
#=================================================
|
|
|
|
|
2021-07-26 11:10:37 +02:00
|
|
|
api_secret="$(ynh_string_random --length=32)"
|
|
|
|
app_key="$(ynh_string_random --length=32)"
|
|
|
|
phantomjs_key="$(ynh_string_random --length=32)"
|
2023-11-16 20:25:15 +01:00
|
|
|
|
2023-11-16 14:33:02 +01:00
|
|
|
email_fullname="$(ynh_user_get_info --username=$admin --key=fullname)"
|
2023-06-05 11:00:33 +02:00
|
|
|
email="$(ynh_user_get_info --username=$admin --key=mail)"
|
2021-07-26 11:10:37 +02:00
|
|
|
|
2020-11-15 21:54:22 +01:00
|
|
|
#=================================================
|
2023-11-16 20:25:15 +01:00
|
|
|
# STORE KEYS TO APP SETTINGS
|
2020-11-15 21:54:22 +01:00
|
|
|
#=================================================
|
2023-11-16 20:25:15 +01:00
|
|
|
ynh_script_progression --message="Storing secrets to app settings..."
|
2020-11-15 21:54:22 +01:00
|
|
|
|
2021-07-26 11:33:12 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=api_secret --value=$api_secret
|
|
|
|
ynh_app_setting_set --app=$app --key=app_key --value=$app_key
|
|
|
|
ynh_app_setting_set --app=$app --key=phantomjs_key --value=$phantomjs_key
|
|
|
|
|
2020-11-15 21:54:22 +01:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2023-06-05 11:03:43 +02:00
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=1
|
2020-11-15 21:54:22 +01:00
|
|
|
|
2023-06-05 10:48:49 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2020-11-15 21:54:22 +01:00
|
|
|
|
2023-06-05 10:48:49 +02:00
|
|
|
chown -R $app:www-data "$install_dir"
|
2020-11-15 21:54:22 +01:00
|
|
|
|
|
|
|
#=================================================
|
2023-06-05 11:03:43 +02:00
|
|
|
# SYSTEM CONFIGURATION
|
2020-11-15 21:54:22 +01:00
|
|
|
#=================================================
|
2023-06-05 11:03:43 +02:00
|
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
2020-11-15 21:54:22 +01:00
|
|
|
|
2023-06-05 10:48:49 +02:00
|
|
|
# Create a dedicated PHP-FPM config
|
2023-11-16 16:43:53 +01:00
|
|
|
ynh_add_fpm_config
|
2023-06-05 10:48:49 +02:00
|
|
|
|
|
|
|
# Create a dedicated nginx config
|
|
|
|
ynh_add_nginx_config
|
2020-11-15 21:54:22 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
|
|
|
#=================================================
|
|
|
|
# MODIFY A CONFIG FILE
|
|
|
|
#=================================================
|
2023-06-05 11:03:43 +02:00
|
|
|
ynh_script_progression --message="Modifying a config file..." --weight=1
|
2020-11-15 21:54:22 +01:00
|
|
|
|
2023-06-05 10:48:49 +02:00
|
|
|
ynh_add_config --template="default.env" --destination="$install_dir/.env"
|
2021-10-30 20:54:48 +02:00
|
|
|
|
2024-07-10 20:54:02 +02:00
|
|
|
chmod 600 "$install_dir/.env"
|
2023-06-05 10:48:49 +02:00
|
|
|
chown $app:$app "$install_dir/.env"
|
2020-11-15 21:54:22 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BUILD THE APPLICATION
|
|
|
|
#=================================================
|
2023-06-05 11:03:43 +02:00
|
|
|
ynh_script_progression --message="Building the application..." --weight=1
|
2020-11-15 21:54:22 +01:00
|
|
|
|
2023-06-05 10:48:49 +02:00
|
|
|
pushd "$install_dir"
|
2020-11-15 21:54:22 +01:00
|
|
|
# Run the database migrations and initially fill the db
|
2020-12-21 21:30:16 +01:00
|
|
|
php$phpversion artisan migrate:fresh --seed --no-interaction --verbose --force
|
2022-08-09 19:06:16 +02:00
|
|
|
php$phpversion artisan ninja:create-account --email $email --password "$password" --no-interaction --verbose
|
2021-10-30 19:07:26 +02:00
|
|
|
php$phpversion artisan optimize --no-interaction --verbose
|
2021-08-29 19:34:44 +02:00
|
|
|
php$phpversion artisan view:clear
|
|
|
|
php$phpversion artisan cache:clear
|
2020-11-15 21:54:22 +01:00
|
|
|
popd
|
|
|
|
|
2023-06-05 10:48:49 +02:00
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2020-12-21 21:30:48 +01:00
|
|
|
|
2020-11-15 21:54:22 +01:00
|
|
|
#=================================================
|
|
|
|
# ADD A CRON JOB
|
|
|
|
#=================================================
|
2023-06-05 11:03:43 +02:00
|
|
|
ynh_script_progression --message="Adding a cron job..." --weight=1
|
2020-11-15 21:54:22 +01:00
|
|
|
|
2023-11-16 16:45:02 +01:00
|
|
|
ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
|
2021-07-26 10:17:25 +02:00
|
|
|
chown root: "/etc/cron.d/$app"
|
|
|
|
chmod 644 "/etc/cron.d/$app"
|
2020-11-15 21:54:22 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Installation of $app completed"
|