From 33815223ee95f00df865d93e7ff566b399b982c4 Mon Sep 17 00:00:00 2001 From: Raindrac Date: Tue, 2 Jul 2024 04:28:46 +0000 Subject: [PATCH 01/12] feat: ujust command to toggle tailscaled service --- just/bluefin-system.just | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/just/bluefin-system.just b/just/bluefin-system.just index 92cadc3ffb6..0f633542343 100644 --- a/just/bluefin-system.just +++ b/just/bluefin-system.just @@ -280,3 +280,29 @@ update-ng: sudo bootc upgrade flatpak update -y brew upgrade + +# Toggle tailscaled service +toggle-tailscaled: + #!/bin/bash + source /usr/lib/ujust/ujust.sh + + TAILSCALE_STATUS="$(systemctl is-enabled tailscaled)" + + if [ "$TAILSCALE_STATUS" == "enabled" ]; then + echo "Tailscale is enabled. Attempting to disable." + systemctl disable --now tailscaled + TAILSCALE_STATUS="$(systemctl is-enabled tailscaled)" + if [ "$TAILSCALE_STATUS" == "disabled" ]; then + echo "${b}${red}Disabled tailscaled.${n}" + fi + elif [ "$TAILSCALE_STATUS" == "disabled" ]; then + echo "Tailscale is disabled. Attempting to enable." + systemctl enable --now tailscaled + TAILSCALE_STATUS="$(systemctl is-enabled tailscaled)" + if [ "$TAILSCALE_STATUS" == "enabled" ]; then + echo "${b}${green}Enabled tailscaled.${n}" + fi + else + echo "${b}${red}Failed to enable/disable tailscaled.${n}" + echo "tailscaled service status: $TAILSCALE_STATUS" + fi \ No newline at end of file From c7798c4de9e76864cd932a4ab194e9c13463d8bc Mon Sep 17 00:00:00 2001 From: Raindrac Date: Tue, 2 Jul 2024 04:33:24 +0000 Subject: [PATCH 02/12] fix: adjusted echo output --- just/bluefin-system.just | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/just/bluefin-system.just b/just/bluefin-system.just index 0f633542343..38515d4b505 100644 --- a/just/bluefin-system.just +++ b/just/bluefin-system.just @@ -289,14 +289,14 @@ toggle-tailscaled: TAILSCALE_STATUS="$(systemctl is-enabled tailscaled)" if [ "$TAILSCALE_STATUS" == "enabled" ]; then - echo "Tailscale is enabled. Attempting to disable." + echo "The tailscaled service is enabled. Attempting to disable." systemctl disable --now tailscaled TAILSCALE_STATUS="$(systemctl is-enabled tailscaled)" if [ "$TAILSCALE_STATUS" == "disabled" ]; then echo "${b}${red}Disabled tailscaled.${n}" fi elif [ "$TAILSCALE_STATUS" == "disabled" ]; then - echo "Tailscale is disabled. Attempting to enable." + echo "The tailscaled service is disabled. Attempting to enable." systemctl enable --now tailscaled TAILSCALE_STATUS="$(systemctl is-enabled tailscaled)" if [ "$TAILSCALE_STATUS" == "enabled" ]; then From 39f91343b56940fd3390d9b1091a405a734d624c Mon Sep 17 00:00:00 2001 From: Raindrac Date: Tue, 2 Jul 2024 02:32:03 -0400 Subject: [PATCH 03/12] feat: Tailscale ujust script now toggles the extension --- just/bluefin-system.just | 56 +++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/just/bluefin-system.just b/just/bluefin-system.just index 38515d4b505..4baf8fb89dd 100644 --- a/just/bluefin-system.just +++ b/just/bluefin-system.just @@ -281,28 +281,48 @@ update-ng: flatpak update -y brew upgrade -# Toggle tailscaled service -toggle-tailscaled: +# Toggle tailscale +toggle-tailscale: #!/bin/bash source /usr/lib/ujust/ujust.sh - TAILSCALE_STATUS="$(systemctl is-enabled tailscaled)" + TAILSCALED_STATUS="$(systemctl is-enabled tailscaled)" - if [ "$TAILSCALE_STATUS" == "enabled" ]; then - echo "The tailscaled service is enabled. Attempting to disable." - systemctl disable --now tailscaled - TAILSCALE_STATUS="$(systemctl is-enabled tailscaled)" - if [ "$TAILSCALE_STATUS" == "disabled" ]; then - echo "${b}${red}Disabled tailscaled.${n}" - fi - elif [ "$TAILSCALE_STATUS" == "disabled" ]; then - echo "The tailscaled service is disabled. Attempting to enable." + if [ "$TAILSCALED_STATUS" == "enabled" ]; then + TAILSCALED="Installed" + elif [ "$TAILSCALED_STATUS" == "disabled" ]; then + TAILSCALED="Installed" + else + echo "${b}${red}Unable to enable or disable Tailscale.${n}" + echo "tailscaled service status: $TAILSCALED_STATUS" + fi + + TAILSCALE_QS="$(gnome-extensions list | grep -q "tailscale"; 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 use this command again." + fi + + if [ "$TAILSCALE_QS" == "Installed" ] && [ "$TAILSCALED" == "Installed" ]; then + echo "Enable or disable Tailscale?" + TS_OPTION=$(gum choose Enable Disable) + + if [ "$TS_OPTION" = "Enable" ]; then systemctl enable --now tailscaled - TAILSCALE_STATUS="$(systemctl is-enabled tailscaled)" - if [ "$TAILSCALE_STATUS" == "enabled" ]; then - echo "${b}${green}Enabled tailscaled.${n}" + TAILSCALED_STATUS="$(systemctl is-enabled tailscaled)" + if [ "$TAILSCALED_STATUS" == "enabled" ]; then + gnome-extensions enable tailscale@joaophi.github.com + echo "${b}${green}Enabled Tailscale.${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 - else - echo "${b}${red}Failed to enable/disable tailscaled.${n}" - echo "tailscaled service status: $TAILSCALE_STATUS" + elif [ "$TS_OPTION" = "Disable" ]; then + systemctl disable --now tailscaled + TAILSCALED_STATUS="$(systemctl is-enabled tailscaled)" + if [ "$TAILSCALED_STATUS" == "disabled" ]; then + gnome-extensions disable tailscale@joaophi.github.com + echo "${b}${red}Disabled tailscaled.${n}" + fi + fi fi \ No newline at end of file From 5245c9fa1a4794472f12250d9ff2a9a02c0f386d Mon Sep 17 00:00:00 2001 From: Raindrac Date: Tue, 2 Jul 2024 03:02:10 -0400 Subject: [PATCH 04/12] Fix: Corrected "tailscaled" to "Tailscale" --- just/bluefin-system.just | 76 ++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/just/bluefin-system.just b/just/bluefin-system.just index 4baf8fb89dd..26ed476c206 100644 --- a/just/bluefin-system.just +++ b/just/bluefin-system.just @@ -283,46 +283,46 @@ update-ng: # Toggle tailscale toggle-tailscale: - #!/bin/bash - source /usr/lib/ujust/ujust.sh +#!/bin/bash +source /usr/lib/ujust/ujust.sh - TAILSCALED_STATUS="$(systemctl is-enabled tailscaled)" +TAILSCALED_STATUS="$(systemctl is-enabled tailscaled)" - if [ "$TAILSCALED_STATUS" == "enabled" ]; then - TAILSCALED="Installed" - elif [ "$TAILSCALED_STATUS" == "disabled" ]; then - TAILSCALED="Installed" - else - echo "${b}${red}Unable to enable or disable Tailscale.${n}" - echo "tailscaled service status: $TAILSCALED_STATUS" - fi +if [ "$TAILSCALED_STATUS" == "enabled" ]; then + TAILSCALED="Installed" +elif [ "$TAILSCALED_STATUS" == "disabled" ]; then + TAILSCALED="Installed" +else + echo "${b}${red}Unable to enable or disable Tailscale.${n}" + echo "tailscaled service status: $TAILSCALED_STATUS" +fi - TAILSCALE_QS="$(gnome-extensions list | grep -q "tailscale"; 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 use this command again." - fi +TAILSCALE_QS="$(gnome-extensions list | grep -q "tailscale"; 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 use this command again." +fi - if [ "$TAILSCALE_QS" == "Installed" ] && [ "$TAILSCALED" == "Installed" ]; then - echo "Enable or disable Tailscale?" - TS_OPTION=$(gum choose Enable Disable) +if [ "$TAILSCALE_QS" == "Installed" ] && [ "$TAILSCALED" == "Installed" ]; then + echo "Enable or disable Tailscale?" + TS_OPTION=$(gum choose Enable Disable) - if [ "$TS_OPTION" = "Enable" ]; then - systemctl enable --now tailscaled - TAILSCALED_STATUS="$(systemctl is-enabled tailscaled)" - if [ "$TAILSCALED_STATUS" == "enabled" ]; then - gnome-extensions enable tailscale@joaophi.github.com - echo "${b}${green}Enabled Tailscale.${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)" - if [ "$TAILSCALED_STATUS" == "disabled" ]; then - gnome-extensions disable tailscale@joaophi.github.com - echo "${b}${red}Disabled tailscaled.${n}" - fi - fi - fi \ No newline at end of file + if [ "$TS_OPTION" = "Enable" ]; then + systemctl enable --now tailscaled + TAILSCALED_STATUS="$(systemctl is-enabled tailscaled)" + if [ "$TAILSCALED_STATUS" == "enabled" ]; then + gnome-extensions enable tailscale@joaophi.github.com + echo "${b}${green}Enabled Tailscale.${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)" + if [ "$TAILSCALED_STATUS" == "disabled" ]; then + gnome-extensions disable tailscale@joaophi.github.com + echo "${b}${red}Disabled Tailscale.${n}" + fi + fi +fi \ No newline at end of file From 08154d891132347d0b280e640305a2a098e0e4c7 Mon Sep 17 00:00:00 2001 From: Raindrac Date: Tue, 2 Jul 2024 03:26:27 -0400 Subject: [PATCH 05/12] style: Added indentation --- just/bluefin-system.just | 76 ++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/just/bluefin-system.just b/just/bluefin-system.just index 26ed476c206..03735ac3fc4 100644 --- a/just/bluefin-system.just +++ b/just/bluefin-system.just @@ -283,46 +283,46 @@ update-ng: # Toggle tailscale toggle-tailscale: -#!/bin/bash -source /usr/lib/ujust/ujust.sh - -TAILSCALED_STATUS="$(systemctl is-enabled tailscaled)" - -if [ "$TAILSCALED_STATUS" == "enabled" ]; then - TAILSCALED="Installed" -elif [ "$TAILSCALED_STATUS" == "disabled" ]; then - TAILSCALED="Installed" -else - echo "${b}${red}Unable to enable or disable Tailscale.${n}" - echo "tailscaled service status: $TAILSCALED_STATUS" -fi - -TAILSCALE_QS="$(gnome-extensions list | grep -q "tailscale"; 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 use this command again." -fi - -if [ "$TAILSCALE_QS" == "Installed" ] && [ "$TAILSCALED" == "Installed" ]; then - echo "Enable or disable Tailscale?" - TS_OPTION=$(gum choose Enable Disable) + #!/bin/bash + source /usr/lib/ujust/ujust.sh - if [ "$TS_OPTION" = "Enable" ]; then - systemctl enable --now tailscaled TAILSCALED_STATUS="$(systemctl is-enabled tailscaled)" + if [ "$TAILSCALED_STATUS" == "enabled" ]; then - gnome-extensions enable tailscale@joaophi.github.com - echo "${b}${green}Enabled Tailscale.${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." + TAILSCALED="Installed" + elif [ "$TAILSCALED_STATUS" == "disabled" ]; then + TAILSCALED="Installed" + else + echo "${b}${red}Unable to enable or disable Tailscale.${n}" + echo "tailscaled service status: $TAILSCALED_STATUS" fi - elif [ "$TS_OPTION" = "Disable" ]; then - systemctl disable --now tailscaled - TAILSCALED_STATUS="$(systemctl is-enabled tailscaled)" - if [ "$TAILSCALED_STATUS" == "disabled" ]; then - gnome-extensions disable tailscale@joaophi.github.com - echo "${b}${red}Disabled Tailscale.${n}" + + TAILSCALE_QS="$(gnome-extensions list | grep -q "tailscale"; 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 use this command again." fi - fi -fi \ No newline at end of file + + if [ "$TAILSCALE_QS" == "Installed" ] && [ "$TAILSCALED" == "Installed" ]; then + echo "Enable or disable Tailscale?" + TS_OPTION=$(gum choose Enable Disable) + + if [ "$TS_OPTION" = "Enable" ]; then + systemctl enable --now tailscaled + TAILSCALED_STATUS="$(systemctl is-enabled tailscaled)" + if [ "$TAILSCALED_STATUS" == "enabled" ]; then + gnome-extensions enable tailscale@joaophi.github.com + echo "${b}${green}Enabled Tailscale.${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)" + if [ "$TAILSCALED_STATUS" == "disabled" ]; then + gnome-extensions disable tailscale@joaophi.github.com + echo "${b}${red}Disabled Tailscale.${n}" + fi + fi + fi \ No newline at end of file From 74cd8b119a5641bafbbaa4aa54f179f17a843fda Mon Sep 17 00:00:00 2001 From: Raindrac Date: Tue, 2 Jul 2024 05:32:24 -0400 Subject: [PATCH 06/12] fix: prevent grep from catching other Tailscale extensions --- just/bluefin-system.just | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/just/bluefin-system.just b/just/bluefin-system.just index 03735ac3fc4..3f6ceead4bb 100644 --- a/just/bluefin-system.just +++ b/just/bluefin-system.just @@ -297,7 +297,7 @@ toggle-tailscale: echo "tailscaled service status: $TAILSCALED_STATUS" fi - TAILSCALE_QS="$(gnome-extensions list | grep -q "tailscale"; echo $?)" + TAILSCALE_QS="$(gnome-extensions list | grep -q "tailscale@joaophi.github.com"; echo $?)" if [ "$TAILSCALE_QS" == 0 ]; then TAILSCALE_QS="Installed" else From 637a07d9c6538e00058ef1a7cf867b0f79bad30e Mon Sep 17 00:00:00 2001 From: Raindrac Date: Tue, 2 Jul 2024 05:52:51 -0400 Subject: [PATCH 07/12] refactor: adjust phrasing --- just/bluefin-system.just | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/just/bluefin-system.just b/just/bluefin-system.just index 3f6ceead4bb..ceaf401218f 100644 --- a/just/bluefin-system.just +++ b/just/bluefin-system.just @@ -313,7 +313,7 @@ toggle-tailscale: TAILSCALED_STATUS="$(systemctl is-enabled tailscaled)" if [ "$TAILSCALED_STATUS" == "enabled" ]; then gnome-extensions enable tailscale@joaophi.github.com - echo "${b}${green}Enabled Tailscale.${n}" + 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 @@ -322,7 +322,7 @@ toggle-tailscale: TAILSCALED_STATUS="$(systemctl is-enabled tailscaled)" if [ "$TAILSCALED_STATUS" == "disabled" ]; then gnome-extensions disable tailscale@joaophi.github.com - echo "${b}${red}Disabled Tailscale.${n}" + echo "${b}${red}Tailscale is disabled.${n}" fi fi fi \ No newline at end of file From 0f17c4efb7b443d3c3279694625de551788c3e53 Mon Sep 17 00:00:00 2001 From: Raindrac Date: Fri, 5 Jul 2024 18:42:25 +0000 Subject: [PATCH 08/12] fix: Changed line ending to satisfy just --- just/bluefin-system.just | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/just/bluefin-system.just b/just/bluefin-system.just index ceaf401218f..54943580933 100644 --- a/just/bluefin-system.just +++ b/just/bluefin-system.just @@ -325,4 +325,4 @@ toggle-tailscale: echo "${b}${red}Tailscale is disabled.${n}" fi fi - fi \ No newline at end of file + fi From 5ece5536a962f9cbb101bc804f5f1ea89f7c7d62 Mon Sep 17 00:00:00 2001 From: Raindrac Date: Mon, 8 Jul 2024 15:15:26 +0000 Subject: [PATCH 09/12] refactor: switch gum to ugum --- just/bluefin-system.just | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/just/bluefin-system.just b/just/bluefin-system.just index 54943580933..35bd40bfa32 100644 --- a/just/bluefin-system.just +++ b/just/bluefin-system.just @@ -306,7 +306,7 @@ toggle-tailscale: if [ "$TAILSCALE_QS" == "Installed" ] && [ "$TAILSCALED" == "Installed" ]; then echo "Enable or disable Tailscale?" - TS_OPTION=$(gum choose Enable Disable) + TS_OPTION=$(ugum choose Enable Disable) if [ "$TS_OPTION" = "Enable" ]; then systemctl enable --now tailscaled From 97628a0983bfcee3c353560a2a9dd70c078a79ac Mon Sep 17 00:00:00 2001 From: Raindrac Date: Mon, 8 Jul 2024 12:54:28 -0400 Subject: [PATCH 10/12] refactor: compactify with OR logical statement --- just/bluefin-system.just | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/just/bluefin-system.just b/just/bluefin-system.just index 35bd40bfa32..0aa65b6f5fc 100644 --- a/just/bluefin-system.just +++ b/just/bluefin-system.just @@ -288,9 +288,7 @@ toggle-tailscale: TAILSCALED_STATUS="$(systemctl is-enabled tailscaled)" - if [ "$TAILSCALED_STATUS" == "enabled" ]; then - TAILSCALED="Installed" - elif [ "$TAILSCALED_STATUS" == "disabled" ]; then + if [ "$TAILSCALED_STATUS" == "enabled" ] || [ "$TAILSCALED_STATUS" == "disabled" ]; then TAILSCALED="Installed" else echo "${b}${red}Unable to enable or disable Tailscale.${n}" From 927c5cedb1a46a7d5cbb5792aa145303af55cada Mon Sep 17 00:00:00 2001 From: Raindrac Date: Mon, 8 Jul 2024 13:29:07 -0400 Subject: [PATCH 11/12] feat: add more error handling --- just/bluefin-system.just | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/just/bluefin-system.just b/just/bluefin-system.just index 0aa65b6f5fc..80c5225f6f9 100644 --- a/just/bluefin-system.just +++ b/just/bluefin-system.just @@ -284,13 +284,15 @@ update-ng: # Toggle tailscale toggle-tailscale: #!/bin/bash + set -euo pipefail source /usr/lib/ujust/ujust.sh - TAILSCALED_STATUS="$(systemctl is-enabled tailscaled)" + 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 "tailscaled service status: $TAILSCALED_STATUS" fi @@ -308,7 +310,7 @@ toggle-tailscale: if [ "$TS_OPTION" = "Enable" ]; then systemctl enable --now tailscaled - TAILSCALED_STATUS="$(systemctl is-enabled 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}" @@ -317,7 +319,7 @@ toggle-tailscale: fi elif [ "$TS_OPTION" = "Disable" ]; then systemctl disable --now tailscaled - TAILSCALED_STATUS="$(systemctl is-enabled 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}" From 7e3b43b1f5d630ada96a37d5bdeab6eb39f42461 Mon Sep 17 00:00:00 2001 From: Raindrac Date: Mon, 8 Jul 2024 14:52:46 -0400 Subject: [PATCH 12/12] refactor: adjust phrasing of error messages --- just/bluefin-system.just | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/just/bluefin-system.just b/just/bluefin-system.just index 80c5225f6f9..e04fc963199 100644 --- a/just/bluefin-system.just +++ b/just/bluefin-system.just @@ -294,6 +294,7 @@ toggle-tailscale: 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 @@ -301,7 +302,7 @@ toggle-tailscale: if [ "$TAILSCALE_QS" == 0 ]; then TAILSCALE_QS="Installed" else - echo "The Tailscale QS extension for Gnome is not installed. Please install it and then use this command again." + 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