Created
October 22, 2012 15:01
-
-
Save anonymous/3931905 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# SERVIDORES DE HORA | |
SRVS=(200.20.186.75 200.20.186.94 {a,b,c,d}.st1.ntp.br {a,b,c}.ntp.br gps.ntp.br); | |
# DEBUG | |
#echo ${#SRVS[@]}; | |
#echo ${SRVS[@]}; | |
#echo ${SRVS[1]}; | |
#exit 0; | |
# CONTANDO O NUMERO DE SERVIDORES DE HORA | |
NUMS=${#SRVS[@]}; | |
# DEBUG | |
#echo ${NUMS}; | |
#exit 0; | |
# RETORNANDO ALEATORIAMENTE, A POSICAO, NA ARRAY, DE UM SERVIDOR DE HORA | |
NUM=$[($RANDOM % ${NUMS} - 0)]; | |
# DEBUG | |
#echo ${NUM}; | |
#exit 0; | |
# OBTENDO O IP/NOME DO SERVIDOR SEGUNDO A SUA POSICAO NA ARRAY | |
SRV=${SRVS[${NUM}]}; | |
# DEBUG | |
#echo ${SRV}; | |
#exit 0; | |
# CORRIGINDO HORARIO DE VERAO | |
/usr/bin/wget -O /tmp/tz-brasil.zic 'http://people.debian.org/~pzn/tz-brasil/tz-brasil.zic' && \ | |
/usr/sbin/zic /tmp/tz-brasil.zic && \ | |
rm -Rfv /tmp/tz-brasil.zic; | |
# PARANDO NTP | |
if [ -x "/etc/init.d/ntp" ]; | |
then | |
/etc/init.d/ntp stop; | |
else | |
echo -e "\nVOCE NAO POSSUI O ntp INSTALDO!"; | |
echo -e "CONTUDO ELE NAO HE NECESSARIO PARA ESTE SCRIPT.\n"; | |
fi; | |
# ATUALIZANDO HORA | |
echo "ATUALIZANDO HORA ..." | |
/usr/sbin/ntpdate -t 5 ${SRV}; | |
# SINCRONIZANDO HORA DA BIOS COM A HORA DO SISTEMA OPERACIONAL | |
echo "SINCRONIZANDO HORA DA BIOS ..."; | |
/sbin/hwclock -w; | |
# REINICIANDO NTP | |
if [ -x "/etc/init.d/ntp" ]; | |
then | |
/etc/init.d/ntp start; | |
else | |
echo -e "\nCASO DESEJE INSTALAR O ntp, UTILIZE O COMANDO:"; | |
echo "apt-get install ntp"; | |
fi; | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment