Skip to content

Commit

Permalink
Merge pull request #4 from Tirsvad/main
Browse files Browse the repository at this point in the history
Optimized for repeated used
  • Loading branch information
Tirsvad authored Sep 16, 2022
2 parents 738fe3b + 00257ff commit 43549ac
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/NvidiaGpuDriverInstall/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,26 @@ ROOT_DIR=$(dirname $(readlink -f $0))

. $ROOT_DIR/config.sh

PASSWORD

# check if running as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root."
exit
fi

# Clean up if the script has been runned before
rm -f /root/runonetime-nvidia-installer-step-01.log
rm -f /root/runonetime-nvidia-installer-step-02.log
rm -f /usr/local/bin/runonetime-nvidia-installer-step-01.sh
rm -f /usr/local/bin/runonetime-nvidia-installer-step-02.sh
rm -f /etc/systemd/system/runonetime-nvidia-installer-step-01.service
rm -f /etc/systemd/system/runonetime-nvidia-installer-step-02.service

# Nvidia is a non-free software
apt-add-repository non-free

# Needed software for this
DEBIAN_FRONTEND=noninteractive apt-get -qq update && apt-get -qq upgrade
DEBIAN_FRONTEND=noninteractive apt-get install mokutil openssl
DEBIAN_FRONTEND=noninteractive apt-get -qq install mokutil openssl
DEBIAN_FRONTEND=noninteractive apt-get -qq install linux-headers-$(uname -r) build-essential
DEBIAN_FRONTEND=noninteractive apt-get -qq install pkg-config
DEBIAN_FRONTEND=noninteractive apt-get -qq install libglvnd-dev
Expand All @@ -29,7 +35,7 @@ if [ ! -f /root/$FILENAME ]; then
curl -LO $DRIVERLINK
chmod u+x $FILENAME
else
echo "File Exist: No need of downloading"
echo "File Exist: Skiping downloading"
fi

# uefi self generated key for signing nvidia driver
Expand All @@ -42,10 +48,9 @@ if [ -d /sys/firmware/efi ]; then
fi

# We need to reboot so key will be loaded. We making some boot up script that will be run onetime and deleted
[ ! -f /usr/local/bin/runonetime-nvidia-installer-step-01.sh ] && {
cat <<EOT >> /usr/local/bin/runonetime-nvidia-installer-step-01.sh
#!/bin/bash
exec 3>&1 1>>/root/step1.log 2>&1
exec 3>&1 1>>/root/runonetime-nvidia-installer-step-01.log 2>&1
DEBIAN_FRONTEND=noninteractive apt-get remove nvidia* && sudo apt-get autoremove
echo "blacklist nouveau" > /etc/modprobe.d/blacklist-nouveau.conf
echo "blacklist lbm-nouveau" >> /etc/modprobe.d/blacklist-nouveau.conf
Expand All @@ -60,7 +65,6 @@ rm /usr/local/bin/runonetime-nvidia-installer-step-01.sh
rm /etc/systemd/system/runonetime-nvidia-installer-step-01.service
reboot
EOT
}

chmod +x /usr/local/bin/runonetime-nvidia-installer-step-01.sh

Expand All @@ -80,10 +84,9 @@ chmod 644 /etc/systemd/system/runonetime-nvidia-installer-step-01.service

# Script part 2

[ ! -f /usr/local/bin/runonetime-nvidia-installer-step-02.sh ] && {
cat <<EOT >> /usr/local/bin/runonetime-nvidia-installer-step-02.sh
#!/bin/bash
exec 3>&1 1>>/root/step2.log 2>&1
exec 3>&1 1>>/root/runonetime-nvidia-installer-step-02.log 2>&1
cd /root
if [ -d /sys/firmware/efi ]; then
./$FILENAME -s --module-signing-secret-key=/root/UEFI.key --module-signing-public-key=/root/UEFI.der
Expand All @@ -94,9 +97,9 @@ systemctl set-default graphical.target
systemctl disable runonetime-nvidia-installer-step-02.service
rm /usr/local/bin/runonetime-nvidia-installer-step-02.sh
/etc/systemd/system/runonetime-nvidia-installer-step-02.service
reboot
shutdown -r now
EOT
}

chmod +x /usr/local/bin/runonetime-nvidia-installer-step-02.sh

cat <<EOT >> /etc/systemd/system/runonetime-nvidia-installer-step-02.service
Expand All @@ -120,5 +123,4 @@ systemctl enable runonetime-nvidia-installer-step-01.service
systemctl set-default multi-user.target
systemctl daemon-reload

shutdown -r

shutdown -r now

0 comments on commit 43549ac

Please sign in to comment.