Created
July 7, 2016 00:45
-
-
Save pi-aej/c37530485dd150e1d7c2ea64318595a4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
#First, prompt user to set the timezone | |
sudo dpkg-reconfigure tzdata | |
#Restart NTP service, force time update | |
sudo service ntp stop | |
export NTPDATE_USE_NTP_CONF | |
sudo ntpdate-debian -t 10 | |
sudo service ntp start | |
#Check with user if time was correct | |
LOCAL=`date` | |
UTC=`date -u` | |
echo "" | |
echo "Local time is now: $LOCAL" | |
echo "Universal time is now: $UTC" | |
echo "" | |
echo "If the time above is not correct, your network administrator or ISP may be blocking NTP packets." | |
echo "Do you want to adjust the time manually? [y/N]" | |
CHOICE="N" | |
read CHOICE | |
C=`echo ${CHOICE,,}` | |
if [ $C == "n" ] || [ $C == "no" ]; then | |
exit 0 | |
else | |
RESULT=1 | |
while [ $RESULT -ne 0 ]; do | |
echo "Please enter the correct local date and time as 'YYYY-MM-DD hh:mm:ss'" | |
read INPUT | |
date --set "$INPUT" | |
RESULT=$? | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment