aboutsummaryrefslogtreecommitdiff
path: root/systemctl-shim
diff options
context:
space:
mode:
Diffstat (limited to 'systemctl-shim')
-rwxr-xr-xsystemctl-shim142
1 files changed, 142 insertions, 0 deletions
diff --git a/systemctl-shim b/systemctl-shim
new file mode 100755
index 0000000..1cb8c9b
--- /dev/null
+++ b/systemctl-shim
@@ -0,0 +1,142 @@
+#!/bin/bash
+# systemctl shim for Windscribe on OpenRC systems
+# Intercepts systemctl calls made by Windscribe binaries
+
+# Parse flags
+USER_FLAG=""
+QUIET_FLAG=""
+while [[ "$1" == --* ]]; do
+ case "$1" in
+ --quiet) QUIET_FLAG=1 ;;
+ --user) USER_FLAG=1 ;;
+ esac
+ shift
+done
+
+cmd="$1"
+shift || true
+
+# Helper to suppress output if --quiet
+output() {
+ if [ -z "$QUIET_FLAG" ]; then
+ echo "$@"
+ fi
+}
+
+case "$cmd" in
+ start)
+ case "$1" in
+ windscribe-helper)
+ exec rc-service windscribe-helper start
+ ;;
+ windscribe)
+ # CLI-only user service maps to system helper
+ exec rc-service windscribe-helper start
+ ;;
+ systemd-resolved)
+ exit 1
+ ;;
+ NetworkManager)
+ exec rc-service NetworkManager start
+ ;;
+ *)
+ output "systemctl shim: unknown service $1"
+ exit 1
+ ;;
+ esac
+ ;;
+ stop)
+ case "$1" in
+ windscribe-helper|windscribe)
+ exec rc-service windscribe-helper stop
+ ;;
+ NetworkManager)
+ exec rc-service NetworkManager stop
+ ;;
+ *)
+ exit 0
+ ;;
+ esac
+ ;;
+ restart)
+ case "$1" in
+ windscribe-helper)
+ exec rc-service windscribe-helper restart
+ ;;
+ NetworkManager)
+ exec rc-service NetworkManager restart
+ ;;
+ *)
+ exit 0
+ ;;
+ esac
+ ;;
+ enable)
+ case "$1" in
+ windscribe-helper|windscribe)
+ exec rc-update add windscribe-helper default
+ ;;
+ NetworkManager)
+ exec rc-update add NetworkManager default
+ ;;
+ systemd-resolved)
+ exit 1
+ ;;
+ *)
+ exit 0
+ ;;
+ esac
+ ;;
+ disable)
+ case "$1" in
+ windscribe-helper|windscribe)
+ exec rc-update del windscribe-helper default
+ ;;
+ *)
+ exit 0
+ ;;
+ esac
+ ;;
+ daemon-reload)
+ exit 0
+ ;;
+ is-active)
+ if [ "$1" = "--quiet" ]; then
+ shift
+ fi
+ case "$1" in
+ systemd-resolved)
+ exit 1
+ ;;
+ windscribe-helper|windscribe)
+ rc-service windscribe-helper status >/dev/null 2>&1
+ exit $?
+ ;;
+ NetworkManager)
+ rc-service NetworkManager status >/dev/null 2>&1
+ exit $?
+ ;;
+ *)
+ exit 1
+ ;;
+ esac
+ ;;
+ status)
+ case "$1" in
+ windscribe-helper|windscribe)
+ exec rc-service windscribe-helper status
+ ;;
+ NetworkManager)
+ exec rc-service NetworkManager status
+ ;;
+ *)
+ exit 1
+ ;;
+ esac
+ ;;
+ *)
+ # Warn to stderr but return 0 so future Windscribe versions don't crash on new commands
+ echo "systemctl shim: unsupported command $cmd $*" >&2
+ exit 0
+ ;;
+esac