Hi!
Im trying to run a script which basically resets a site-to-site vpn connection, from a Nagios event handler, and also locally on the vyos in the form of a task scheduler.
Version is 1.4-rolling-202106131819.
Every time I pass an argument to the script, regardless of whatever it is, the script sees it as ‘1’. (I am echoing the argument)
Any ideas why this is happening?
What I’ve tried (remotely):
Last login: Sun Jul 11 01:29:18 UTC 2021 on pts/5
-bash-4.2$ ssh -i /var/spool/nagios/.ssh/sina_id_rsa vyos@10.20.0.254 'sg vyattacfg /config/scripts/restart-ipsec-services a'
Welcome to VyOS
argument is 1
ssh -i /var/spool/nagios/.ssh/sina_id_rsa vyos@10.20.0.254 'exec sg vyattacfg "/config/scripts/restart-ipsec-services a"'
Welcome to VyOS
argument is 1
ssh -i /var/spool/nagios/.ssh/sina_id_rsa vyos@10.10.0.254 "vbash -ic 'sg vyattacfg -c "/config/scripts/restart-ipsec-services mtn"'"
Welcome to VyOS
vbash: cannot set terminal process group (-1): Inappropriate ioctl for device
vbash: no job control in this shell
argument is 1
Locally:
root@edge01:/home/vyos# sg vyattacfg -c "/config/scripts/restart-ipsec-services a"
argument is 1
Script is basically:
#!/bin/vbash
source /opt/vyatta/etc/functions/script-template
......
main(){
if [ "$(id -g -n)" != 'vyattacfg' ] ; then
exec sg vyattacfg -c "/bin/vbash $(readlink -f $0) $@"
fi
echo "argument is $@"
TUNNEL="$@"
local result=$(vpn-reset "$TUNNEL")
echo "$result"
send_mail "$result" | nc 10.10.0.9 25 > /dev/null 2>&1
}
main "$@"