From ee63b7fb3826138c2422dc07340cde342fc84e67 Mon Sep 17 00:00:00 2001 From: Simon Hawkenson <7358924+sihawken@users.noreply.github.com> Date: Wed, 8 Feb 2023 16:40:09 -0330 Subject: [PATCH 1/3] Create a migration script --- migrate.sh | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 migrate.sh diff --git a/migrate.sh b/migrate.sh new file mode 100644 index 0000000..dc3db18 --- /dev/null +++ b/migrate.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +IMG_NAME="uBlue Image with Nvidia Drivers" +SB_IMG="ostree-unverified-registry:ghcr.io/ublue-os/silverblue-nvidia:latest" +KN_IMG="ostree-unverified-registry:ghcr.io/ublue-os/silverblue-nvidia:latest" + +if [[ $(id -u) == 0 ]]; then + echo "Do not run this script using sudo. Please run as a normal user." + exit 99 +fi + +if [ -f /etc/os-release ]; then + # freedesktop.org and systemd + . /etc/os-release + OS=$NAME + VAR=$VARIANT +fi + +# Only run if on Kinoite or Silverblue +if [ "${OS}" = "Fedora Linux" ] && [ "${VAR}" = "Kinoite" ]; then + echo "System is running Fedora Kinoite. Ready to migrate to: \"${IMG_NAME}\"." +elif [ "${OS}" = "Fedora Linux" ] && [ "${VAR}" = "Silverblue" ]; then + echo "System is running Fedora Silverblue. Ready to migrate to: \"${IMG_NAME}\"." +else + echo "Host system is neither Fedora Silverblue or Fedora Kinoite. This script only supports migrating from these two systems. Please install Fedora Silverblue or Fedora Kinoite and run the script again." + exit 1 +fi + +echo "Which variant do you wish to install?:" +echo "1. Silverblue" +echo "2. Kinoite" +read -r -p "Select your preferred system: " systemresponse +if [[ $systemresponse =~ 1 ]]; then + echo "Silverblue selected." + IMG=${SB_IMG} +elif [[ $systemresponse =~ 2 ]]; then + echo "Kinoite selected." + IMG=${KN_IMG} +else + echo "Input not recognized. Please run the migration script again." + exit 1 +fi + +read -r -p "WARNING: Rebasing to \"${IMG_NAME}\" will delete all preinstalled flatpaks. This script is meant to only be used on a new Kinoite or Silverblue install. Do you wish to continue? [y/N]: " migrationresponse +if [[ ! $migrationresponse =~ ^[Yy]$ ]]; then + echo "Confirmation not recieved. System will not be migrated." + exit 1 +fi + +echo "Migrating to \"${IMG_NAME}\". Running rpm-ostree rebase && setting the kernel arguments." + +RUNSCRIPT="RET=1; until [ \${RET} -eq 0 ]; do rpm-ostree rebase --experimental ${IMG}; RET=\$?; if [[ ! \$RET = 0 ]]; then read -r -p 'Rebasing failed. Do you want to try again? [y/N]: ' retryresponse; if [[ ! \$retryresponse =~ ^[Yy]$ ]]; then exit 1; fi; fi; done; rpm-ostree kargs --append=rd.driver.blacklist=nouveau --append=modprobe.blacklist=nouveau --append=nvidia-drm.modeset=1" + +pkexec /bin/bash -c "${RUNSCRIPT}" + +echo "System migrated. Reboot to run the new image." + +read -r -p "Do you wish to reboot now? [y/N]: " rebootresponse + +if [[ $rebootresponse =~ ^[Yy]$ ]]; then + echo "Rebooting in 5 seconds..." + sleep 5 + systemctl reboot +fi \ No newline at end of file From 2dd1ad2b54534404f4c2069f1b53776f25ba2443 Mon Sep 17 00:00:00 2001 From: Simon Hawkenson <7358924+sihawken@users.noreply.github.com> Date: Wed, 8 Feb 2023 16:55:40 -0330 Subject: [PATCH 2/3] Typo in migration script prompt --- migrate.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migrate.sh b/migrate.sh index dc3db18..9f086be 100644 --- a/migrate.sh +++ b/migrate.sh @@ -47,7 +47,7 @@ if [[ ! $migrationresponse =~ ^[Yy]$ ]]; then exit 1 fi -echo "Migrating to \"${IMG_NAME}\". Running rpm-ostree rebase && setting the kernel arguments." +echo "Migrating to \"${IMG_NAME}\". Running rpm-ostree rebase & setting the kernel arguments." RUNSCRIPT="RET=1; until [ \${RET} -eq 0 ]; do rpm-ostree rebase --experimental ${IMG}; RET=\$?; if [[ ! \$RET = 0 ]]; then read -r -p 'Rebasing failed. Do you want to try again? [y/N]: ' retryresponse; if [[ ! \$retryresponse =~ ^[Yy]$ ]]; then exit 1; fi; fi; done; rpm-ostree kargs --append=rd.driver.blacklist=nouveau --append=modprobe.blacklist=nouveau --append=nvidia-drm.modeset=1" @@ -61,4 +61,4 @@ if [[ $rebootresponse =~ ^[Yy]$ ]]; then echo "Rebooting in 5 seconds..." sleep 5 systemctl reboot -fi \ No newline at end of file +fi From 0616ff5f03bc5990fbea55ea62ebb34c284b3016 Mon Sep 17 00:00:00 2001 From: Simon Hawkenson <7358924+sihawken@users.noreply.github.com> Date: Wed, 8 Feb 2023 16:56:11 -0330 Subject: [PATCH 3/3] Fix wrong URL for kinoite image --- migrate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrate.sh b/migrate.sh index 9f086be..05398a9 100644 --- a/migrate.sh +++ b/migrate.sh @@ -2,7 +2,7 @@ IMG_NAME="uBlue Image with Nvidia Drivers" SB_IMG="ostree-unverified-registry:ghcr.io/ublue-os/silverblue-nvidia:latest" -KN_IMG="ostree-unverified-registry:ghcr.io/ublue-os/silverblue-nvidia:latest" +KN_IMG="ostree-unverified-registry:ghcr.io/ublue-os/kinoite-nvidia:latest" if [[ $(id -u) == 0 ]]; then echo "Do not run this script using sudo. Please run as a normal user."