aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authoryalh76 <yalh@yahoo.com>2019-07-10 01:07:32 +0200
committeryalh76 <yalh@yahoo.com>2019-07-10 01:07:32 +0200
commitfeab0450d821b21cdc8a8fc0ee9ae9b1e9913d33 (patch)
tree16ce9dbb3cb6116b2904daf4abda8addcab3ba56 /scripts
parente0d8fa20c3694523b15e5602001a2727314698d9 (diff)
downloadmastodon_ynh-feab0450d821b21cdc8a8fc0ee9ae9b1e9913d33.tar.gz
mastodon_ynh-feab0450d821b21cdc8a8fc0ee9ae9b1e9913d33.tar.bz2
mastodon_ynh-feab0450d821b21cdc8a8fc0ee9ae9b1e9913d33.zip
Implement LDAP
Diffstat (limited to 'scripts')
-rw-r--r--scripts/install15
-rw-r--r--scripts/remove8
-rw-r--r--scripts/restore9
-rw-r--r--scripts/upgrade16
4 files changed, 48 insertions, 0 deletions
diff --git a/scripts/install b/scripts/install
index 0991cbc..97bbc0b 100644
--- a/scripts/install
+++ b/scripts/install
@@ -36,6 +36,9 @@ admin_mail=$(ynh_user_get_info $admin 'mail')
app=$YNH_APP_INSTANCE_NAME
+ldap_user="svc_${app}_ldap"
+ldap_password=$(ynh_string_random --length=8)
+
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
@@ -68,6 +71,8 @@ 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
+ynh_app_setting_set --app=$app --key=ldap_user --value=$ldap_user
+ynh_app_setting_set --app=$app --key=ldap_password --value=$ldap_password
#=================================================
# STANDARD MODIFICATIONS
@@ -135,6 +140,13 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# SPECIFIC SETUP
#=================================================
+# CREATING LDAP USER
+#=================================================
+ynh_script_progression --message="Creating LDAP user..." --weight=424
+
+yunohost user create $ldap_user --firstname "SvcMastodonLdap" --lastname "SvcMastodonLdap" --mail ${ldap_user}@$domain --password $ldap_password -q 0
+
+#=================================================
# INSTALLING RUBY AND BUNDLER
#=================================================
ynh_script_progression --message="Installing Ruby..." --weight=424
@@ -170,6 +182,9 @@ otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c
ynh_replace_string --match_string="__OTP_SECRET__" --replace_string="$otp_secret" --target_file="$final_path/live/.env.production"
ynh_app_setting_set --app="$app" --key=otp_secret --value="$otp_secret"
+ynh_replace_string --match_string="__LDAP_USER__" --replace_string="$ldap_user" --target_file="$final_path/live/.env.production"
+ynh_replace_string --match_string="__LDAP_PASSWORD__" --replace_string="$ldap_password" --target_file="$final_path/live/.env.production"
+
#=================================================
# INSTALLING MASTODON
#=================================================
diff --git a/scripts/remove b/scripts/remove
index 19cbf29..cbbae0b 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -22,6 +22,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$app
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+ldap_user=$(ynh_app_setting_get --app=$app --key=ldap_user)
#=================================================
# STANDARD REMOVE
@@ -96,6 +97,13 @@ ynh_remove_nginx_config
#=================================================
# SPECIFIC REMOVE
#=================================================
+# REMOVE LDAP USER
+#=================================================
+ynh_script_progression --message="Removing ldap user..." --weight=2
+
+yunohost user delete $ldap_user --purge
+
+#=================================================
# REMOVE THE CRON FILE
#=================================================
diff --git a/scripts/restore b/scripts/restore
index 59e71fc..89e2430 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -35,6 +35,8 @@ 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_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
+ldap_user=$(ynh_app_setting_get --app=$app --key=ldap_user)
+ldap_password=$(ynh_app_setting_get --app=$app --key=ldap_password)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
@@ -90,6 +92,13 @@ ynh_install_app_dependencies $pkg_dependencies
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#=================================================
+# CREATING LDAP USER
+#=================================================
+ynh_script_progression --message="Creating LDAP user..." --weight=424
+
+yunohost user create $ldap_user --firstname "SvcMastodonLdap" --lastname "SvcMastodonLdap" --mail ${ldap_user}@$domain --password $ldap_password -q 0
+
+#=================================================
# INSTALLING RUBY AND BUNDLER
#=================================================
ynh_script_progression --message="Installing Ruby..." --weight=393
diff --git a/scripts/upgrade b/scripts/upgrade
index 46e7229..fe6f331 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -37,6 +37,9 @@ 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)
+ldap_user=$(ynh_app_setting_get --app=$app --key=ldap_user)
+ldap_password=$(ynh_app_setting_get --app=$app --key=ldap_password)
+
#=================================================
# CHECK VERSION
#=================================================
@@ -122,6 +125,16 @@ if [[ -z "$vapid_private_key" ]]; then
ynh_app_setting_set "$app" vapid_public_key "$vapid_public_key"
fi
+# If ldap_user doesn't exist, retrieve it or create it
+if [[ -z "$ldap_user" ]]; then
+ ldap_user="svc_${app}_ldap"
+ ldap_password==$(ynh_string_random --length=8)
+ ynh_app_setting_set "$app" ldap_user "$ldap_user"
+ ynh_app_setting_set "$app" ldap_password "$ldap_password"
+
+ yunohost user create $ldap_user --firstname "SvcMastodonLdap" --lastname "SvcMastodonLdap" --mail ${ldap_user}@$domain --password $ldap_password -q 0
+fi
+
#Remove previous added repository
ynh_remove_extra_repo
@@ -239,6 +252,9 @@ ynh_replace_string --match_string="__OTP_SECRET__" --replace_string="$otp_secret
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"
+ynh_replace_string --match_string="__LDAP_USER__" --replace_string="$ldap_user" --target_file="$final_path/live/.env.production"
+ynh_replace_string --match_string="__LDAP_PASSWORD__" --replace_string="$ldap_password" --target_file="$final_path/live/.env.production"
+
#=================================================
# UPGRADE MASTODON
#=================================================