aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authoryalh76 <yalh@yahoo.com>2021-02-17 19:22:07 +0100
committeryalh76 <yalh@yahoo.com>2021-02-17 19:22:07 +0100
commitaa8928abd9d670920a23e922ab6d188ba530ffb1 (patch)
tree6a60945f540789b6739519d704c880a321970ed5 /scripts
parent014dcf6239936a43249f3f8dd1fe8c5237f335d7 (diff)
downloadmastodon_ynh-aa8928abd9d670920a23e922ab6d188ba530ffb1.tar.gz
mastodon_ynh-aa8928abd9d670920a23e922ab6d188ba530ffb1.tar.bz2
mastodon_ynh-aa8928abd9d670920a23e922ab6d188ba530ffb1.zip
Apply last example_ynh
Diffstat (limited to 'scripts')
-rw-r--r--scripts/install12
-rw-r--r--scripts/remove8
-rw-r--r--scripts/restore7
-rw-r--r--scripts/upgrade63
4 files changed, 28 insertions, 62 deletions
diff --git a/scripts/install b/scripts/install
index a005eba..8f4ca05 100644
--- a/scripts/install
+++ b/scripts/install
@@ -54,7 +54,6 @@ ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin
-ynh_app_setting_set --app=$app --key=is_public --value=$is_public
ynh_app_setting_set --app=$app --key=language --value=$language
#=================================================
@@ -83,9 +82,9 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st
#=================================================
# CREATE A POSTGRESQL DATABASE
#=================================================
-ynh_script_progression --message="Creating a MySQL database..."
+ynh_script_progression --message="Creating a PostgreSQL database..."
-# Create postgresql database
+# Create PostgreSQL database
db_name="${app}_production"
db_user=$app
db_pwd=$(ynh_string_random --length=30)
@@ -269,13 +268,14 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s
#=================================================
# SETUP SSOWAT
#=================================================
-ynh_script_progression --message="Configuring SSOwat..."
+ynh_script_progression --message="Configuring permissions..."
# Make app public if necessary
if [ $is_public -eq 1 ]
then
- # unprotected_uris allows SSO credentials to be passed anyway.
- ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
+ # Everyone can access the app.
+ # The "main" permission is automatically created before the install script.
+ ynh_permission_update --permission="main" --add="visitors"
fi
#=================================================
diff --git a/scripts/remove b/scripts/remove
index 9fac8f2..46a78ab 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -20,7 +20,7 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-db_user=$app
+db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
@@ -32,19 +32,19 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Remove the service from the list of services known by Yunohost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status "$app-web" >/dev/null
then
- ynh_script_progression --message="Removing $app-web service..."
+ ynh_script_progression --message="Removing $app-web service integration..."
yunohost service remove "$app-web"
fi
if ynh_exec_warn_less yunohost service status "$app-sidekiq" >/dev/null
then
- ynh_script_progression --message="Removing $app-sidekiq service..."
+ ynh_script_progression --message="Removing $app-sidekiq service integration..."
yunohost service remove "$app-sidekiq"
fi
if ynh_exec_warn_less yunohost service status "$app-streaming" >/dev/null
then
- ynh_script_progression --message="Removing $app-streaming service..."
+ ynh_script_progression --message="Removing $app-streaming service integration..."
yunohost service remove "$app-streaming"
fi
diff --git a/scripts/restore b/scripts/restore
index 84610eb..aef19ad 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
-ynh_script_progression --message="Managing script failure..."
ynh_clean_setup () {
ynh_clean_check_starting
@@ -34,7 +33,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-db_user=$app
+db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
#=================================================
@@ -135,7 +134,7 @@ ynh_script_progression --message="Restoring the systemd configuration..."
ynh_restore_file --origin_path="/etc/systemd/system/$app-web.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app-sidekiq.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app-streaming.service"
-systemctl enable "$app-web" "$app-sidekiq" "$app-streaming"
+systemctl enable "$app-web" "$app-sidekiq" "$app-streaming" --quiet
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
@@ -167,7 +166,7 @@ ynh_restore_file --origin_path="/etc/cron.d/$app"
#=================================================
# RELOAD NGINX
#=================================================
-ynh_script_progression --message="Reloading nginx web server..."
+ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
diff --git a/scripts/upgrade b/scripts/upgrade
index a045f46..8ab0fb5 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -37,6 +37,8 @@ otp_secret=$(ynh_app_setting_get --app=$app --key=otp_secret)
vapid_private_key=$(ynh_app_setting_get --app=$app --key=vapid_private_key)
vapid_public_key=$(ynh_app_setting_get --app=$app --key=vapid_public_key)
+config="$final_path/live/.env.production"
+
#=================================================
# CHECK VERSION
#=================================================
@@ -49,39 +51,27 @@ upgrade_type=$(ynh_check_app_version_changed)
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
-config="$final_path/live/.env.production"
-# If db_name doesn't exist, create it
-if [ -z "$db_name" ]; then
- db_name="${app}_production"
- ynh_app_setting_set --app=$app --key=db_name --value=$db_name
-fi
+# Cleaning legacy permissions
+if ynh_legacy_permissions_exists; then
+ ynh_legacy_permissions_delete_all
-# If final_path doesn't exist, create it
-if [ -z "$final_path" ]; then
- final_path=/var/www/$app
- ynh_app_setting_set --app=$app --key=final_path --value=$final_path
+ ynh_app_setting_delete --app=$app --key=is_public
fi
-# Check if admin is not null
-if [[ "$admin" = "" || "$language" = "" ]]; then
- echo "Unable to upgrade, please contact support"
- ynh_die
-fi
-
-# If port_web doesn't exist, create it, need for old install
+# If port_web doesn't exist, create it, needed for old install
if [[ -z "$port_web" ]]; then
port_web=3000
ynh_app_setting_set --app=$app --key=port_web --value=$port_web
fi
-# If port_web doesn't exist, create it, need for old install
+# If port_web doesn't exist, create it, needed for old install
if [[ -z "$port_stream" ]]; then
port_stream=4000
ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream
fi
-# If db_pwd doesn't exist, create it, need for old install
+# If db_pwd doesn't exist, create it, needed for old install
if [[ -z "$db_pwd" ]]; then
db_pwd=$(ynh_string_random)
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
@@ -144,18 +134,6 @@ ynh_clean_setup () {
ynh_abort_if_errors
#=================================================
-# CHECK THE PATH
-#=================================================
-
-# Normalize the URL path syntax
-# N.B. : this is for app installations before YunoHost 2.7
-# where this value might be something like /foo/ or foo/
-# instead of /foo ....
-# If nobody installed your app before 2.7, then you may
-# safely remove this line
-path_url=$(ynh_normalize_url_path --path_url=$path_url)
-
-#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
@@ -201,6 +179,7 @@ fi
#=================================================
ynh_script_progression --message="Upgrading nginx web server configuration..."
+# Create a dedicated NGINX config
ynh_add_nginx_config 'port_web port_stream'
#=================================================
@@ -316,15 +295,6 @@ ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.ser
ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node"
#=================================================
-# INTEGRATE SERVICE IN YUNOHOST
-#=================================================
-ynh_script_progression --message="Integrating service in YunoHost..."
-
-yunohost service add "$app-web" --description "$app web service" --log_type "systemd"
-yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd"
-yunohost service add "$app-streaming" --description "$app streaming service" --log_type "systemd"
-
-#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
@@ -335,16 +305,13 @@ ynh_script_progression --message="Securing files and directories..."
chown -R $app: $final_path
#=================================================
-# SETUP SSOWAT
+# INTEGRATE SERVICE IN YUNOHOST
#=================================================
-ynh_script_progression --message="Upgrading SSOwat configuration..."
+ynh_script_progression --message="Integrating service in YunoHost..."
-# Make app public if necessary
-if [ $is_public -eq 1 ]
-then
- # unprotected_uris allows SSO credentials to be passed anyway
- ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
-fi
+yunohost service add "$app-web" --description "$app web service" --log_type "systemd"
+yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd"
+yunohost service add "$app-streaming" --description "$app streaming service" --log_type "systemd"
#=================================================
# START SYSTEMD SERVICE