aboutsummaryrefslogtreecommitdiff
path: root/nitro@/setup
diff options
context:
space:
mode:
Diffstat (limited to 'nitro@/setup')
-rwxr-xr-xnitro@/setup28
1 files changed, 28 insertions, 0 deletions
diff --git a/nitro@/setup b/nitro@/setup
new file mode 100755
index 0000000..d906bcb
--- /dev/null
+++ b/nitro@/setup
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+# when you enable nitro@username, "$1" to setup (and run) is "username"
+# fail if "username" doesn't exist on this system (as per the passwd database)
+# this isn't a definitive failure (the user may be created later)
+getent passwd "$1" >/dev/null || exit 1
+
+USER="$1"
+. ./common
+
+# make sure the user has the config directory
+# by default this is ~/.config/nitro
+# if it doesn't exist, there's not much of a point to starting
+# this isn't a definitive failure (the user might create it later)
+[ -d "$CONFDIR" ] || exit 2
+
+# the socket needs to go somewhere
+# by default, it goes into /run/user/$UID/nitro/nitro.sock
+# /run/user/$UID may not exist, so we create it if it doesn't
+if [ ! -d "$SOCKDIR" ]; then
+ mkdir -p -m 0700 "$SOCKDIR"
+ chown $UID:$GID "$SOCKDIR"
+fi
+
+# if creating it failed (e.g. /run is a read-only filesystem), fail
+# this is also not a definitive failure:
+# /run might be in the process of remounting
+[ -d "$SOCKDIR" ] || exit 3