#641 Issue closed: 43_prepare_timesync.sh: Wrong script in rescue image when using TIMESYNC=NTP.

Labels: bug, fixed / solved / done

hpannenb opened issue at 2015-08-20 08:59:

Hi.
during some of my recovery tests on a RHEL6 server I investigated the current

https://github.com/rear/rear/blob/master/usr/share/rear/rescue/default/43_prepare_timesync.sh

does not prepare the correct 90-timesync.sh script in /etc/scripts/system-setup.d/ of the rescue image when using TIMESYNC=NTP in the ReaR config file. This leads to a failure during startup but does not seem to have any further influence.

Not beeing a shell expert this is due to the cat command beeing used which already replaces the used (shell) variables in the resulting script.

I "patched" the script as follows (diff -u); the "+++" is my patched version; I still have to test if this works as supposed to:

--- ./43_prepare_timesync.sh    2015-08-20 10:27:06.759967040 +0200
+++ /usr/share/rear/rescue/default/43_prepare_timesync.sh       2015-08-20 10:21:03.376653865 +0200
@@ -8,15 +8,15 @@
                cat >$ROOTFS_DIR/etc/scripts/system-setup.d/90-timesync.sh <<-EOF
                        echo "Setting system time via NTP ..."
                        ntpd -q -g & # allow for big jumps
-                       ntpd_pid=$!
+                       ntpd_pid=\$!
                        i=0
-                       while kill -0 $ntpd_pid 2>/dev/null; do
-                               if [[ $i -ge 10 ]]; then
+                       while kill -0 \$ntpd_pid 2>/dev/null; do
+                               if [[ \$i -ge 10 ]]; then
                                        echo "Gave up on NTP after 10 seconds."
-                                       kill $ntpd_pid
+                                       kill \$ntpd_pid
                                        break
                                fi
-                               i=$(( $i + 1 ))
+                               i=\$(( \$i + 1 ))
                                sleep 1
                        done
                EOF

Regards,
Holger.

hpannenb commented at 2015-08-20 11:46:

I checked the situation. In principle the script 90-timesync.sh is working. Its output is as follows:

./90-timesync.sh 
Setting system time via NTP ...
getconfig: Couldn't open </etc/ntp/crypto/pw>
ntpd: time slew -0.011359s

The error is initiated with the command ntpd -q -g. Maybe it is worth extending the COPY_AS_IS section in the 43_prepare_timesync.sh to also copy /etc/ntp/ ?

The extended looks as follows:

COPY_AS_IS=( "${COPY_AS_IS[@]}" /etc/ntp.conf /etc/ntp/ )

gdha commented at 2015-08-28 12:51:

@hpannenb Thank you for reporting it - it has been fixed in the master tree

hpannenb commented at 2015-08-31 15:29:

Works as supposed to. Thanks. :-)


[Export of Github issue for rear/rear.]