40scripts/add_api_user.sh

49 lines
1.5 KiB
Bash
Raw Normal View History

2023-03-21 21:58:55 +00:00
#!/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"