blob: ad4ac6ff12e0c653451f878193c6a9c7ceca4aea (
plain)
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
|
#!/bin/bash
cleanup()
{
for file in $( ls -1rv /etc/services-enabled.d ); do
/etc/services-enabled.d/"$file" stop "$1"
done
exit
}
trap cleanup SIGTERM
# if an empty volume is mounted to /data, pre-populate it
[[ $( ls -1A /data | wc -l ) -eq 0 ]] && { echo "Initializing empty volume.."; cp -raT /data-ro /data; }
# wrapper to simulate update-rc.d
cat > /usr/local/sbin/update-rc.d <<'EOF'
#!/bin/bash
FILE=/etc/services-available.d/???"$1"
test -f $FILE || {
echo "$1 doesn't exist"
exit 0
}
[[ "$2" == "enable" ]] && {
ln -sf $FILE /etc/services-enabled.d/$( basename $FILE )
echo "enabled $1"
exit 0
}
[[ "$2" == "disable" ]] && {
rm -f /etc/services-enabled.d/$( basename $FILE )
echo "disabled $1"
exit 0
}
EOF
chmod +x /usr/local/sbin/update-rc.d
# Iterate only over 000* entries which might setup environment
for file in $( ls -1v /etc/services-enabled.d | grep 000* ); do
/etc/services-enabled.d/"$file" start "$1"
done
# Iterate over remaining entries
for file in $( ls -1v -I 000* /etc/services-enabled.d ); do
/etc/services-enabled.d/"$file" start "$1"
done
# wait for trap from 'docker stop'
echo "Init done"
while true; do sleep 0.5; done
|