From 511ce5f9fda26148723dbf2284c55409d0df41b5 Mon Sep 17 00:00:00 2001 From: daniel fusser Date: Tue, 21 Mar 2023 22:58:55 +0100 Subject: [PATCH] add api user script --- add_api_user.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 add_api_user.sh diff --git a/add_api_user.sh b/add_api_user.sh new file mode 100644 index 0000000..79ef6d1 --- /dev/null +++ b/add_api_user.sh @@ -0,0 +1,48 @@ +#!/bin/sh +set -e + +ssh_user="admin" +ssh_host="${ssh_user}@192.168.2.1" +ssh_opts="-p 11422" + +api_user="apiadmin" +api_comment="api admin" + +api_profile="api_ro" +. util.sh # import ssh function after options are set + +# set accprofile {string} Admin user access profile. size[35] - datasource(s): system.accprofile.name +# +# set schedule {string} Schedule name. size[35] +# set cors-allow-origin {string} Value for Access-Control-Allow-Origin on API responses. Avoid using '*' if possible. size[269] +# set peer-auth {enable | disable} Enable/disable peer authentication. +# set peer-group {string} Peer group name. size[35] +# config trusthost +# edit {id} +# # Trusthost. +# set id {integer} Table ID. range[0-4294967295] +# set type {ipv4-trusthost | ipv6-trusthost} Trusthost type. +# ipv4-trusthost IPv4 trusthost. +# ipv6-trusthost IPv6 trusthost. +# set ipv4-trusthost {ipv4 classnet} IPv4 trusted host address. +# set ipv6-trusthost {ipv6 prefix} IPv6 trusted host address. +# next + +fg_updatekey_script=" +execute batch start +config system accprofile + edit \"${api_profile}\" + set sysgrp read + set system-diagnostics disable + end +config system api-user + edit \"${api_user}\" + set comments \"${api_comment}\" + set accprofile ${api_profile} +end +execute api-user generate-key \"${api_user}\" +execute batch end +execute batch lastlog +" + +run_ssh_script "${fg_updatekey_script}" | grep "New API"