39 lines
923 B
Bash
39 lines
923 B
Bash
#!/bin/sh
|
|
|
|
# PROVIDE: clawdie_tailscale_up
|
|
# REQUIRE: LOGIN tailscaled
|
|
# KEYWORD: shutdown
|
|
|
|
. /etc/rc.subr
|
|
|
|
name="clawdie_tailscale_up"
|
|
rcvar="${name}_enable"
|
|
start_cmd="${name}_start"
|
|
stop_cmd=":"
|
|
required_files="/var/lib/clawdie-iso/tailscale-authkey"
|
|
|
|
clawdie_tailscale_up_start() {
|
|
_keyfile="/var/lib/clawdie-iso/tailscale-authkey"
|
|
|
|
[ -s "$_keyfile" ] || return 0
|
|
command -v tailscale >/dev/null 2>&1 || return 1
|
|
service tailscaled onestatus >/dev/null 2>&1 || return 1
|
|
|
|
_authkey=$(tr -d '\r\n' < "$_keyfile")
|
|
if [ -z "${_authkey:-}" ]; then
|
|
rm -f "$_keyfile"
|
|
return 0
|
|
fi
|
|
|
|
if tailscale up --auth-key="${_authkey}" --hostname=clawdie-live --ssh=false; then
|
|
rm -f "$_keyfile"
|
|
/usr/sbin/sysrc ${name}_enable=NO >/dev/null 2>&1 || true
|
|
return 0
|
|
fi
|
|
|
|
return 1
|
|
}
|
|
|
|
load_rc_config "$name"
|
|
: "${clawdie_tailscale_up_enable:=NO}"
|
|
run_rc_command "$1"
|