Skip to content

Commit b0b6e19

Browse files
improved UID & GID handling
1 parent 3ee8580 commit b0b6e19

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

files/runScanner.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,24 @@ if [[ $NAME == *" "* ]]; then
66
exit -1
77
fi
88

9-
if [[ -z ${UID} ]]; then
10-
UID=1000
9+
if [[ -z {$NAME} ]]; then
10+
$NAME="Scanner"
11+
fi
12+
13+
# if running as root, create default user. If UID is set, use that
14+
if [[ ${UID} == 0 ]]; then
15+
USERID=1000
16+
else
17+
USERID=$UID
1118
fi
1219
if [[ -z ${GID} ]]; then
13-
GID=1000
20+
GROUPID=1000
21+
else
22+
GROUPID=$GID
1423
fi
15-
groupadd --gid "$GID" NAS
16-
adduser "$NAME" --uid $UID --gid "$GID" --disabled-password --force-badname --gecos ""
24+
25+
groupadd --gid "$GROUPID" NAS
26+
adduser "$NAME" --uid $USERID --gid "$GROUPID" --disabled-password --force-badname --gecos ""
1727
mkdir -p /scans
1828
chmod 777 /scans
1929
touch /var/log/scanner.log

0 commit comments

Comments
 (0)