From 21dd08c9a43588e7b0550e55d6dd0cd6f6e6fa3d Mon Sep 17 00:00:00 2001 From: "J. Fernando Lagrange" Date: Sun, 17 Sep 2017 11:09:49 +0200 Subject: [PATCH] Add dedicated system user. This adds a dependency on YNH version to be able to use helpers. Prepare work on #2. --- manifest.json | 2 +- scripts/install | 10 ++++++++++ scripts/remove | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 63e4105..23c2744 100644 --- a/manifest.json +++ b/manifest.json @@ -13,7 +13,7 @@ "url": "https://github.com/scith" }, "requirements": { - "yunohost": ">= 2.4.0" + "yunohost": ">= 2.6.4" }, "multi_instance": true, "services": [ diff --git a/scripts/install b/scripts/install index 5c03660..9e5e116 100644 --- a/scripts/install +++ b/scripts/install @@ -9,6 +9,9 @@ app=$YNH_APP_INSTANCE_NAME domain=$YNH_APP_ARG_DOMAIN path=$YNH_APP_ARG_PATH +# Compute parameters +final_path=/home/yunohost.app/$app + # Source YunoHost helpers source /usr/share/yunohost/helpers @@ -16,6 +19,13 @@ source /usr/share/yunohost/helpers sudo yunohost app checkurl "${domain}${path}" -a "$app" \ || ynh_die "Path not available: ${domain}${path}" +# Check system user availability +if ynh_system_user_exists "$app" ; then + ynh_die "System user $app already exists !" +else + ynh_system_user_create "$app" "$final_path" +fi + # Install dependencies sudo apt-get update sudo apt-get install nodejs-legacy npm python-pip python-dev python-lxml python-imaging -y -qq diff --git a/scripts/remove b/scripts/remove index d2caf7a..92c68e4 100644 --- a/scripts/remove +++ b/scripts/remove @@ -17,3 +17,6 @@ sudo rm -f /etc/systemd/system/$app.service # Reload nginx service sudo service nginx reload + +# Remove dedicated system user +ynh_system_user_delete $app