From 44b85645d349934310f9d9156e6471059caca585 Mon Sep 17 00:00:00 2001 From: daniel fusser Date: Mon, 10 Apr 2023 01:26:30 +0200 Subject: [PATCH] add dns, get version scripts --- add_api_user.sh | 0 add_dns.sh | 30 ++++++++++++++++++++++++++++++ get_fw.sh | 21 +++++++++++++++++++++ 3 files changed, 51 insertions(+) mode change 100644 => 100755 add_api_user.sh create mode 100755 add_dns.sh create mode 100755 get_fw.sh diff --git a/add_api_user.sh b/add_api_user.sh old mode 100644 new mode 100755 diff --git a/add_dns.sh b/add_dns.sh new file mode 100755 index 0000000..a41bc5e --- /dev/null +++ b/add_dns.sh @@ -0,0 +1,30 @@ +#!/bin/sh +set -e +ssh_user="admin" + +ssh_host="${ssh_user}@192.168.2.1" +ssh_opts="-p 11422" + +dns_domain=dafu.dev +dns_hostname=${1} +dns_ip=${2:-192.168.2.20} + +. util.sh # import ssh function after options are set + + +fg_add_dns_script=" +execute batch start +config system dns-database + edit \"${dns_domain}\" + config dns-entry + edit 0 + set hostname \"${dns_hostname}\" + set ip \"${dns_ip}\" + end + end +execute batch end +execute batch lastlog +" + +run_ssh_script "${fg_add_dns_script}" + diff --git a/get_fw.sh b/get_fw.sh new file mode 100755 index 0000000..b8a0710 --- /dev/null +++ b/get_fw.sh @@ -0,0 +1,21 @@ +#!/bin/sh +set -e + +# FG_HOST=192.168.2.1 FG_PORT=11422 ./get_fw.sh + +ssh_user="${FG_USER:-admin}" +ssh_host="${ssh_user}@${FG_HOST:-}" +ssh_port=${FG_PORT:-22} +ssh_opts="-q -p ${ssh_port}" + +. util.sh # import ssh function after options are set + +fg_updatekey_script=" +get system status +" + +ver=$(run_ssh_script "${fg_updatekey_script}" | \ + grep "Version" | \ + grep -o -P "(?<=Version: ).*(?=,build.*)" 2>/dev/null) + +echo "Version is $ver"