File tree 1 file changed +13
-8
lines changed
1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -3,22 +3,27 @@ set -eu
3
3
4
4
USER=" coder"
5
5
6
- # Add a Coder user to run as in systemd.
7
- if ! id -u $USER > /dev/null 2>&1 ; then
6
+ if id -u $USER > /dev/null 2>&1 ; then
7
+ # If the coder user already exists, we don't need to add it.
8
+ exit 0
9
+ fi
10
+
11
+ if command -V useradd > /dev/null 2>&1 ; then
8
12
useradd \
9
13
--create-home \
10
14
--system \
11
15
--user-group \
12
16
--shell /bin/false \
13
17
$USER
14
18
15
- # Add the Coder user to the Docker group.
16
- # Coder is frequently used with Docker, so
17
- # this prevents failures when building.
18
- #
19
- # It's fine if this fails!
20
19
usermod \
21
20
--append \
22
21
--groups docker \
23
- $USER 2> /dev/null || true
22
+ $USER > /dev/null 2>&1 || true
23
+ elif command -V adduser > /dev/null 2>&1 ; then
24
+ # On alpine distributions useradd does not exist.
25
+ # This is a backup!
26
+ addgroup -S $USER
27
+ adduser -G coder -S coder
28
+ adduser coder docker > /dev/null 2>&1 || true
24
29
fi
You can’t perform that action at this time.
0 commit comments