-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathentrypoint.sh
55 lines (42 loc) · 1.42 KB
/
entrypoint.sh
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
set -e
# set umask:
umask 0002
if [ "$1" = 'runldm.sh' ]; then
USERNAME=${LDM_USERNAME:-ldm}
USER_ID=${LDM_USER_ID:-1000}
GROUP_ID=${LDM_GROUP_ID:-1000}
###
# LDM user
###
groupadd -r ${USERNAME} -g ${GROUP_ID} && \
useradd -u ${USER_ID} -g ${USERNAME} -ms /bin/bash -c "LDM user" ${USERNAME}
# All of this is to avoid chowning -R var/data which will take too long if
# there is a lot of data
for i in /. /var /var/data /var/queues /var/logs
do
j=${HOME}$i
if [ -d "$j" ]; then
chown ${USERNAME}:${USERNAME} "$j"
fi
done
# add group permissions to product queue
chmod 775 /home/ldm/var/queues
if [ -f /home/ldm/var/queues/ldm.pq ]; then
chmod 664 /home/ldm/var/queues/ldm.pq
fi
# chown everything in ${HOME} except var/data which will take too long
cd ${HOME} && chown -R ${USERNAME}:${USERNAME} $(ls -A | awk '{if($1 != "var"){ print $1 }}')
# deal with cron for user ldm
if [ -f /var/spool/cron/ldm ]; then
if ! [[ "ldm" == "${USERNAME}" ]]; then
mv /var/spool/cron/ldm /var/spool/cron/${USERNAME}
fi
chown ${USERNAME}:${USERNAME} /var/spool/cron/${USERNAME} && chmod 600 /var/spool/cron/${USERNAME}
fi
chown root ${HOME}/bin/hupsyslog ${HOME}/bin/ldmd
chmod 4755 ${HOME}/bin/hupsyslog ${HOME}/bin/ldmd
sync
exec gosu ${USERNAME} "$@"
fi
exec "$@"