aboutsummaryrefslogtreecommitdiff
path: root/scripts/install
diff options
context:
space:
mode:
authoryalh76 <yalh@yahoo.com>2022-01-07 01:25:26 +0100
committeryalh76 <yalh@yahoo.com>2022-01-07 01:25:26 +0100
commita40b4e0e0b05ff40ab10f749435e880322ea9ba6 (patch)
tree19ecc95d4b3b68a0d74f3f1591a248b8de6ded47 /scripts/install
parent1476f17251ea0b339390cfa5210e258342ea5a4a (diff)
downloadmastodon_ynh-a40b4e0e0b05ff40ab10f749435e880322ea9ba6.tar.gz
mastodon_ynh-a40b4e0e0b05ff40ab10f749435e880322ea9ba6.tar.bz2
mastodon_ynh-a40b4e0e0b05ff40ab10f749435e880322ea9ba6.zip
Full upgrade
Diffstat (limited to 'scripts/install')
-rw-r--r--scripts/install25
1 files changed, 13 insertions, 12 deletions
diff --git a/scripts/install b/scripts/install
index e6960d1..3100891 100644
--- a/scripts/install
+++ b/scripts/install
@@ -86,7 +86,7 @@ ynh_install_ruby --ruby_version=$RUBY_VERSION
ynh_script_progression --message="Configuring system user..."
# Create a system user
-ynh_system_user_create --username=$app --home_dir="$final_path"
+ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# CREATE A POSTGRESQL DATABASE
@@ -99,6 +99,7 @@ db_name=$(ynh_sanitize_dbid --db_name="${app}_production")
db_user=$(ynh_sanitize_dbid --db_name=$app)
db_pwd=$(ynh_string_random --length=30)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
+ynh_app_setting_set --app=$app --key=db_user --value=$db_user
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_execute_as_root --sql="ALTER USER $db_user CREATEDB;"
@@ -122,7 +123,7 @@ chown -R $app:www-data "$final_path"
ynh_script_progression --message="Configuring NGINX web server..."
# Create a dedicated NGINX config
-ynh_add_nginx_config 'port_web port_stream'
+ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
@@ -156,7 +157,7 @@ popd
#=================================================
# ADD A CONFIGURATION
#=================================================
-ynh_script_progression --message="Adding a config file..."
+ynh_script_progression --message="Adding a configuration file..."
config="$final_path/live/.env.production"
@@ -203,17 +204,17 @@ ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming
ynh_script_progression --message="Installing Mastodon..."
pushd "$final_path/live"
- sudo -u $app $ynh_ruby_load_path bin/bundle config deployment 'true'
- sudo -u $app $ynh_ruby_load_path bin/bundle config without 'development test'
- sudo -u $app $ynh_ruby_load_path bin/bundle install -j$(getconf _NPROCESSORS_ONLN)
+ ynh_exec_as $app $ynh_ruby_load_path bin/bundle config deployment 'true'
+ ynh_exec_as $app $ynh_ruby_load_path bin/bundle config without 'development test'
+ ynh_exec_as $app $ynh_ruby_load_path bin/bundle install -j$(getconf _NPROCESSORS_ONLN)
ynh_use_nodejs
- ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH yarn install --pure-lockfile
+ ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn install --pure-lockfile
echo "SAFETY_ASSURED=1">> $config
- ynh_exec_warn_less sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:setup --quiet
- ynh_exec_warn_less sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:precompile --quiet
- ynh_exec_warn_less sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt
- ynh_exec_warn_less sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > /dev/null
- ynh_exec_warn_less sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl accounts modify "$admin" --approve
+ ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:setup --quiet
+ ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:precompile --quiet
+ ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt
+ ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > /dev/null
+ ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl accounts modify "$admin" --approve
popd
vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" "$final_path/live/key.txt")