From 34fc15bf3a33f92c19836126077f2d237cfeaf7d Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Thu, 1 Jun 2023 10:30:28 +0200 Subject: [PATCH] wip --- scripts/install | 70 +++++++++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/scripts/install b/scripts/install index 6b8a4fb..e521697 100644 --- a/scripts/install +++ b/scripts/install @@ -50,7 +50,43 @@ pushd "$install_dir/live" ynh_gem install bundler --no-document popd -# Installing Glitch-Soc +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." --weight=1 + +config="$install_dir/live/.env.production" + +language="$(echo $language | head -c 2)" + +redis_namespace=${app}_production +ynh_app_setting_set --app="$app" --key=redis_namespace --value="$redis_namespace" + +secret_key_base=$(ynh_string_random --length=128) +ynh_app_setting_set --app="$app" --key=secret_key_base --value="$secret_key_base" + +otp_secret=$(ynh_string_random --length=128) +ynh_app_setting_set --app="$app" --key=otp_secret --value="$otp_secret" + +# We need rake to build vapid keys, we generate them later once the app is installed +vapid_private_key="" +vapid_public_key="" + +ynh_add_config --template="../conf/.env.production.sample" --destination="$config" + +# Disable registration and invites +ynh_replace_string --match_string="registrations_mode: 'open'" --replace_string="registrations_mode: 'none'" --target_file="$install_dir/live/config/settings.yml" +ynh_replace_string --match_string="min_invite_role: 'admin'" --replace_string="min_invite_role: 'none'" --target_file="$install_dir/live/config/settings.yml" + +ynh_store_file_checksum --file="$install_dir/live/config/settings.yml" + +chmod 400 "$install_dir/live/config/settings.yml" +chown $app:$app "$install_dir/live/config/settings.yml" + +#================================================= +# INSTALLING GLITCH-SOC +#================================================= + ynh_script_progression --message="Installing Glitch-Soc..." --weight=5 pushd "$install_dir/live" @@ -62,6 +98,8 @@ pushd "$install_dir/live" echo "SAFETY_ASSURED=1">> $config ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails db:migrate --quiet ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails assets:precompile --quiet + # Generate vapid keys + ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt popd #================================================= @@ -86,27 +124,10 @@ ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" #================================================= # APP INITIAL CONFIGURATION #================================================= -# ADD A CONFIGURATION +# UPDATE A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression --message="Updating configuration file..." --weight=1 -config="$install_dir/live/.env.production" - -language="$(echo $language | head -c 2)" - -redis_namespace=${app}_production -ynh_app_setting_set --app="$app" --key=redis_namespace --value="$redis_namespace" - -secret_key_base=$(ynh_string_random --length=128) -ynh_app_setting_set --app="$app" --key=secret_key_base --value="$secret_key_base" - -otp_secret=$(ynh_string_random --length=128) -ynh_app_setting_set --app="$app" --key=otp_secret --value="$otp_secret" - -# Generate vapid keys -pushd "$install_dir/live" - ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt -popd vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" "$install_dir/live/key.txt") ynh_app_setting_set --app="$app" --key=vapid_private_key --value="$vapid_private_key" vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K.+" "$install_dir/live/key.txt") @@ -118,15 +139,6 @@ ynh_add_config --template="../conf/.env.production.sample" --destination="$confi chmod 400 "$config" chown $app:$app "$config" -# Disable registration and invites -ynh_replace_string --match_string="registrations_mode: 'open'" --replace_string="registrations_mode: 'none'" --target_file="$install_dir/live/config/settings.yml" -ynh_replace_string --match_string="min_invite_role: 'admin'" --replace_string="min_invite_role: 'none'" --target_file="$install_dir/live/config/settings.yml" - -ynh_store_file_checksum --file="$install_dir/live/config/settings.yml" - -chmod 400 "$install_dir/live/config/settings.yml" -chown $app:$app "$install_dir/live/config/settings.yml" - #================================================= # SETUP ADMIN USER #=================================================