2013-12-21 10:56:45 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2014-01-13 15:02:37 +00:00
|
|
|
THISFILE=$0
|
2013-12-21 10:56:45 +00:00
|
|
|
|
|
|
|
setclock() {
|
2013-12-22 22:22:00 +00:00
|
|
|
echo "Setting clock."
|
2014-01-21 06:11:29 +00:00
|
|
|
MYTIME=$(date -r $THISFILE '+%Y-%m-%d %H:%M:%S')
|
2013-12-21 10:56:45 +00:00
|
|
|
date --set="$MYTIME" &>/dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
saveclock() {
|
2013-12-22 22:22:00 +00:00
|
|
|
echo "Saving current time."
|
2014-01-13 15:02:37 +00:00
|
|
|
touch $THISFILE &>/dev/null
|
2013-12-21 10:56:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
set)
|
|
|
|
setclock
|
|
|
|
;;
|
|
|
|
save)
|
|
|
|
saveclock
|
|
|
|
;;
|
|
|
|
*)
|
2014-01-13 15:02:37 +00:00
|
|
|
echo "Usage: $THISFILE {set|save}"
|
2013-12-21 10:56:45 +00:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|