diff options
| author | yalh76 <yalh@yahoo.com> | 2019-05-12 20:32:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-12 20:32:33 +0200 |
| commit | c857d70f73587852cacc608a4e140b5b6b2b9e87 (patch) | |
| tree | 0cf3ea06df3f1b5f6206d51518f805a481417117 /scripts | |
| parent | 386c48a3389d0d817b87bccf43f312f75782646a (diff) | |
| parent | 0e6fcf1700e12399fea0bf3ba0c91a71f0bec9cc (diff) | |
| download | mastodon_ynh-c857d70f73587852cacc608a4e140b5b6b2b9e87.tar.gz mastodon_ynh-c857d70f73587852cacc608a4e140b5b6b2b9e87.tar.bz2 mastodon_ynh-c857d70f73587852cacc608a4e140b5b6b2b9e87.zip | |
Merge branch 'testing' into example_ynh
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/install | 14 | ||||
| -rw-r--r-- | scripts/restore | 4 | ||||
| -rw-r--r-- | scripts/upgrade | 52 |
3 files changed, 42 insertions, 28 deletions
diff --git a/scripts/install b/scripts/install index 29058f6..ff03433 100644 --- a/scripts/install +++ b/scripts/install @@ -154,9 +154,9 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= ynh_script_progression --message="Installing Ruby..." --weight=424 -ynh_install_ruby --ruby_version=2.6.0 -/opt/rbenv/versions/2.6.0/bin/gem update --system -#/opt/rbenv/versions/2.6.0/bin/gem install bundler --no-document +ynh_install_ruby --ruby_version=2.6.1 +/opt/rbenv/versions/2.6.1/bin/gem update --system +#/opt/rbenv/versions/2.6.1/bin/gem install bundler --no-document #================================================= # MODIFY A CONFIG FILE @@ -194,12 +194,12 @@ chown -R "$app": "$final_path" pushd "$final_path/live" ynh_use_nodejs - sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test + sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.1/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test sudo -u "$app" env PATH=$PATH yarn install --pure-lockfile sudo -u "$app" echo "SAFETY_ASSURED=1">> .env.production - sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails db:migrate --quiet - sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails assets:precompile --quiet - sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt + sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.1/bin/bundle exec rails db:migrate --quiet + sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.1/bin/bundle exec rails assets:precompile --quiet + sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.1/bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > acc.txt popd diff --git a/scripts/restore b/scripts/restore index ce097c4..e85815c 100644 --- a/scripts/restore +++ b/scripts/restore @@ -108,8 +108,8 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= ynh_script_progression --message="Installing Ruby..." --weight=393 -ynh_install_ruby --ruby_version=2.6.0 -/opt/rbenv/versions/2.6.0/bin/gem update --system +ynh_install_ruby --ruby_version=2.6.1 +/opt/rbenv/versions/2.6.1/bin/gem update --system #================================================= # RESTORE THE POSTGRESQL DATABASE diff --git a/scripts/upgrade b/scripts/upgrade index cb2c66e..7562d85 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -71,7 +71,7 @@ fi # If paperclip_secret doesn't exist, retrieve it or create it if [[ -z "$paperclip_secret" ]]; then - paperclip_secret=$(grep -oP "PAPERCLIP_SECRET=\K\w+" test) + paperclip_secret=$(grep -oP "PAPERCLIP_SECRET=\K\w+" ${final_path}/live/.env.production) if [[ -z "$paperclip_secret" ]]; then paperclip_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) fi @@ -80,7 +80,7 @@ fi # If secret_key_base doesn't exist, retrieve it or create it if [[ -z "$secret_key_base" ]]; then - secret_key_base=$(grep -oP "SECRET_KEY_BASE=\K\w+" test) + secret_key_base=$(grep -oP "SECRET_KEY_BASE=\K\w+" ${final_path}/live/.env.production) if [[ -z "$secret_key_base" ]]; then secret_key_base=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) fi @@ -89,13 +89,21 @@ fi # If otp_secret doesn't exist, retrieve it or create it if [[ -z "$otp_secret" ]]; then - otp_secret=$(grep -oP "OTP_SECRET=\K\w+" test) + otp_secret=$(grep -oP "OTP_SECRET=\K\w+" ${final_path}/live/.env.production) if [[ -z "$otp_secret" ]]; then otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) fi ynh_app_setting_set --app=$app --key=otp_secret --value="$otp_secret" fi +# If vapid_private_key doesn't exist, retrieve it or create it +if [[ -z "$vapid_private_key" ]]; then + vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K\w+" ${final_path}/live/.env.production) + vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K\w+" ${final_path}/live/.env.production) + ynh_app_setting_set "$app" vapid_private_key "$vapid_private_key" + ynh_app_setting_set "$app" vapid_public_key "$vapid_public_key" +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -185,9 +193,9 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= ynh_script_progression --message="Installing Ruby..." --weight=424 -ynh_install_ruby --ruby_version=2.6.0 -/opt/rbenv/versions/2.6.0/bin/gem update --system -#/opt/rbenv/versions/2.6.0/bin/gem install bundler +ynh_install_ruby --ruby_version=2.6.1 +/opt/rbenv/versions/2.6.1/bin/gem update --system +#/opt/rbenv/versions/2.6.1/bin/gem install bundler #================================================= # MODIFY A CONFIG FILE @@ -210,6 +218,9 @@ ynh_replace_string --match_string="__SECRET_KEY_BASE__" --replace_string="$secre ynh_replace_string --match_string="__OTP_SECRET__" --replace_string="$otp_secret" --target_file="$final_path/live/.env.production" +ynh_replace_string "__VAPID_PRIVATE_KEY__" "$vapid_private_key" "$final_path/live/.env.production" +ynh_replace_string "__VAPID_PUBLIC_KEY__" "$vapid_public_key" "$final_path/live/.env.production" + #================================================= # UPGRADE MASTODON #================================================= @@ -220,25 +231,28 @@ chown -R "$app": "$final_path" pushd "$final_path/live" ynh_use_nodejs if [ "$(lsb_release --codename --short)" == "jessie" ]; then - sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/bundle install --deployment --without development test + sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.1/bin/bundle install --deployment --without development test else - sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/bundle install --deployment --force --without development test + sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.1/bin/bundle install --deployment --force --without development test fi sudo -u "$app" env PATH=$PATH yarn install --pure-lockfile - sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails assets:clean - sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails assets:precompile - sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails db:migrate + sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.1/bin/bundle exec rails assets:clean + sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.1/bin/bundle exec rails assets:precompile + sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.1/bin/bundle exec rails db:migrate + sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl cache clear popd # If vapid_private_key doesn't exist, retrieve it or create it -if [[ -z "$vapid_private_key" ]]; then - sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt - vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K\w+" "$final_path/live/key.txt") - vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K\w+" "$final_path/live/key.txt") - ynh_app_setting_set --app="$app" --key=vapid_private_key --value="$vapid_private_key" - ynh_app_setting_set --app="$app" --key=vapid_public_key --value="$vapid_public_key" - ynh_secure_remove --file="$final_path/live/key.txt" -fi +#if [[ -z "$vapid_private_key" ]]; then +# sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt +# vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K\w+" "$final_path/live/key.txt") +# vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K\w+" "$final_path/live/key.txt") +# ynh_app_setting_set "$app" vapid_private_key "$vapid_private_key" +# ynh_app_setting_set "$app" vapid_public_key "$vapid_public_key" +# ynh_secure_remove "$final_path/live/key.txt" +# ynh_replace_string "__VAPID_PRIVATE_KEY__" "$vapid_private_key" "${final_path}/live/.env.production" +# ynh_replace_string "__VAPID_PUBLIC_KEY__" "$vapid_public_key" "${final_path}/live/.env.production" +#fi # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="${final_path}/live/.env.production" |
