aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryalh76 <yalh@yahoo.com>2021-04-10 20:28:06 +0200
committeryalh76 <yalh@yahoo.com>2021-04-10 20:28:06 +0200
commitf19e49ae9861a93b22640f11437b749a006be2cd (patch)
treed7a803a006d8caaedb381bc00f44bad8803aedef
parentd5c6970fafd35955d1f6ea695d8e195c64419620 (diff)
downloadmastodon_ynh-f19e49ae9861a93b22640f11437b749a006be2cd.tar.gz
mastodon_ynh-f19e49ae9861a93b22640f11437b749a006be2cd.tar.bz2
mastodon_ynh-f19e49ae9861a93b22640f11437b749a006be2cd.zip
Apply example_ynh
-rw-r--r--scripts/install45
-rw-r--r--scripts/restore14
-rw-r--r--scripts/upgrade27
3 files changed, 44 insertions, 42 deletions
diff --git a/scripts/install b/scripts/install
index 91133d3..cf1ccf3 100644
--- a/scripts/install
+++ b/scripts/install
@@ -154,9 +154,9 @@ pushd "$final_path/live"
popd
#=================================================
-# MODIFY A CONFIG FILE
+# ADD A CONFIGURATION
#=================================================
-ynh_script_progression --message="Modifying a config file..."
+ynh_script_progression --message="Adding a config file..."
config="$final_path/live/.env.production"
@@ -173,18 +173,32 @@ vapid_public_key=""
ynh_add_config --template="../conf/.env.production.sample" --destination="$config"
+chmod 400 "$config"
+chown $app:$app "$config"
+
ynh_replace_string --match_string="registrations_mode: 'open'" --replace_string="registrations_mode: 'none'" --target_file="$final_path/live/config/settings.yml"
ynh_replace_string --match_string="min_invite_role: 'admin'" --replace_string="min_invite_role: 'none'" --target_file="$final_path/live/config/settings.yml"
ynh_store_file_checksum --file="$final_path/live/config/settings.yml"
+chmod 400 "$final_path/live/config/settings.yml"
+chown $app:$app "$final_path/live/config/settings.yml"
+
+#=================================================
+# SETUP SYSTEMD
+#=================================================
+ynh_script_progression --message="Configuring a systemd service..."
+
+# Create a dedicated systemd config
+ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" --others_var="port_web RBENV_ROOT"
+ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" --others_var="RBENV_ROOT"
+ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node"
+
#=================================================
# INSTALLING MASTODON
#=================================================
ynh_script_progression --message="Installing Mastodon..."
-chown -R "$app": "$final_path"
-
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'
@@ -205,11 +219,14 @@ ynh_app_setting_set --app="$app" --key=vapid_private_key --value="$vapid_private
vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K.+" "$final_path/live/key.txt")
ynh_app_setting_set --app="$app" --key=vapid_public_key --value="$vapid_public_key"
+ynh_secure_remove --file="$final_path/live/key.txt"
+
ynh_delete_file_checksum --file="$config"
ynh_add_config --template="../conf/.env.production.sample" --destination="$config"
-ynh_secure_remove --file="$final_path/live/key.txt"
+chmod 400 "$config"
+chown $app:$app "$config"
#=================================================
# SETUP THE CRON FILE
@@ -219,24 +236,6 @@ ynh_script_progression --message="Setuping the cron file..."
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
#=================================================
-# SETUP SYSTEMD
-#=================================================
-ynh_script_progression --message="Configuring a systemd service..."
-
-# Create a dedicated systemd config
-ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" --others_var="port_web RBENV_ROOT"
-ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" --others_var="RBENV_ROOT"
-ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node"
-
-#=================================================
-# STORE THE CONFIG FILE CHECKSUM
-#=================================================
-ynh_script_progression --message="Storing the config file checksum..."
-
-# Calculate and store the config file checksum into the app settings
-ynh_store_file_checksum --file="$config"
-
-#=================================================
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
diff --git a/scripts/restore b/scripts/restore
index 3e50248..0b389f0 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -93,6 +93,13 @@ ynh_script_progression --message="Adding $swap_needed Mo to swap..."
ynh_add_swap --size=$swap_needed
#=================================================
+# RESTORE THE CRON FILE
+#=================================================
+ynh_script_progression --message="Restoring the cron file..."
+
+ynh_restore_file --origin_path="/etc/cron.d/$app"
+
+#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..."
@@ -152,13 +159,6 @@ ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=sys
ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=systemd --line_match="Worker 1 now listening"
#=================================================
-# RESTORE THE CRON FILE
-#=================================================
-ynh_script_progression --message="Restoring the cron file..."
-
-ynh_restore_file --origin_path="/etc/cron.d/$app"
-
-#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
diff --git a/scripts/upgrade b/scripts/upgrade
index b4c16e1..870bd4c 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -230,14 +230,27 @@ pushd "$final_path/live"
popd
#=================================================
-# MODIFY A CONFIG FILE
+# UPDATE A CONFIG FILE
#=================================================
-ynh_script_progression --message="Modifying a config file..."
+ynh_script_progression --message="Updating a config file..."
language="$(echo $language | head -c 2)"
ynh_add_config --template="../conf/.env.production.sample" --destination="$config"
+chmod 400 "$config"
+chown $app:$app "$config"
+
+#=================================================
+# SETUP SYSTEMD
+#=================================================
+ynh_script_progression --message="Upgrading systemd configuration..."
+
+# Create a dedicated systemd config
+ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" --others_var="port_web RBENV_ROOT"
+ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" --others_var="RBENV_ROOT"
+ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node"
+
#=================================================
# UPGRADE MASTODON
#=================================================
@@ -265,16 +278,6 @@ ynh_script_progression --message="Setuping the cron file..."
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
#=================================================
-# SETUP SYSTEMD
-#=================================================
-ynh_script_progression --message="Upgrading systemd configuration..."
-
-# Create a dedicated systemd config
-ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" --others_var="port_web RBENV_ROOT"
-ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" --others_var="RBENV_ROOT"
-ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node"
-
-#=================================================
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST