/ de-omarchy / bin / omarchy-remove-service-sunshine
swadhinbiswas Initial de-omarchy: Omarchy UI layer for Arch-based distros · 8/22/2026
9f393b2
70 lines · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash

# omarchy:summary=Remove Sunshine and close Omarchy-managed Moonlight streaming ports.
# omarchy:requires-sudo=true

set -e

TCP_PORTS=(47984 47989 48010)
UDP_PORTS=(5353 47998 47999 48000 48002 48010)
PRIVATE_CIDRS=(10.0.0.0/8 172.16.0.0/12 192.168.0.0/16)
SUNSHINE_ADMIN_APP="Sunshine Admin"
HYPR_AUTOSTART_FILE="$HOME/.config/hypr/autostart.lua"
HYPR_AUTOSTART_ENTRY='o.launch_on_start("sunshine")'

delete_ufw_rule() {
  sudo ufw --force delete "$@" >/dev/null 2>&1 || true
}

close_ufw_port_for_private_lans() {
  local proto="$1"
  local port="$2"
  local cidr

  for cidr in "${PRIVATE_CIDRS[@]}"; do
    delete_ufw_rule allow in proto "$proto" from "$cidr" to any port "$port"
  done
}

close_ufw_port_for_tailscale() {
  local proto="$1"
  local port="$2"

  delete_ufw_rule allow in on tailscale0 to any port "$port" proto "$proto"
}

close_ufw_ports() {
  local port

  if omarchy-cmd-missing ufw; then
    return
  fi

  for port in "${TCP_PORTS[@]}"; do
    close_ufw_port_for_private_lans tcp "$port"
    close_ufw_port_for_tailscale tcp "$port"
  done

  for port in "${UDP_PORTS[@]}"; do
    close_ufw_port_for_private_lans udp "$port"
    close_ufw_port_for_tailscale udp "$port"
  done

  sudo ufw reload
}

disable_hyprland_autostart() {
  if [[ -f $HYPR_AUTOSTART_FILE ]]; then
    sed -i "\|^$HYPR_AUTOSTART_ENTRY$|d" "$HYPR_AUTOSTART_FILE"
  fi
}

systemctl --user disable --now sunshine 2>/dev/null || true
omarchy-pkg-drop sunshine
omarchy-webapp-remove "$SUNSHINE_ADMIN_APP" 2>/dev/null || true
disable_hyprland_autostart
close_ufw_ports

echo ""
echo "Sunshine has been removed and its Omarchy-managed Moonlight streaming ports have been closed."