blob: 28b9457b3d037903cdef4752cec495763082ebce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
set -euo pipefail
# Optional: where to log the daemon
LOGFILE="/var/log/warp-svc.log"
start_daemon() {
if ! pgrep -x warp-svc >/dev/null 2>&1; then
echo "Starting warp-svc daemon..."
sudo nohup warp-svc >>"$LOGFILE" 2>&1 &
sleep 2
else
echo "warp-svc already running."
fi
}
is_registered() {
if warp-cli status 2>&1 | grep -qi "Registration missing"; then
return 1
fi
return 0
}
register_client() {
echo "Registering client..."
warp-cli registration new
}
connect_client() {
echo "Connecting to WARP..."
warp-cli connect
}
main() {
start_daemon
if ! is_registered; then
register_client
else
echo "Client already registered."
fi
connect_client
echo "Current status:"
warp-cli status
}
main "$@"
|