Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ujust command to toggle Tailscale #1477

Merged
merged 14 commits into from
Jul 8, 2024
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
Raindrac marked this conversation as resolved.
Show resolved Hide resolved
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"
Raindrac marked this conversation as resolved.
Show resolved Hide resolved
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
Loading