openfortivpn: fix shellcheck warnings
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
This commit is contained in:
parent
7d170b8f64
commit
c4686691aa
2 changed files with 12 additions and 13 deletions
|
@ -23,19 +23,19 @@ trap_with_arg() {
|
||||||
func_trap() {
|
func_trap() {
|
||||||
logger "openfortivpn-wrapper[$$]" "$config: sending signal ${1}"
|
logger "openfortivpn-wrapper[$$]" "$config: sending signal ${1}"
|
||||||
killed=1
|
killed=1
|
||||||
kill -${1} $child 2>/dev/null
|
kill "-${1}" "$child" 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
trap_with_arg func_trap INT TERM KILL
|
trap_with_arg func_trap INT TERM KILL
|
||||||
|
|
||||||
|
|
||||||
start_time=$(date '+%s')
|
start_time=$(date '+%s')
|
||||||
/usr/sbin/openfortivpn "$@" < $pwfile 2>/dev/null &
|
/usr/sbin/openfortivpn "$@" < "$pwfile" 2>/dev/null &
|
||||||
child=$!
|
child=$!
|
||||||
wait $child || {
|
wait $child || {
|
||||||
[ "$killed" = 1 ] && exit 0
|
[ "$killed" = 1 ] && exit 0
|
||||||
current_time=$(date '+%s')
|
current_time=$(date '+%s')
|
||||||
elapsed=$(($current_time-$start_time))
|
elapsed=$((current_time-start_time))
|
||||||
. /lib/netifd/netifd-proto.sh
|
. /lib/netifd/netifd-proto.sh
|
||||||
proto_notify_error "$config" "Failed to connect after $elapsed seconds."
|
proto_notify_error "$config" "Failed to connect after $elapsed seconds."
|
||||||
proto_block_restart "$config"
|
proto_block_restart "$config"
|
||||||
|
|
|
@ -30,7 +30,7 @@ proto_openfortivpn_setup() {
|
||||||
|
|
||||||
local msg ifname ip server_ips pwfile callfile
|
local msg ifname ip server_ips pwfile callfile
|
||||||
|
|
||||||
local host peeraddr port tunlink local_ip username password trusted_cert \
|
local peeraddr port tunlink local_ip username password trusted_cert \
|
||||||
remote_status_check
|
remote_status_check
|
||||||
json_get_vars host peeraddr port tunlink local_ip username password trusted_cert \
|
json_get_vars host peeraddr port tunlink local_ip username password trusted_cert \
|
||||||
remote_status_check
|
remote_status_check
|
||||||
|
@ -41,7 +41,7 @@ proto_openfortivpn_setup() {
|
||||||
[ -n "$tunlink" ] && {
|
[ -n "$tunlink" ] && {
|
||||||
network_get_device iface_device_name "$tunlink"
|
network_get_device iface_device_name "$tunlink"
|
||||||
network_is_up "$tunlink" || {
|
network_is_up "$tunlink" || {
|
||||||
msg="$tunlink is not up $iface_device_up"
|
msg="$tunlink is not up $iface_device_name"
|
||||||
logger -t "openfortivpn" "$config: $msg"
|
logger -t "openfortivpn" "$config: $msg"
|
||||||
proto_notify_error "$config" "$msg"
|
proto_notify_error "$config" "$msg"
|
||||||
proto_block_restart "$config"
|
proto_block_restart "$config"
|
||||||
|
@ -52,8 +52,7 @@ proto_openfortivpn_setup() {
|
||||||
if echo "$peeraddr" | grep -q -E "$IPv4_REGEX"; then
|
if echo "$peeraddr" | grep -q -E "$IPv4_REGEX"; then
|
||||||
server_ips="$peeraddr"
|
server_ips="$peeraddr"
|
||||||
elif command -v resolveip >/dev/null ; then
|
elif command -v resolveip >/dev/null ; then
|
||||||
server_ips="$(resolveip -4 -t 10 "$peeraddr")"
|
server_ips="$(resolveip -4 -t 10 "$peeraddr")" || {
|
||||||
[ $? -eq 0 ] || {
|
|
||||||
msg="$config: failed to resolve server ip for $peeraddr"
|
msg="$config: failed to resolve server ip for $peeraddr"
|
||||||
logger -t "openfortivpn" "$msg"
|
logger -t "openfortivpn" "$msg"
|
||||||
sleep 10
|
sleep 10
|
||||||
|
@ -67,7 +66,7 @@ proto_openfortivpn_setup() {
|
||||||
|
|
||||||
|
|
||||||
[ "$remote_status_check" = "curl" ] && {
|
[ "$remote_status_check" = "curl" ] && {
|
||||||
curl -k --head -s --connect-timeout 10 ${tunlink:+--interface} $iface_device_name https://$peeraddr > /dev/null || {
|
curl -k --head -s --connect-timeout 10 ${tunlink:+--interface} "$iface_device_name" "https://$peeraddr" > /dev/null || {
|
||||||
msg="failed to reach https://$peeraddr${tunlink:+ on $iface_device_name}"
|
msg="failed to reach https://$peeraddr${tunlink:+ on $iface_device_name}"
|
||||||
logger -t "openfortivpn" "$config: $msg"
|
logger -t "openfortivpn" "$config: $msg"
|
||||||
sleep 10
|
sleep 10
|
||||||
|
@ -77,7 +76,7 @@ proto_openfortivpn_setup() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[ "$remote_status_check" = "ping" ] && {
|
[ "$remote_status_check" = "ping" ] && {
|
||||||
ping ${tunlink:+-I} $iface_device_name -c 1 -w 10 $peeraddr > /dev/null 2>&1 || {
|
ping ${tunlink:+-I} "$iface_device_name" -c 1 -w 10 "$peeraddr" > /dev/null 2>&1 || {
|
||||||
msg="$config: failed to ping $peeraddr on $iface_device_name"
|
msg="$config: failed to ping $peeraddr on $iface_device_name"
|
||||||
logger -t "openfortvpn" "$config: $msg"
|
logger -t "openfortvpn" "$config: $msg"
|
||||||
sleep 10
|
sleep 10
|
||||||
|
@ -96,7 +95,7 @@ proto_openfortivpn_setup() {
|
||||||
|
|
||||||
# uclient-fetch cannot bind to interface, so perform check after adding host dependency
|
# uclient-fetch cannot bind to interface, so perform check after adding host dependency
|
||||||
[ "$remote_status_check" = "fetch" ] && {
|
[ "$remote_status_check" = "fetch" ] && {
|
||||||
uclient-fetch --no-check-certificate -q -s --timeout=10 https://$peeraddr > /dev/null 2>&1 || {
|
uclient-fetch --no-check-certificate -q -s --timeout=10 "https://$peeraddr" > /dev/null 2>&1 || {
|
||||||
msg="$config: failed to reach ${server_ip:-$peeraddr} on $iface_device_name"
|
msg="$config: failed to reach ${server_ip:-$peeraddr} on $iface_device_name"
|
||||||
logger -t "openfortvpn" "$config: $msg"
|
logger -t "openfortvpn" "$config: $msg"
|
||||||
sleep 10
|
sleep 10
|
||||||
|
@ -147,7 +146,7 @@ ipparam $config
|
||||||
lcp-max-configure 40
|
lcp-max-configure 40
|
||||||
ip-up-script /lib/netifd/openfortivpn-ppp-up
|
ip-up-script /lib/netifd/openfortivpn-ppp-up
|
||||||
ip-down-script /lib/netifd/ppp-down
|
ip-down-script /lib/netifd/ppp-down
|
||||||
mru 1354" > $callfile
|
mru 1354" > "$callfile"
|
||||||
append_args "--pppd-call=openfortivpn/$config"
|
append_args "--pppd-call=openfortivpn/$config"
|
||||||
|
|
||||||
logger -p 6 -t openfortivpn "$config: executing 'openfortivpn $cmdline'"
|
logger -p 6 -t openfortivpn "$config: executing 'openfortivpn $cmdline'"
|
||||||
|
@ -161,8 +160,8 @@ proto_openfortivpn_teardown() {
|
||||||
pwfile="/var/etc/openfortivpn/$config.passwd"
|
pwfile="/var/etc/openfortivpn/$config.passwd"
|
||||||
callfile="/var/etc/openfortivpn/peers/$config"
|
callfile="/var/etc/openfortivpn/peers/$config"
|
||||||
|
|
||||||
rm -f $pwfile
|
rm -f "$pwfile"
|
||||||
rm -f $callfile
|
rm -f "$callfile"
|
||||||
proto_kill_command "$config" 2
|
proto_kill_command "$config" 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue