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 }