diff options
| author | ishaan <> | 2026-07-01 10:11:39 +0530 |
|---|---|---|
| committer | ishaan <> | 2026-07-01 10:11:39 +0530 |
| commit | 254d1d61386ce516bf02589bc96a64d9ed2bdf78 (patch) | |
| tree | 9665ec242043da4ddb175f27d9755ae56fa58428 /windscribe-openrc.install | |
init
Diffstat (limited to 'windscribe-openrc.install')
| -rw-r--r-- | windscribe-openrc.install | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/windscribe-openrc.install b/windscribe-openrc.install new file mode 100644 index 0000000..37ade14 --- /dev/null +++ b/windscribe-openrc.install @@ -0,0 +1,77 @@ +pre_install() { + # Stop any running instance before upgrade/reinstall + rc-service windscribe-helper stop >/dev/null 2>&1 || true + + # If migrating from a systemd-based install, disable the old systemd unit + if command -v systemctl >/dev/null 2>&1; then + systemctl stop windscribe-helper >/dev/null 2>&1 || true + systemctl disable windscribe-helper >/dev/null 2>&1 || true + fi +} + +post_install() { + # Ensure windscribe user/group exist + getent group windscribe >/dev/null 2>&1 || groupadd windscribe + id -u windscribe >/dev/null 2>&1 || useradd -r -g windscribe -s /bin/false windscribe + + # Add helper to default runlevel and start it + rc-update add windscribe-helper default >/dev/null 2>&1 || true + rc-service windscribe-helper start >/dev/null 2>&1 || true + + # Symlink CLI binary into PATH + ln -sf /opt/windscribe/windscribe-cli /usr/bin/windscribe-cli + + # Desktop database + update-desktop-database || true + + # Set setgid on Windscribe GUI binary so it can talk to helper + chgrp windscribe /opt/windscribe/Windscribe && chmod 2755 /opt/windscribe/Windscribe + + # Platform marker + mkdir -p /etc/windscribe + echo linux_zst_x64 > /etc/windscribe/platform + + # Add shim to PATH only if no real systemctl exists (don't shadow systemd) + if ! command -v systemctl >/dev/null 2>&1 && [ ! -e /usr/local/bin/systemctl ]; then + ln -sf /opt/windscribe/systemctl /usr/local/bin/systemctl + fi +} + +pre_upgrade() { + rc-service windscribe-helper stop >/dev/null 2>&1 || true + rc-update del windscribe-helper default >/dev/null 2>&1 || true +} + +post_upgrade() { + post_install + rm -rf /etc/windscribe/stunnel.conf /etc/windscribe/config.ovpn /etc/windscribe/windscribe_servers +} + +pre_remove() { + # Kill GUI + killall -q Windscribe || true + + # Stop and remove helper from runlevel + rc-service windscribe-helper stop >/dev/null 2>&1 || true + rc-update del windscribe-helper default >/dev/null 2>&1 || true + + # Reset MAC addresses + if [ -x /opt/windscribe/helper ]; then + /opt/windscribe/helper --reset-mac-addresses >/dev/null 2>&1 || true + fi + + # Remove user/group + userdel -f windscribe >/dev/null 2>&1 || true + groupdel -f windscribe >/dev/null 2>&1 || true + + # Cleanup + rm -rf /etc/windscribe + rm -rf /var/log/windscribe + rm -rf /var/lib/windscribe + rm -f /usr/bin/windscribe-cli + + # Remove shim symlink if it points to our shim + if [ -L /usr/local/bin/systemctl ] && [ "$(readlink /usr/local/bin/systemctl)" = "/opt/windscribe/systemctl" ]; then + rm -f /usr/local/bin/systemctl + fi +} |