-
Notifications
You must be signed in to change notification settings - Fork 0
/
mul_entrypoint.sh
68 lines (54 loc) · 1.6 KB
/
mul_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
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
set -e
CHRONY_CONF_FILE="/etc/chrony/chrony.conf"
# setup ros2 environment
echo "-> Setting up ROS"
source "/opt/ros/$ROS_DISTRO/setup.bash"
echo "-> Setting up Chrony "
# confirm correct permissions on chrony run directory
if [ -d /run/chrony ]; then
sudo chown -R ros:ros /run/chrony
sudo chmod o-rx /run/chrony
# remove previous pid file if it exist
rm -f /var/run/chrony/chronyd.pid
fi
# confirm correct permissions on chrony variable state directory
if [ -d /var/lib/chrony ]; then
sudo chown -R ros:ros /var/lib/chrony
fi
## dynamically populate chrony config file.
{
sudo echo "# https://github.com/simonrupf/docker-chrony"
sudo echo
sudo echo "# chrony.conf file generated by startup script"
sudo echo "# located at $0"
sudo echo
sudo echo "# time servers provided by NTP_SERVER environment variables."
} > ${CHRONY_CONF_FILE}
# PTP0 configuration: if it has been passed through, it means we want to use it
if [ -e /dev/ptp0 ]; then
sudo echo "refclock PHC /dev/ptp0 poll 3 dpoll -2 stratum 2" >> ${CHRONY_CONF_FILE}
fi
# final bits for the config file
{
echo
echo "driftfile /var/lib/chrony/chrony.drift"
echo "makestep 0.1 3"
if [ -n "${NTP_DIRECTIVES}" ]; then
echo -e "${NTP_DIRECTIVES}"
fi
if [ "${NOCLIENTLOG:-false}" = true ]; then
echo "noclientlog"
fi
echo
echo "allow all"
} >> ${CHRONY_CONF_FILE}
# enable control of system clock, disabled by default
SYSCLK="-x"
if [[ "${ENABLE_SYSCLK:-false}" = true ]]; then
SYSCLK=""
fi
## startup chronyd in the foreground
exec /usr/sbin/chronyd -u chrony -d ${SYSCLK}
echo "==> Container ready"
exec "$@"