| 1 | #!/bin/sh |
| 2 | # Wait until the network is connected and the time is synced |
| 3 | # before syncing with the server |
| 4 | |
| 5 | RETRY_LATER=21 |
| 6 | OK=0 |
| 7 | |
| 8 | ping 8.8.8.8 -c1 > /dev/null 2>&1 |
| 9 | if [ $? != 0 ]; then |
| 10 | exit ${RETRY_LATER} |
| 11 | fi |
| 12 | |
| 13 | TIME_SYNC_STATUS=$(timedatectl | grep NTP | awk '{print $NF}') |
| 14 | if [ "${TIME_SYNC_STATUS}" != "yes" ] && [ "${TIME_SYNC_STATUS}" != "active" ]; then |
| 15 | exit ${RETRY_LATER} |
| 16 | fi |
| 17 | |
| 18 | exit ${OK} |