aboutsummaryrefslogtreecommitdiffstats
path: root/modules/scripts/warp-start.sh
diff options
context:
space:
mode:
Diffstat (limited to 'modules/scripts/warp-start.sh')
-rw-r--r--modules/scripts/warp-start.sh94
1 files changed, 47 insertions, 47 deletions
diff --git a/modules/scripts/warp-start.sh b/modules/scripts/warp-start.sh
index a1f3c76..bafbe84 100644
--- a/modules/scripts/warp-start.sh
+++ b/modules/scripts/warp-start.sh
@@ -4,68 +4,68 @@ LOGFILE="/var/log/warp-svc.log"
DAEMON_TIMEOUT=30 # seconds
start_daemon() {
- if ! pgrep -x warp-svc >/dev/null 2>&1; then
- echo "Starting warp-svc daemon..."
- sudo nohup warp-svc >>"$LOGFILE" 2>&1 &
- else
- echo "warp-svc already running."
- fi
+ if ! pgrep -x warp-svc >/dev/null 2>&1; then
+ echo "Starting warp-svc daemon..."
+ sudo nohup warp-svc >>"$LOGFILE" 2>&1 &
+ else
+ echo "warp-svc already running."
+ fi
}
wait_for_daemon() {
- echo "Waiting for warp-svc to become ready..."
- for ((i=1; i<=DAEMON_TIMEOUT; i++)); do
- if warp-cli status >/dev/null 2>&1; then
- echo "warp-svc is ready."
- return 0
- fi
- sleep 1
- done
-
- echo "ERROR: warp-svc did not become ready within ${DAEMON_TIMEOUT}s" >&2
- exit 1
+ echo "Waiting for warp-svc to become ready..."
+ for ((i=1; i<=DAEMON_TIMEOUT; i++)); do
+ if warp-cli status >/dev/null 2>&1; then
+ echo "warp-svc is ready."
+ return 0
+ fi
+ sleep 1
+ done
+
+ echo "ERROR: warp-svc did not become ready within ${DAEMON_TIMEOUT}s" >&2
+ exit 1
}
is_registered() {
- if warp-cli status 2>&1 | grep -qi "Registration missing"; then
- return 1
- fi
- return 0
+ if warp-cli status 2>&1 | grep -qi "Registration missing"; then
+ return 1
+ fi
+ return 0
}
register_client() {
- echo "Registering client..."
- sudo warp-cli registration new
+ echo "Registering client..."
+ sudo warp-cli registration new
}
connect_client() {
- echo "Connecting to WARP..."
- sudo warp-cli connect
+ echo "Connecting to WARP..."
+ sudo warp-cli connect
}
main() {
- [[ "${EUID:-$(id -u)}" -eq 0 ]] || {
- if [[ -t 2 ]]; then
- echo -e "\e[31mERROR:\e[0m Must be run as root" >&2
- else
- echo "ERROR: Must be run as root" >&2
- fi
- exit 1
- }
-
- start_daemon
- wait_for_daemon
-
- if ! is_registered; then
- register_client
- else
- echo "Client already registered."
- fi
-
- connect_client
-
- echo "Current status:"
- warp-cli status
+ [[ "${EUID:-$(id -u)}" -eq 0 ]] || {
+ if [[ -t 2 ]]; then
+ echo -e "\e[31mERROR:\e[0m Must be run as root" >&2
+ else
+ echo "ERROR: Must be run as root" >&2
+ fi
+ exit 1
+ }
+
+ start_daemon
+ wait_for_daemon
+
+ if ! is_registered; then
+ register_client
+ else
+ echo "Client already registered."
+ fi
+
+ connect_client
+
+ echo "Current status:"
+ warp-cli status
}
main