diff options
| author | Arpit Chakladar <arpitchakladar@proton.me> | 2026-03-12 18:48:40 +0530 |
|---|---|---|
| committer | Arpit Chakladar <arpitchakladar@proton.me> | 2026-03-12 18:48:40 +0530 |
| commit | 51d537e03ad877566f00af3c6a1c00340512ac65 (patch) | |
| tree | 7f8e1c6fccc68ba2ad7c3a2a02fb6efbc36d37d3 /modules/scripts/warp-start.sh | |
| parent | d6ccf7e455bd6947664d4a44dfe578813fa2b4eb (diff) | |
| download | home-manager-config-51d537e03ad877566f00af3c6a1c00340512ac65.tar.gz home-manager-config-51d537e03ad877566f00af3c6a1c00340512ac65.zip | |
Using spaces instead of tabs
Diffstat (limited to 'modules/scripts/warp-start.sh')
| -rw-r--r-- | modules/scripts/warp-start.sh | 94 |
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 |
