From 6b652a5e242f7dbcbcab0850f32403933e759b3d Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Sun, 29 Aug 2021 19:34:44 +0200 Subject: [PATCH] make installation work --- conf/default.env | 9 +++++---- scripts/install | 19 +++++++------------ scripts/remove | 2 +- scripts/upgrade | 32 ++++++++++++++++++++------------ 4 files changed, 33 insertions(+), 29 deletions(-) diff --git a/conf/default.env b/conf/default.env index 19aaf53..4d18148 100644 --- a/conf/default.env +++ b/conf/default.env @@ -3,7 +3,7 @@ APP_ENV=production APP_KEY=base64:3E5HVZ/T+VbZu+oA4GNlwnvwFe3jNtkGbR95K0uwr7A= APP_DEBUG=false -APP_URL=http://localhost +APP_URL=https://__DOMAIN____PATH__ DB_CONNECTION=mysql MULTI_DB_ENABLED=false @@ -19,7 +19,6 @@ DEMO_MODE=false BROADCAST_DRIVER=log LOG_CHANNEL=stack CACHE_DRIVER=file -QUEUE_CONNECTION=sync SESSION_DRIVER=file SESSION_LIFETIME=120 @@ -32,9 +31,9 @@ MAIL_HOST=smtp.__DOMAIN__ MAIL_PORT=25 MAIL_USERNAME=null MAIL_PASSWORD=null -MAIL_ENCRYPTION=null +MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS='__EMAIL__' -MAIL_FROM_NAME='__EMAIL_NAME__' +MAIL_FROM_NAME="__EMAIL_NAME__" POSTMARK_API_TOKEN= REQUIRE_HTTPS=false @@ -55,3 +54,5 @@ UPDATE_SECRET=__API_SECRET__ COMPOSER_AUTH='{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}' SENTRY_LARAVEL_DSN=https://cc7e8e2c678041689e53e409b7dba236@sentry.invoicing.co/5 + +PRECONFIGURED_INSTALL=true diff --git a/scripts/install b/scripts/install index f421336..55ee27e 100755 --- a/scripts/install +++ b/scripts/install @@ -101,10 +101,6 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" - #================================================= # NGINX CONFIGURATION #================================================= @@ -140,15 +136,14 @@ pushd "$final_path" # Run the database migrations and initially fill the db php$phpversion artisan optimize --no-interaction --verbose php$phpversion artisan migrate:fresh --seed --no-interaction --verbose --force + php$phpversion artisan ninja:create-account --email $email --password changeme --no-interaction --verbose + php$phpversion artisan view:clear + php$phpversion artisan cache:clear popd -# ynh_app_setting_set --app=$app --key=unprotected_uris --value='/' - -# first_name="$(ynh_app_setting_get --app=$app --key=mail_from_name) | cut -d ' ' -f 1" -# last_name="$(ynh_app_setting_get --app=$app --key=mail_from_name) | cut -d ' ' -f 2" -# mail_from_address="$(ynh_user_get_info $admin mail)" - -# curl --silent --show-error --insecure --location -H "Content-Type:application/json" --header "Host: $domain" --header "X-Requested-With: XMLHttpRequest" --resolve $domain:443:127.0.0.1 --data "{\"report_errors\":true,\"email\":\"$mail_from_address\",\"password\":\"insecurechangeme\",\"first_name\":\"$first_name\",\"last_name\":\"$last_name\",\"terms_of_service\":\"1\",\"privacy_policy\":\"1\"}" 'https://localhost/api/v1/signup?first_load=true' --cookie-jar /tmp/ynh--cookie.txt --cookie /tmp/ynh--cookie.txt +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # ADD A CRON JOB @@ -165,7 +160,7 @@ chmod 644 "/etc/cron.d/$app" ynh_script_progression --message="Configuring permissions..." --weight=3 # Restrict access to admin only -ynh_permission_update --permission="main" --remove="all_users" --add=$admin +ynh_permission_update --permission "main" --add visitors #================================================= # RELOAD NGINX diff --git a/scripts/remove b/scripts/remove index ad26ef1..a46c348 100755 --- a/scripts/remove +++ b/scripts/remove @@ -38,7 +38,7 @@ ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies -ynh_remove_app_dependencies +#ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR diff --git a/scripts/upgrade b/scripts/upgrade index 7a0b704..6502074 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -98,11 +98,6 @@ then ynh_setup_source --dest_dir="$final_path" fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" -chmod -R 755 $final_path/storage - #================================================= # UPGRADE DEPENDENCIES #================================================= @@ -110,6 +105,15 @@ ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies +#================================================= +# ADD A CRON JOB +#================================================= +ynh_script_progression --message="Adding a cron job..." + +ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" +chown root: "/etc/cron.d/$app" +chmod 644 "/etc/cron.d/$app" + #================================================= # NGINX CONFIGURATION #================================================= @@ -133,14 +137,15 @@ ynh_add_fpm_config --package="$extra_php_dependencies" # MODIFY A CONFIG FILE #================================================= -# if [ "$upgrade_type" == "UPGRADE_APP" ] -# then -# ynh_add_config --template="../conf/default.env" --destination="$final_path/.env" -# fi + if [ "$upgrade_type" == "UPGRADE_APP" ] + then + ynh_add_config --template="../conf/default.env" --destination="$final_path/.env" + fi #================================================= # UPGRADE DATABASE #================================================= + ynh_script_progression --message="Upgrading the database..." pushd "$final_path" @@ -148,16 +153,19 @@ pushd "$final_path" php$phpversion artisan down --no-interaction --verbose # Optimize the framework for better performance - php$phpversion artisan optimize --force --no-interaction --verbose + php$phpversion artisan optimize --no-interaction --verbose # Run the database migrations - php$phpversion artisan migrate --no-interaction --verbose - php$phpversion artisan db:seed --class=UpdateSeeder --force --no-interaction --verbose + php$phpversion artisan migrate --force --no-interaction --verbose # Bring the application out of maintenance mode php$phpversion artisan up --no-interaction --verbose popd +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # RELOAD NGINX #=================================================