#!/bin/bash #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers ### 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, ### or 'example__2', '__3'... for multi-instance installs) #================================================= # INITIALIZE AND STORE SETTINGS #================================================= # wbk fixme - check whether one of these work #ynh_composer_version = "2.2.0" #ynh_app_setting_set --key=YNH_COMPOSER_VERSION --value=$(composer --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression "Setting up source files..." ynh_setup_source --dest_dir="$install_dir" chown -R "$app:www-data" "$install_dir" #================================================= # APP INITIAL CONFIGURATION #================================================= ynh_script_progression "Adding $app's configuration files..." ### You can add specific configuration files. ### ### Typically, put your template conf file in ../conf/your_config_file ### The template may contain strings such as __FOO__ or __FOO_BAR__, ### which will automatically be replaced by the values of $foo and $foo_bar ### Check the documentation of `ynh_config_add` for more info. ynh_config_add --template=.env --destination="$install_dir/.env" chmod 600 "$install_dir/.env" chown "$app:$app" "$install_dir/.env" #================================================= # SYSTEM CONFIGURATION #================================================= ynh_script_progression "Adding system configurations related to $app..." ### `ynh_config_add_phpfpm` is used to set up a PHP config. ### You can remove it if your app doesn't use PHP. ### `ynh_config_add_phpfpm` will use the files conf/extra_php-fpm.conf ### If you're not using these lines: ### - 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 # Create a PHP-FPM config (with conf/extra_php-fpm.conf being appended to it) #ynh_config_add_phpfpm # Create a dedicated NGINX config using the conf/nginx.conf template ynh_config_add_nginx # systemd : not applicable, runs via php-fpm and nginx # Create a dedicated Fail2Ban config #ynh_config_add_fail2ban --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" #================================================= # INSTALL APP WITH COMPOSER #================================================= ynh_script_progression "Installing app with Composer..." # ynh_composer_update bestaat niet, proberen met enkel install.. #ynh_composer_update #echo "ynh_composer_version="$ynh_composer_version #wbk fixme manual installation needed an update before executing install #ynh_composer_exec update 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 "php$php_version" artisan make:database $app "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 chgrp "$app" -R "$install_dir/storage" "$install_dir/public" chmod -R 2775 "$install_dir/storage" "$install_dir/app" "$install_dir/public" "$install_dir/bootstrap/" #================================================= # SETUP APPLICATION WITH CURL #================================================= ### 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. # Installation with curl ynh_script_progression "Finalizing installation..." #ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression "Starting $app's systemd service..." ### `ynh_systemctl` is used to start a systemd service for an app. ### Only needed if you have configure a systemd service ### If you're not using these lines: ### - 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 # Start a systemd service ynh_systemctl --service="nginx" --action="reload" ynh_systemctl --service="php__PHP_VERSION__-fpm" --action="reload" #================================================= # END OF SCRIPT #================================================= ynh_script_progression "Installation of $app completed"