2020-11-15 21:54:22 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
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-06-05 11:00:33 +02:00
|
|
|
email_firstname="$(ynh_user_get_info --username=$admin --key=firstname)"
|
|
|
|
email_lastname="$(ynh_user_get_info --username=$admin --key=lastname)"
|
|
|
|
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
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Storing installation settings..."
|
|
|
|
|
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
|
2021-09-18 17:09:12 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=email_firstname --value="$email_firstname"
|
|
|
|
ynh_app_setting_set --app=$app --key=email_lastname --value="$email_lastname"
|
2021-07-26 11:33:12 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=email --value=$email
|
|
|
|
|
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
|
|
|
|
2023-06-05 10:48:49 +02:00
|
|
|
chmod 400 "$install_dir/.env"
|
|
|
|
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
|
2022-11-21 09:08:12 +01:00
|
|
|
|
|
|
|
# install snappdf, since it isn't included by default anymore since
|
|
|
|
# 5.5.12: https://invoiceninja.github.io/docs/self-host-troubleshooting/#pdf-conversion-issues
|
|
|
|
php$phpversion vendor/bin/snappdf download
|
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"
|