Last active
October 27, 2015 02:13
-
-
Save mu-777/10b0773bafc9d20b9e2e to your computer and use it in GitHub Desktop.
ROS同期関連の便利コマンドmemo
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 | |
function usage() { | |
cat <<_EOT_ | |
Usage: | |
$ ./chrony_setup [-0|-h] ntpserver_machine_ip | |
Description: | |
他マシンと時間同期するようのbash | |
Options: | |
-0 通常の状態に戻る | |
-h ヘルプ | |
Arguments: | |
ntpserver_machine_ip NTPサーバのIP | |
_EOT_ | |
exit 1 | |
} | |
function comfirm() { | |
echo "" | |
echo "To comfirm synchronization: $ ntpdate -q $1" | |
echo "To comfirm chrony settings: $ chronyc tracking" | |
echo "" | |
} | |
if [ ! -e /etc/chrony/chrony.conf.default ]; then | |
sudo cp /etc/chrony/chrony.conf /etc/chrony/chrony.conf.default | |
fi | |
case "$1" in | |
"-0") | |
sudo rm /etc/chrony/chrony.conf | |
sudo cp /etc/chrony/chrony.conf.default /etc/chrony/chrony.conf | |
sudo /etc/init.d/chrony restart | |
comfirm $1 | |
;; | |
"-h") | |
usage | |
;; | |
* ) | |
if [ "$#" = "1" ]; then | |
sudo rm /etc/chrony/chrony.conf | |
sudo cp /etc/chrony/chrony.conf.default /etc/chrony/chrony.conf | |
sudo echo "server $1 minpoll 0 maxpoll 5 maxdelay .05" >> /etc/chrony/chrony.conf | |
sudo /etc/init.d/chrony restart | |
comfirm $1 | |
else | |
echo "Try to enter the -h option." | |
fi | |
;; | |
esac | |
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
# http://wiki.ros.org/ROS/NetworkSetup#Timing_issues.2C_TF_complaining_about_extrapolation_into_the_future.3F | |
# 同期確認 | |
ntpdate -q other_machine_ip | |
# chrony編集 | |
sudo echo "server other_machine_ip minpoll 0 maxpoll 5 maxdelay .05" >> /etc/chrony/chrony.conf | |
# chronyスタート | |
sudo /etc/init.d/chrony stop | |
sudo ntpdate other_computer_ip | |
sudo /etc/init.d/chrony start | |
# chrony確認 | |
chronyc tracking | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment