Skip to content

Instantly share code, notes, and snippets.

@ebisawa
Last active December 10, 2015 21:08
Show Gist options
  • Save ebisawa/4492584 to your computer and use it in GitHub Desktop.
Save ebisawa/4492584 to your computer and use it in GitHub Desktop.
#!/bin/bash
modconf() {
conf=$1; before=$2; after=$3
mode=`stat -c "%a" $conf`
tmpfile=`mktemp /tmp/__modconf.XXXXXX`
cat $conf | sudo sed -r "s/$before/$after/" >$tmpfile
mv $tmpfile $conf
chmod $mode $conf
rm -f $tmpfile
}
auto_apt_get() {
DEBIAN_FRONTEND=noninteractive apt-get -y --force-yes $*
}
auto_apt_get install ntp
modconf /etc/ntp.conf "server 0.ubuntu.pool.ntp.org" "server ntp.nict.jp"
modconf /etc/ntp.conf "server 1.ubuntu.pool.ntp.org" "server ntp1.jst.mfeed.ad.jp"
modconf /etc/ntp.conf "server 2.ubuntu.pool.ntp.org" "server ntp2.jst.mfeed.ad.jp"
modconf /etc/ntp.conf "server 3.ubuntu.pool.ntp.org" "server ntp3.jst.mfeed.ad.jp"
service ntp restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment