aboutsummaryrefslogtreecommitdiff
path: root/nitro@/setup
blob: d906bcbb4184da9ffd57cbe7efb5015a21173fdc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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