Skip to content

Commit

Permalink
feat: ujust command to toggle Tailscale (#1477)
Browse files Browse the repository at this point in the history
Co-authored-by: Raindrac <raindrac@proton.me>
  • Loading branch information
Raindrac and Raindrac authored Jul 8, 2024
1 parent 94a38ed commit 9f914cf
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions just/bluefin-system.just
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,50 @@ update-ng:
sudo bootc upgrade
flatpak update -y
brew upgrade

# Toggle tailscale
toggle-tailscale:
#!/bin/bash
set -euo pipefail
source /usr/lib/ujust/ujust.sh

TAILSCALED_STATUS="$(systemctl is-enabled tailscaled || true )"

if [ "$TAILSCALED_STATUS" == "enabled" ] || [ "$TAILSCALED_STATUS" == "disabled" ]; then
TAILSCALED="Installed"
else
TAILSCALED="Not Found"
echo "${b}${red}Unable to enable or disable Tailscale.${n}"
echo "The tailscaled service must be present and either enabled or disabled to run this script."
echo "tailscaled service status: $TAILSCALED_STATUS"
fi

TAILSCALE_QS="$(gnome-extensions list | grep -q "tailscale@joaophi.github.com"; echo $?)"
if [ "$TAILSCALE_QS" == 0 ]; then
TAILSCALE_QS="Installed"
else
echo "The Tailscale QS extension for Gnome is not installed. Please install it and then run this script again."
fi

if [ "$TAILSCALE_QS" == "Installed" ] && [ "$TAILSCALED" == "Installed" ]; then
echo "Enable or disable Tailscale?"
TS_OPTION=$(ugum choose Enable Disable)

if [ "$TS_OPTION" = "Enable" ]; then
systemctl enable --now tailscaled
TAILSCALED_STATUS="$(systemctl is-enabled tailscaled || true )"
if [ "$TAILSCALED_STATUS" == "enabled" ]; then
gnome-extensions enable tailscale@joaophi.github.com
echo "${b}${green}Tailscale is enabled.${n}"
echo "If this is your first time using Tailscale, setup is necessary."
echo "Refer to Tailscale's documentation at https://tailscale.com/kb/1346/start."
fi
elif [ "$TS_OPTION" = "Disable" ]; then
systemctl disable --now tailscaled
TAILSCALED_STATUS="$(systemctl is-enabled tailscaled || true )"
if [ "$TAILSCALED_STATUS" == "disabled" ]; then
gnome-extensions disable tailscale@joaophi.github.com
echo "${b}${red}Tailscale is disabled.${n}"
fi
fi
fi

0 comments on commit 9f914cf

Please sign in to comment.