-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathentrypoint.sh
More file actions
40 lines (30 loc) · 927 Bytes
/
entrypoint.sh
File metadata and controls
40 lines (30 loc) · 927 Bytes
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
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env sh
test -e /etc/motioneye/motioneye.conf\
|| cp /usr/share/motioneye/extra/motioneye.conf.sample /etc/motioneye/motioneye.conf\
if [ "$TZ" ]; then
cp /usr/share/zoneinfo/${TZ} /etc/localtime
fi
# https://gist.github.com/qizhihere/c8db099c673e2f4718418ca05c9b2767
has_gid () {
cut -d: -f1,4 /etc/passwd | grep -q "^${1}:${2}" || return 1
}
# example: ensure_user btsync 1000 1000
ensure_user () {
local user=$1
local uid=$2
local gid=$3
local group_prefix=${4:-_}
{
deluser $user
delgroup $user
delgroup $group_prefix$user
} 2>/dev/null
adduser -h / -s /bin/sh -D -u $uid $user
has_gid $user $gid || {
addgroup -g $gid $group_prefix$user
sed -i 's/^\('$user'\(:[^:]\{1,\}\)\{2\}\):[0-9]\{1,\}/\1:'$gid/ /etc/passwd
}
}
ensure_user motioneye $UID $GID
ln -s /dev/stdout /var/log/motion.log
exec su motioneye -c "exec $*"