diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 21bc74cd315..20bd0d6fd35 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -213,7 +213,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} # Sign container - - uses: sigstore/cosign-installer@v3.3.0 + - uses: sigstore/cosign-installer@v3.4.0 if: github.event_name != 'pull_request' - name: Sign container image diff --git a/fetch-quadlets.sh b/fetch-quadlets.sh index e9d200ec2f4..6cc90904c5b 100755 --- a/fetch-quadlets.sh +++ b/fetch-quadlets.sh @@ -7,36 +7,42 @@ mkdir -p /usr/etc/containers/systemd/users # bluefin-cli wget --output-document="/usr/etc/containers/systemd/users/bluefin-cli.container" --quiet https://raw.githubusercontent.com/ublue-os/toolboxes/main/quadlets/bluefin-cli/bluefin-cli.container +cat /usr/share/ublue-os/bluefin-cli/prompt-integration >> /usr/etc/containers/systemd/users/bluefin-cli.container printf "\n\n[Install]\nWantedBy=bluefin-cli.target" >> /usr/etc/containers/systemd/users/bluefin-cli.container sed -i '/AutoUpdate.*/ s/^#*/#/' /usr/etc/containers/systemd/users/bluefin-cli.container sed -i 's/ContainerName=bluefin/ContainerName=bluefin-cli/' /usr/etc/containers/systemd/users/bluefin-cli.container # bluefin-dx-cli wget --output-document="/usr/etc/containers/systemd/users/bluefin-dx-cli.container" --quiet https://raw.githubusercontent.com/ublue-os/toolboxes/main/quadlets/bluefin-cli/bluefin-dx-cli.container +cat /usr/share/ublue-os/bluefin-cli/prompt-integration >> /usr/etc/containers/systemd/users/bluefin-dx-cli.container printf "\n\n[Install]\nWantedBy=bluefin-dx-cli.target" >> /usr/etc/containers/systemd/users/bluefin-dx-cli.container sed -i '/AutoUpdate.*/ s/^#*/#/' /usr/etc/containers/systemd/users/bluefin-dx-cli.container sed -i 's/ContainerName=bluefin/ContainerName=bluefin-dx-cli/' /usr/etc/containers/systemd/users/bluefin-dx-cli.container # fedora-toolbox wget --output-document="/usr/etc/containers/systemd/users/fedora-toolbox.container" --quiet https://raw.githubusercontent.com/ublue-os/toolboxes/main/quadlets/fedora-toolbox/fedora-distrobox-quadlet.container +cat /usr/share/ublue-os/bluefin-cli/prompt-integration >> /usr/etc/containers/systemd/users/fedora-toolbox.container printf "\n\n[Install]\nWantedBy=fedora-toolbox.target" >> /usr/etc/containers/systemd/users/fedora-toolbox.container sed -i '/AutoUpdate.*/ s/^#*/#/' /usr/etc/containers/systemd/users/fedora-toolbox.container sed -i 's/ContainerName=fedora-distrobox-quadlet/ContainerName=fedora-toolbox/' /usr/etc/containers/systemd/users/fedora-toolbox.container # ubuntu-toolbox wget --output-document="/usr/etc/containers/systemd/users/ubuntu-toolbox.container" --quiet https://raw.githubusercontent.com/ublue-os/toolboxes/main/quadlets/ubuntu-toolbox/ubuntu-distrobox-quadlet.container +cat /usr/share/ublue-os/bluefin-cli/prompt-integration >> /usr/etc/containers/systemd/users/ubuntu-toolbox.container printf "\n\n[Install]\nWantedBy=ubuntu-toolbox.target" >> /usr/etc/containers/systemd/users/ubuntu-toolbox.container sed -i '/AutoUpdate.*/ s/^#*/#/' /usr/etc/containers/systemd/users/ubuntu-toolbox.container sed -i 's/ContainerName=ubuntu-distrobox-quadlet/ContainerName=ubuntu-toolbox/' /usr/etc/containers/systemd/users/ubuntu-toolbox.container # wolfi-toolbox wget --output-document="/usr/etc/containers/systemd/users/wolfi-toolbox.container" --quiet https://raw.githubusercontent.com/ublue-os/toolboxes/main/quadlets/wolfi-toolbox/wolfi-distrobox-quadlet.container +cat /usr/share/ublue-os/bluefin-cli/prompt-integration >> /usr/etc/containers/systemd/users/wolfi-toolbox.container printf "\n\n[Install]\nWantedBy=wolfi-toolbox.target" >> /usr/etc/containers/systemd/users/wolfi-toolbox.container sed -i '/AutoUpdate.*/ s/^#*/#/' /usr/etc/containers/systemd/users/wolfi-toolbox.container sed -i 's/ContainerName=wolfi-quadlet/ContainerName=wolfi-toolbox/' /usr/etc/containers/systemd/users/wolfi-toolbox.container # wolfi-dx-toolbox wget --output-document="/usr/etc/containers/systemd/users/wolfi-dx-toolbox.container" --quiet https://raw.githubusercontent.com/ublue-os/toolboxes/main/quadlets/wolfi-toolbox/wolfi-dx-distrobox-quadlet.container +cat /usr/share/ublue-os/bluefin-cli/prompt-integration >> /usr/etc/containers/systemd/users/wolfi-dx-toolbox.container printf "\n\n[Install]\nWantedBy=wolfi-dx-toolbox.target" >> /usr/etc/containers/systemd/users/wolfi-dx-toolbox.container sed -i '/AutoUpdate.*/ s/^#*/#/' /usr/etc/containers/systemd/users/wolfi-dx-toolbox.container sed -i 's/ContainerName=wolfi-quadlet/ContainerName=wolfi-dx-toolbox/' /usr/etc/containers/systemd/users/wolfi-dx-toolbox.container diff --git a/just/custom.just b/just/custom.just index a25219be65d..1121cd02f34 100644 --- a/just/custom.just +++ b/just/custom.just @@ -5,9 +5,14 @@ benchmark: echo 'Running a 1 minute benchmark ...' stress-ng --matrix 0 -t 1m --times -# Configure bluefin-cli Terminal Experience +# Configure Bluefin-CLI Terminal Experience bluefin-cli: - /usr/libexec/bluefin-cli.sh + @/usr/libexec/enable-bluefin-cli.sh + +# Configure Terminal Experience +[private] +configure-terminal: + @/usr/libexec/configure-terminal.sh # Enable Cockpit for web-based system management | https://cockpit-project.org/ cockpit: diff --git a/usr/libexec/bluefin-cli.sh b/usr/libexec/configure-terminal.sh similarity index 84% rename from usr/libexec/bluefin-cli.sh rename to usr/libexec/configure-terminal.sh index 303e3ed7f07..73b6aef382f 100755 --- a/usr/libexec/bluefin-cli.sh +++ b/usr/libexec/configure-terminal.sh @@ -7,9 +7,11 @@ source /usr/lib/ujust/ujust.sh ### targets=( "bluefin-cli" + "bluefin-dx-cli" "fedora-toolbox" "ubuntu-toolbox" "wolfi-toolbox" + "wolfi-dx-toolbox" ) ### @@ -39,6 +41,7 @@ function String_check(){ ### # Trap function ### +# shellcheck disable=SC2317 function ctrl_c(){ printf "\nSignal SIGINT caught\n" Exiting @@ -66,7 +69,6 @@ function Make_container(){ fi if test "$MAKE_CONTAINER" -eq 1; then printf "Not making a container. Existing containers will not be deleted...\n" - Make_bashrc_d_file "$TERMINAL_CHOICE" "$CONTAINER_CHOICE" Good_Exit fi } @@ -124,7 +126,6 @@ function Is_enabled_and_stop(){ unset "$Enabled" done if test "$MATCH" -eq 1; then - Make_bashrc_d_file "$TERMINAL_CHOICE" "$1" Good_Exit fi unset $MATCH @@ -148,7 +149,6 @@ function Already_exists_and_rm(){ podman rm --force "$1" else echo "Reuisng existing $1 container." - Make_bashrc_d_file "$TERMINAL_CHOICE" "$1" Good_Exit fi unset "$Delete" @@ -194,20 +194,20 @@ function Build_container(){ # If ~/.bashrc.d exists and Chose Container for terminal. Make a symlink from /usr/share/ublue-os for first time shell. # If Host was chosen. Remove existing symlink. ### -function Make_bashrc_d_file(){ - if test -d "${HOME}/.bashrc.d" && test "$1" = "Host"; then - echo "${red}Removing existing ~/.bashrc.d/00-container.sh if it exists${normal}." - test -f "${HOME}/.bashrc.d/00-container.sh" && rm "${HOME}/.bashrc.d/00-container.sh" - elif test -d "${HOME}/.bashrc.d"; then - echo "Setting first terminal be Container for bash using ~/.bashrc.d" - echo "Enter into container using prompt's menu after first entry" - echo "${blue}This requires your bash shell to source files in ~/.bashrc.d/${normal}" - test -e "${HOME}/.bashrc.d/00-container.sh" && rm "${HOME}/.bashrc.d/00-container.sh" - cp "/usr/share/ublue-os/bluefin-cli/${2}.sh" "${HOME}/.bashrc.d/00-container.sh" - else - echo "${red}Not implemented for non-Bash shells${normal} at this time..." - fi -} +# function Make_bashrc_d_file(){ +# if test -d "${HOME}/.bashrc.d" && test "$1" = "Host"; then +# echo "${red}Removing existing ~/.bashrc.d/00-container.sh if it exists${normal}." +# test -f "${HOME}/.bashrc.d/00-container.sh" && rm "${HOME}/.bashrc.d/00-container.sh" +# elif test -d "${HOME}/.bashrc.d"; then +# echo "Setting first terminal be Container for bash using ~/.bashrc.d" +# echo "Enter into container using prompt's menu after first entry" +# echo "${blue}This requires your bash shell to source files in ~/.bashrc.d/${normal}" +# test -e "${HOME}/.bashrc.d/00-container.sh" && rm "${HOME}/.bashrc.d/00-container.sh" +# cp "/usr/share/ublue-os/bluefin-cli/${2}.sh" "${HOME}/.bashrc.d/00-container.sh" +# else +# echo "${red}Not implemented for non-Bash shells${normal} at this time..." +# fi +# } function main(){ trap ctrl_c SIGINT @@ -219,7 +219,6 @@ function main(){ Is_enabled_and_stop "$CONTAINER_CHOICE" Already_exists_and_rm "$CONTAINER_CHOICE" Build_container "$MAKE_CONTAINER" "$CONTAINER_MANAGER" "$CONTAINER_CHOICE" - Make_bashrc_d_file "$TERMINAL_CHOICE" "$CONTAINER_CHOICE" Good_Exit } diff --git a/usr/libexec/enable-bluefin-cli.sh b/usr/libexec/enable-bluefin-cli.sh new file mode 100755 index 00000000000..037cb5fe655 --- /dev/null +++ b/usr/libexec/enable-bluefin-cli.sh @@ -0,0 +1,57 @@ +#!/usr/bin/bash + +# Choose to enable or disable bluefin-cli + +# shellcheck disable=1091 +# shellcheck disable=2206 +# shellcheck disable=2154 +source /usr/lib/ujust/ujust.sh + +bluefin_cli=(${red}Disabled${n} ${red}Inactive${n}) + +function get_status(){ + if systemctl --quiet --user is-enabled bluefin-cli.target; then + bluefin_cli[0]="${green}Enabled${n}" + else + bluefin_cli[0]="${red}Disabled${n}" + fi + if systemctl --quiet --user is-active bluefin-cli.service; then + bluefin_cli[1]="${green}Active${n}" + else + bluefin_cli[1]="${red}Inactive${n}" + fi + echo "Bluefin-cli is currently ${b}${bluefin_cli[0]}${n} and ${b}${bluefin_cli[1]}${n}" +} +function logic(){ + if test "$toggle" = "Enable"; then + echo "${b}${green}Enabling${n} Bluefin-CLI" + systemctl --user enable --now bluefin-cli.target > /dev/null 2>&1 + if ! systemctl --quiet --user is-active bluefin-cli.service; then + systemctl --user reset-failed bluefin-cli.service > /dev/null 2>&1 || true + echo "${b}${green}Starting${n} Bluefin-CLI" + systemctl --user start bluefin-cli.service + fi + elif test "$toggle" = "Disable"; then + echo "${b}${red}Disabling${n} Bluefin-CLI" + systemctl --user disable --now bluefin-cli.target > /dev/null 2>&1 + if systemctl --quiet --user is-active bluefin-cli.service; then + echo "Do you want to ${b}${red}Stop${n} the Container?" + stop=$(Confirm) + if test "$stop" -eq 0; then + systemctl --user stop bluefin-cli.service > /dev/null 2>&1 + systemctl --user reset-failed bluefin-cli.service > /dev/null 2>&1 || true + fi + fi + else + echo "Not Changing" + fi +} + +function main(){ + get_status + toggle=$(Choose Enable Disable Cancel) + logic + get_status +} + +main \ No newline at end of file diff --git a/usr/libexec/prompt-add-profile.sh b/usr/libexec/prompt-add-profile.sh new file mode 100755 index 00000000000..8286a591c74 --- /dev/null +++ b/usr/libexec/prompt-add-profile.sh @@ -0,0 +1,29 @@ +#!/usr/bin/bash + +# Read the current value of the array +CURRENT_VALUE=$(dconf read /org/gnome/Prompt/profile-uuids) +guid=$1 + +# remove the leading and trailing brackets +CURRENT_VALUE=${CURRENT_VALUE:1:-1} + +# remove any spaces +CURRENT_VALUE=${CURRENT_VALUE// /} + +# split the string into an array +IFS=',' read -r -a array <<<"$CURRENT_VALUE" + +# add the new value +array+=("'$guid'") + +# join the array back into a string +UPDATED_VALUE=$(printf "%s," "${array[@]}") + +# remove the trailing comma +UPDATED_VALUE=${UPDATED_VALUE%?} + +# add the leading and trailing brackets +UPDATED_VALUE="[$UPDATED_VALUE]" + +# Write the updated array back to dconf +dconf write /org/gnome/Prompt/profile-uuids "$UPDATED_VALUE" \ No newline at end of file diff --git a/usr/libexec/prompt-create-profile.sh b/usr/libexec/prompt-create-profile.sh new file mode 100755 index 00000000000..87d8161856b --- /dev/null +++ b/usr/libexec/prompt-create-profile.sh @@ -0,0 +1,42 @@ +#!/usr/bin/bash + +# create a Prompt profile using dconf given the guid of the instance +# $1 = name + +# dconf read /org/gnome/Prompt/Profiles/d092b3519698570a3252762c658f7629/ +# /org/gnome/Prompt/Profiles/d092b3519698570a3252762c658f7629/custom-command +# 'blincus shell myubuntu' +# /org/gnome/Prompt/Profiles/d092b3519698570a3252762c658f7629/label +# 'myubuntu' +# /org/gnome/Prompt/Profiles/d092b3519698570a3252762c658f7629/login-shell +# true +# /org/gnome/Prompt/Profiles/d092b3519698570a3252762c658f7629/use-custom-command +# true + +# if dconf doesn't exist, just return +if ! command -v dconf >/dev/null; then + return +fi + +# shellcheck disable=SC2001 +gen_uuid() { + uuid="$(cat /proc/sys/kernel/random/uuid)" + echo "$uuid" | sed 's/-//g' +} + +guid=$(gen_uuid) +name="$1" +palette="$2" + +profile="/org/gnome/Prompt/Profiles/${guid}/" + +dconf write "${profile}custom-command" "'sh -c \"[ ! -e /run/.containerenv ] && [ ! -e /run/.dockerenv ] && distrobox enter ${name} || ${SHELL}\"'" +dconf write "${profile}label" "'${name}'" +dconf write "${profile}use-custom-command" "true" +if test -n "$palette"; then + dconf write "${profile}palette" "'${palette}'" +elif test "$name" = "bluefin-cli"; then + dconf write "${profile}palette" "'catppuccin-dynamic'" +fi + +/usr/libexec/prompt-add-profile.sh "$guid" diff --git a/usr/libexec/prompt-remove-profile.sh b/usr/libexec/prompt-remove-profile.sh new file mode 100755 index 00000000000..2cd33642975 --- /dev/null +++ b/usr/libexec/prompt-remove-profile.sh @@ -0,0 +1,52 @@ +#!/usr/bin/bash +# ensure that the prompt profiles for deleted instances are removed + +# if dconf doesn't exist, just return +if ! command -v dconf >/dev/null; then + return +fi + +name="$1" + +# Read the current value of the array +CURRENT_VALUE=$(dconf read /org/gnome/Prompt/profile-uuids) + +# remove the leading and trailing brackets +CURRENT_VALUE=${CURRENT_VALUE:1:-1} + +# remove any spaces +CURRENT_VALUE=${CURRENT_VALUE// /} + +# split the string into an array +IFS=',' read -r -a array <<<"$CURRENT_VALUE" + +# loop through the array and remove any that don't exist +for i in "${!array[@]}"; do + guid=${array[i]} + + # remove single quotes from guid + + guid=${guid//\'/} + + #echo "Checking profile for $(red $guid)" + profile="/org/gnome/Prompt/Profiles/${guid}/" + + custom_shell=$(dconf read "${profile}custom-command") + + if [[ $custom_shell == *"[ ! -e /run/.containerenv ] && [ ! -e /run/.dockerenv ] && distrobox enter ${name}"* ]]; then + dconf reset -f "${profile}" + # remove the guid from the array + unset 'array[i]' + # join the array back into a string + UPDATED_VALUE=$(printf "%s," "${array[@]}") + + # remove the trailing comma + UPDATED_VALUE=${UPDATED_VALUE%?} + + # add the leading and trailing brackets + UPDATED_VALUE="[$UPDATED_VALUE]" + + # Write the updated array back to dconf + dconf write /org/gnome/Prompt/profile-uuids "$UPDATED_VALUE" + fi +done \ No newline at end of file diff --git a/usr/share/ublue-os/bluefin-cli/bluefin-cli.sh b/usr/share/ublue-os/bluefin-cli/bluefin-cli.sh deleted file mode 100644 index b6c9b2e066c..00000000000 --- a/usr/share/ublue-os/bluefin-cli/bluefin-cli.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -if test ! -f "/run/user/${UID}/container-entry" && test -n "$PS1"; then - touch "/run/user/${UID}/container-entry" - exec /usr/bin/distrobox-enter bluefin-cli -fi \ No newline at end of file diff --git a/usr/share/ublue-os/bluefin-cli/prompt-integration b/usr/share/ublue-os/bluefin-cli/prompt-integration new file mode 100644 index 00000000000..7d93a895cae --- /dev/null +++ b/usr/share/ublue-os/bluefin-cli/prompt-integration @@ -0,0 +1,6 @@ + + +[Service] +ExecStartPre=-/usr/libexec/prompt-remove-profile.sh %N +ExecStartPost=-/usr/libexec/prompt-create-profile.sh %N +ExecStop=-/usr/libexec/prompt-remove-profile.sh %N \ No newline at end of file diff --git a/usr/share/ublue-os/motd/tips/10-tips.md b/usr/share/ublue-os/motd/tips/10-tips.md index 9c93dd9e7de..46fc5db4811 100644 --- a/usr/share/ublue-os/motd/tips/10-tips.md +++ b/usr/share/ublue-os/motd/tips/10-tips.md @@ -6,7 +6,7 @@ Support the app store! Donate to  [Flatpak](https://opencollective.com/flatpa Bluefin is proudly built using 󰣛 Fedora Atomic Desktop technology with a bit of  Ubuntu flavor Check out Justin Garrison's 󰗃 [Introduction to Bluefin](https://www.youtube.com/watch?v=Nz-yyDwTfRM) Check out the Bluefin 󰗃 [announcement video](https://www.youtube.com/watch?v=YFXufAVdrw4) -Need more indepth technical information? ~ Check out the [Bluefin Administrator's Guide](https://universal-blue.discourse.group/docs?topic=40) +Need more indepth technical information?~Check out the [Bluefin Administrator's Guide](https://universal-blue.discourse.group/docs?topic=40) Support [Bluefin's Paleoartists](https://universal-blue.discourse.group/docs?topic=299) Like servers? Check out [ucore](https://github.com/ublue-os/ucore) -Update break something? You can roll back and pin the previous release or build date: ~ [View our guide](https://universal-blue.discourse.group/docs?topic=513) +Update break something? You can roll back and pin the previous release or build date:~[View our guide](https://universal-blue.discourse.group/docs?topic=513)