Skip to content

Commit

Permalink
Add method_script.sh file
Browse files Browse the repository at this point in the history
  • Loading branch information
karencfv committed Nov 21, 2023
1 parent c4dc50c commit 7461821
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions smf/oximeter/method_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

set -x
set -o errexit
set -o pipefail

. /lib/svc/share/smf_include.sh

LISTEN_ADDR="$(svcprop -c -p config/listen_addr "${SMF_FMRI}")"
LISTEN_PORT="$(svcprop -c -p config/listen_port "${SMF_FMRI}")"
DATALINK="$(svcprop -c -p config/datalink "${SMF_FMRI}")"
GATEWAY="$(svcprop -c -p config/gateway "${SMF_FMRI}")"
ID="$(svcprop -c -p config/id "${SMF_FMRI}")"

if [[ $DATALINK == unknown ]] || [[ $GATEWAY == unknown ]]; then
printf 'ERROR: missing datalink or gateway\n' >&2
exit "$SMF_EXIT_ERR_CONFIG"
fi

# TODO remove when https://github.com/oxidecomputer/stlouis/issues/435 is addressed
ipadm delete-if "$DATALINK" || true
ipadm create-if -t "$DATALINK"

ipadm set-ifprop -t -p mtu=9000 -m ipv4 "$DATALINK"
ipadm set-ifprop -t -p mtu=9000 -m ipv6 "$DATALINK"

ipadm show-addr "$DATALINK/ll" || ipadm create-addr -t -T addrconf "$DATALINK/ll"
ipadm show-addr "$DATALINK/omicron6" || ipadm create-addr -t -T static -a "$LISTEN_ADDR" "$DATALINK/omicron6"
route get -inet6 default -inet6 "$GATEWAY" || route add -inet6 default -inet6 "$GATEWAY"

args=(
'--address' "[$LISTEN_ADDR]:$LISTEN_PORT"
'--id' "$ID"
)

exec /opt/oxide/oximeter/bin/oximeter run /var/svc/manifest/site/oximeter/config.toml "${args[@]}" &

0 comments on commit 7461821

Please sign in to comment.