2014-10-20 18:55:53 +02:00
|
|
|
#!/bin/bash
|
2015-10-27 16:03:21 +01:00
|
|
|
|
2017-06-02 18:23:51 +02:00
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2017-06-05 13:11:48 +02:00
|
|
|
source _common.sh
|
2017-06-02 18:23:51 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2024-01-10 23:52:57 +01:00
|
|
|
### Install parameters are automatically saved as settings
|
|
|
|
###
|
|
|
|
### Settings are automatically loaded as bash variables
|
|
|
|
### in every app script context, therefore typically these will exist:
|
|
|
|
### - $domain
|
|
|
|
### - $path
|
|
|
|
### - $language
|
|
|
|
### ... etc
|
|
|
|
###
|
|
|
|
### Resources defined in the manifest are provisioned prior to this script
|
|
|
|
### and corresponding settings are also available, such as:
|
|
|
|
### - $install_dir
|
|
|
|
### - $port
|
|
|
|
### - $db_name
|
|
|
|
### ...
|
|
|
|
###
|
|
|
|
### $app is the app id (i.e. 'example' for first install,
|
2024-09-03 13:55:06 +02:00
|
|
|
### or 'example__2', '__3'... for multi-instance installs)
|
2021-03-17 16:32:11 +01:00
|
|
|
|
2017-06-02 18:23:51 +02:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2024-06-20 23:49:43 +02:00
|
|
|
ynh_script_progression "Setting up source files..."
|
2017-06-02 18:23:51 +02:00
|
|
|
|
2023-01-30 19:10:14 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2023-12-30 03:02:42 +01:00
|
|
|
chown -R "$app:www-data" "$install_dir"
|
2023-01-30 19:10:14 +01:00
|
|
|
|
2024-02-21 16:34:51 +01:00
|
|
|
#=================================================
|
|
|
|
# APP INITIAL CONFIGURATION
|
|
|
|
#=================================================
|
2024-06-20 23:49:43 +02:00
|
|
|
ynh_script_progression "Adding $app's configuration files..."
|
2024-02-21 16:34:51 +01:00
|
|
|
|
2025-02-26 10:24:13 +01:00
|
|
|
ynh_config_add --template=.env --destination="$install_dir/.env"
|
2024-02-21 16:34:51 +01:00
|
|
|
|
2025-03-01 17:42:29 +01:00
|
|
|
chmod 640 "$install_dir/.env"
|
2025-03-01 10:57:07 +01:00
|
|
|
chown "$app:www-data" "$install_dir/.env"
|
2024-02-21 16:34:51 +01:00
|
|
|
|
|
|
|
|
2017-06-02 18:23:51 +02:00
|
|
|
#=================================================
|
2023-01-30 19:10:14 +01:00
|
|
|
# SYSTEM CONFIGURATION
|
2017-06-02 18:23:51 +02:00
|
|
|
#=================================================
|
2024-06-20 23:49:43 +02:00
|
|
|
ynh_script_progression "Adding system configurations related to $app..."
|
2017-06-02 18:23:51 +02:00
|
|
|
|
2024-06-20 23:49:43 +02:00
|
|
|
### `ynh_config_add_phpfpm` is used to set up a PHP config.
|
2018-07-01 09:57:16 +02:00
|
|
|
### You can remove it if your app doesn't use PHP.
|
2024-06-20 23:49:43 +02:00
|
|
|
### `ynh_config_add_phpfpm` will use the files conf/extra_php-fpm.conf
|
2018-06-28 22:05:35 +02:00
|
|
|
### If you're not using these lines:
|
2024-01-10 23:34:28 +01:00
|
|
|
### - You can remove these files in conf/.
|
|
|
|
### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script
|
|
|
|
### - Remove also the section "REMOVE PHP-FPM CONFIGURATION" in the remove script
|
|
|
|
### - As well as the section "RESTORE THE PHP-FPM CONFIGURATION" in the restore script
|
|
|
|
### with the reload at the end of the script.
|
|
|
|
### - And the section "PHP-FPM CONFIGURATION" in the upgrade script
|
2018-06-28 22:05:35 +02:00
|
|
|
|
2023-07-24 16:11:17 +02:00
|
|
|
# Create a PHP-FPM config (with conf/extra_php-fpm.conf being appended to it)
|
2025-03-01 17:42:29 +01:00
|
|
|
# (added to nginx.conf)
|
2025-02-25 14:30:31 +01:00
|
|
|
#ynh_config_add_phpfpm
|
2017-06-02 18:23:51 +02:00
|
|
|
|
2023-01-30 19:10:14 +01:00
|
|
|
# Create a dedicated NGINX config using the conf/nginx.conf template
|
2025-03-01 17:42:29 +01:00
|
|
|
# (the PHP-FPM config is here as well)
|
2024-06-20 23:49:43 +02:00
|
|
|
ynh_config_add_nginx
|
2022-05-31 01:56:33 +02:00
|
|
|
|
2025-03-01 09:24:30 +01:00
|
|
|
# systemd : not applicable, runs via php-fpm and nginx
|
2021-04-29 20:58:35 +02:00
|
|
|
|
2023-01-30 19:10:14 +01:00
|
|
|
# Create a dedicated Fail2Ban config
|
2025-03-01 17:42:29 +01:00
|
|
|
# todo
|
2025-02-25 14:30:31 +01:00
|
|
|
#ynh_config_add_fail2ban --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
|
2021-04-29 20:58:35 +02:00
|
|
|
|
2025-02-26 10:24:13 +01:00
|
|
|
#=================================================
|
|
|
|
# INSTALL APP WITH COMPOSER
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression "Installing app with Composer..."
|
|
|
|
|
2025-02-26 22:32:42 +01:00
|
|
|
#wbk fixme manual installation needed an update before executing install
|
2025-02-26 10:24:13 +01:00
|
|
|
ynh_composer_install
|
|
|
|
ynh_composer_exec install --no-dev
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BUILDING
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression "configuring $app..."
|
|
|
|
|
|
|
|
|
|
|
|
pushd "$install_dir"
|
|
|
|
|
|
|
|
"php$php_version" artisan key:generate -n --force --env
|
2025-02-26 22:35:32 +01:00
|
|
|
"php$php_version" artisan make:database $app
|
2025-02-26 10:24:13 +01:00
|
|
|
"php$php_version" artisan migrate:fresh --seed -n --force
|
|
|
|
"php$php_version" artisan config:clear -n
|
|
|
|
"php$php_version" artisan config:cache -n
|
|
|
|
#"php$php_version" artisan lychee:create_user "$admin" "$password"
|
|
|
|
|
|
|
|
popd
|
|
|
|
|
|
|
|
# copy/paste from lychee install, for what it's worth...
|
|
|
|
# file was touched by artisan, rehash it
|
|
|
|
ynh_store_file_checksum "$install_dir/.env"
|
|
|
|
app_key=$(cat $install_dir/.env | grep -e ^APP_KEY | cut -c 9-)
|
|
|
|
ynh_app_setting_set --key=app_key --value=$app_key
|
|
|
|
|
2025-03-01 10:59:53 +01:00
|
|
|
# group only, make it www-data vs user/group $app:www-data
|
|
|
|
chgrp "www-data" -R "$install_dir/storage" "$install_dir/public"
|
2025-02-26 10:24:13 +01:00
|
|
|
chmod -R 2775 "$install_dir/storage" "$install_dir/app" "$install_dir/public" "$install_dir/bootstrap/"
|
|
|
|
|
2017-06-02 18:23:51 +02:00
|
|
|
#=================================================
|
2017-06-17 17:49:26 +02:00
|
|
|
# SETUP APPLICATION WITH CURL
|
2017-06-02 18:23:51 +02:00
|
|
|
#=================================================
|
|
|
|
|
2018-07-01 09:57:16 +02:00
|
|
|
### Use these lines only if the app installation needs to be finalized through
|
|
|
|
### web forms. We generally don't want to ask the final user,
|
|
|
|
### so we're going to use curl to automatically fill the fields and submit the
|
|
|
|
### forms.
|
2018-06-28 22:05:35 +02:00
|
|
|
|
2017-06-02 18:23:51 +02:00
|
|
|
# Installation with curl
|
2024-06-20 23:49:43 +02:00
|
|
|
ynh_script_progression "Finalizing installation..."
|
2025-02-25 14:30:31 +01:00
|
|
|
#ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
|
2017-06-02 18:23:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
2019-05-02 20:44:22 +02:00
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2024-06-20 23:49:43 +02:00
|
|
|
ynh_script_progression "Starting $app's systemd service..."
|
2019-05-02 20:44:22 +02:00
|
|
|
|
2024-06-20 23:49:43 +02:00
|
|
|
### `ynh_systemctl` is used to start a systemd service for an app.
|
2019-05-02 20:44:22 +02:00
|
|
|
### Only needed if you have configure a systemd service
|
|
|
|
### If you're not using these lines:
|
2024-01-10 23:34:28 +01:00
|
|
|
### - Remove the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the backup script
|
|
|
|
### - As well as the section "START SYSTEMD SERVICE" in the restore script
|
|
|
|
### - As well as the section"STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the upgrade script
|
|
|
|
### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script
|
2019-05-02 20:44:22 +02:00
|
|
|
|
|
|
|
# Start a systemd service
|
2025-03-01 09:40:53 +01:00
|
|
|
ynh_systemctl --service="nginx" --action="reload"
|
2025-03-01 09:43:16 +01:00
|
|
|
ynh_systemctl --service="php$php_version-fpm" --action="reload"
|
2019-05-02 20:44:22 +02:00
|
|
|
|
2019-02-10 15:02:38 +01:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2024-06-20 23:49:43 +02:00
|
|
|
|
|
|
|
ynh_script_progression "Installation of $app completed"
|