From 8b9455d0e1cfc11fa14adbac67332f10ce4339be Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sat, 12 Nov 2022 13:14:02 +0100 Subject: [PATCH] Add scripts for `linux-surface` and `secure-boot` --- ManuSurface/setup.sh | 4 ++++ scripts/PopOS/linux-surface.sh | 22 ++++++++++++++++++ scripts/PopOS/secure-boot.sh | 42 ++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 scripts/PopOS/linux-surface.sh create mode 100644 scripts/PopOS/secure-boot.sh diff --git a/ManuSurface/setup.sh b/ManuSurface/setup.sh index b8bc6c8d..5839b39d 100644 --- a/ManuSurface/setup.sh +++ b/ManuSurface/setup.sh @@ -8,6 +8,10 @@ sudo hostnamectl set-hostname ManuSurface sudo apt update sudo apt upgrade +# Install surface-linux and Secure Boot +source "$dir/../scripts/PopOS/linux-surface.sh" +source "$dir/../scripts/PopOS/secure-boot.sh" + # Install Brave source "$dir/../scripts/PopOS/softwate/brave.sh" source "$dir/../scripts/PopOS/software/brave-extensions.sh" diff --git a/scripts/PopOS/linux-surface.sh b/scripts/PopOS/linux-surface.sh new file mode 100644 index 00000000..70bbdfb0 --- /dev/null +++ b/scripts/PopOS/linux-surface.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Elevate script +if [ ! "$UID" -eq 0 ] +then + exec sudo bash "$0" +fi + +wget -qO - https://raw.githubusercontent.com/linux-surface/linux-surface/master/pkg/keys/surface.asc \ + | gpg --dearmor | sudo dd of=/etc/apt/trusted.gpg.d/linux-surface.gpg + +echo "deb [arch=amd64] https://pkg.surfacelinux.com/debian release main" \ + | sudo tee /etc/apt/sources.list.d/linux-surface.list + +apt update +apt install linux-image-surface linux-headers-surface iptsd libwacom-surface +systemctl enable iptsd + +# Install DTX +package=$(mktemp) +wget https://github.com/linux-surface/surface-dtx-daemon/releases/download/v0.3.3-2/surface-dtx-daemon_0.3.3-2_amd64.deb -O $package +dpkg -i $package +rm -f $package diff --git a/scripts/PopOS/secure-boot.sh b/scripts/PopOS/secure-boot.sh new file mode 100644 index 00000000..0e642c33 --- /dev/null +++ b/scripts/PopOS/secure-boot.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# Elevate script +if [ ! "$UID" -eq 0 ] +then + exec sudo bash "$0" +fi + +# Create context directory +workingDirectory=$(pwd) +contextRoot=$(mktemp -d) +cd $contextRoot + +# Initialize variables +esp=/boot/efi +defaultBootDir=$esp/EFI/BOOT +microsoftBootDir=$esp/EFI/Microsoft/Boot + +systemdDirName=/EFI/systemd +systemdFullName=$esp$systemdDirName +systemdFile=$systemdFullName/systemd-bootx64.efi + +loaderBaseName=loader.efi +systemdLoaderFile=$systemdFullName/$loaderBaseName + +# Install PreLoader +wget https://blog.hansenpartnership.com/wp-uploads/2013/HashTool.efi +wget https://blog.hansenpartnership.com/wp-uploads/2013/PreLoader.efi + +cp {HashTool,PreLoader}.efi $systemdFullName +cp $systemdFile $systemdLoaderFile +efibootmgr --unicode --disk /dev/nvme0n1 --part 0 --create --label "PreLoader" --loader $systemdDirName/PreLoader.efi + +# Add fallbacks +cp ./HashTool.efi $defaultBootDir +cp $systemdFile $defaultBootDir/$loaderBaseName +cp ./PreLoader.efi $defaultBootDir/BOOTx64.EFI + +# Add Microsoft fallbacks +mkdir -p $microsoftBootDir +cp ./PreLoader.efi $microsoftBootDir/bootmgfw.efi +cp ./HashTool.efi $microsoftBootDir +cp $systemdFile $microsoftBootDir/$loaderBaseName