From 353ab3b0c3f8a6c48f242a4c9cdcebed70f9a022 Mon Sep 17 00:00:00 2001 From: Dmytro Aleksandrov Date: Wed, 15 Aug 2018 16:13:57 +0300 Subject: T689: Added ntp and date op mode definition --- .gitignore | 3 ++ Makefile | 1 + debian/control | 1 + op-mode-definitions/date.xml | 64 ++++++++++++++++++++++++++++++++++++++ op-mode-definitions/show-date.xml | 30 ------------------ op-mode-definitions/show-ntp.xml | 22 +++++++++++++ src/completion/list_ntp_servers.sh | 4 +++ 7 files changed, 95 insertions(+), 30 deletions(-) create mode 100644 op-mode-definitions/date.xml delete mode 100644 op-mode-definitions/show-date.xml create mode 100644 op-mode-definitions/show-ntp.xml create mode 100755 src/completion/list_ntp_servers.sh diff --git a/.gitignore b/.gitignore index 5d0af4bae..af15969c8 100644 --- a/.gitignore +++ b/.gitignore @@ -21,12 +21,15 @@ parts/ sdist/ var/ wheels/ +Pipfile +Pipfile.lock *.egg-info/ .installed.cfg *.egg .idea/ .idea .idea/* +*.iml # PyInstaller # Usually these files are written by a python script from a template diff --git a/Makefile b/Makefile index 9e7a67fbf..823637e84 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,7 @@ op_mode_definitions: find $(CURDIR)/op-mode-definitions/ -type f -name "*.xml" | xargs -I {} $(CURDIR)/scripts/build-command-op-templates {} $(CURDIR)/schema/op-mode-definition.rng $(OP_TMPL_DIR) || exit 1 # XXX: delete top level op mode node.def's that now live in other packages + rm -f $(OP_TMPL_DIR)/set/node.def rm -f $(OP_TMPL_DIR)/show/node.def rm -f $(OP_TMPL_DIR)/show/dns/node.def rm -f $(OP_TMPL_DIR)/reset/node.def diff --git a/debian/control b/debian/control index ce9d925d3..70bf7a61c 100644 --- a/debian/control +++ b/debian/control @@ -32,6 +32,7 @@ Depends: python3, snmp, snmpd, openssh-server, ntp, + ntpdate, iputils-arping, libvyosconfig0, beep, diff --git a/op-mode-definitions/date.xml b/op-mode-definitions/date.xml new file mode 100644 index 000000000..15a69dbd9 --- /dev/null +++ b/op-mode-definitions/date.xml @@ -0,0 +1,64 @@ + + + + + + + Show system time and date + + /bin/date + + + + Show system date and time as Coordinated Universal Time + + /bin/date -u + + + + Show UTC date in Maya calendar format + + ${vyos_op_scripts_dir}/maya_date.py $(date +%s) + + + + + + + + + + + + Set system date and time + + <MMDDhhmm> <MMDDhhmmYY> <MMDDhhmmCCYY> <MMDDhhmmCCYY.ss> + + + /bin/date "$3" + + + + Set system date and time + + + + + Set system date and time from NTP server (default: 0.pool.ntp.org) + + /usr/sbin/ntpdate -u 0.pool.ntp.org + + + + Set system date and time from NTP server + + + + + /usr/sbin/ntpdate -u "$4" + + + + + + diff --git a/op-mode-definitions/show-date.xml b/op-mode-definitions/show-date.xml deleted file mode 100644 index 705172b39..000000000 --- a/op-mode-definitions/show-date.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - Show system time and date - - /bin/date - - - - Show system date and time as Coordinated Universal Time - - /bin/date -u - - - - Show UTC date in Maya calendar format - - ${vyos_op_scripts_dir}/maya_date.py $(date +%s) - - - - - - - - - diff --git a/op-mode-definitions/show-ntp.xml b/op-mode-definitions/show-ntp.xml new file mode 100644 index 000000000..4f2f2192b --- /dev/null +++ b/op-mode-definitions/show-ntp.xml @@ -0,0 +1,22 @@ + + + + + + + Show peer status of NTP daemon + + if ps -C ntpd &>/dev/null; then ntpdc -n -c peers; else echo NTP daemon disabled; fi + + + + Show date and time of specified NTP server + + + + + /usr/sbin/ntpdate -q "$3" + + + + diff --git a/src/completion/list_ntp_servers.sh b/src/completion/list_ntp_servers.sh new file mode 100755 index 000000000..d0977fbd6 --- /dev/null +++ b/src/completion/list_ntp_servers.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# Completion script used to select specific NTP server +/bin/cli-shell-api -- listEffectiveNodes system ntp server | sed "s/'//g" -- cgit v1.2.3