From 38b9812d97d9a0087a2b29341599e8bfee92bf8f Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Mon, 23 Jan 2023 16:14:55 +0100 Subject: [PATCH] Manage workind directories using `pushd`/`popd` --- scripts/Config/Fonts/MicrosoftFonts/install.sh | 5 ++--- scripts/Config/GnomeExtensions/install.sh | 10 ++++------ scripts/Devices/SurfaceBook2/Camera/install.sh | 5 ++--- scripts/Devices/SurfaceBook2/SecureBoot/install.sh | 5 ++--- scripts/Software/JetBrains/install-toolbox.sh | 5 ++--- scripts/Software/Oh My Posh/install.sh | 5 ++--- scripts/Software/Woodpecker CLI/install.sh | 3 +-- scripts/Software/tea/install.sh | 5 ++--- 8 files changed, 17 insertions(+), 26 deletions(-) diff --git a/scripts/Config/Fonts/MicrosoftFonts/install.sh b/scripts/Config/Fonts/MicrosoftFonts/install.sh index 8d1a6449..4ea90da4 100755 --- a/scripts/Config/Fonts/MicrosoftFonts/install.sh +++ b/scripts/Config/Fonts/MicrosoftFonts/install.sh @@ -5,9 +5,8 @@ then sudo bash "$BASH_SOURCE" "$USER"; else apt install -y p7zip-full libgumbo-dev libfuse-dev libssl-dev libcurl4-openssl-dev uuid-dev; - workingDirectory="$(pwd)"; tempDir="$(mktemp -d)"; - cd "$tempDir"; + pushd "$tempDir"; git clone https://github.com/fangfufu/httpdirfs.git; pushd httpdirfs; @@ -28,5 +27,5 @@ else unzip -d . CascadiaCode.zip; cp ttf/* /usr/share/fonts/TTF; - cd "$workingDirectory"; + popd; fi diff --git a/scripts/Config/GnomeExtensions/install.sh b/scripts/Config/GnomeExtensions/install.sh index 83a0ea51..426bafa7 100755 --- a/scripts/Config/GnomeExtensions/install.sh +++ b/scripts/Config/GnomeExtensions/install.sh @@ -1,23 +1,21 @@ #!/bin/bash commandName=gnome-shell-extension-installer; extensionLocation=/usr/share/gnome-shell/extensions; -workingDirectory="$(pwd)"; contextRoot="$(mktemp -d)"; -cd "$contextRoot"; +pushd "$contextRoot"; sudo apt install -y jq; wget -O "$commandName" "https://github.com/brunelli/gnome-shell-extension-installer/raw/master/gnome-shell-extension-installer"; sudo install "$commandName" /usr/local/bin; -cd "$workingDirectory"; +popd; rm -rf "$contextRoot"; for id in 779 4907 1162 do - workingDirectory="$(pwd)"; contextRoot="$(mktemp -d)"; unzipLocation="$(mktemp -d)"; - cd "$contextRoot"; + pushd "$contextRoot"; gnome-shell-extension-installer "$id" --no-install; sudo gnome-shell-extension-installer "$id" --yes; @@ -27,7 +25,7 @@ do sudo chmod -R +r "$extensionLocation/$uuid"; gnome-extensions enable "$uuid"; - cd "$workingDirectory"; + popd; rm -rf "$contextRoot"; done diff --git a/scripts/Devices/SurfaceBook2/Camera/install.sh b/scripts/Devices/SurfaceBook2/Camera/install.sh index 55f4ba7e..b77c281d 100755 --- a/scripts/Devices/SurfaceBook2/Camera/install.sh +++ b/scripts/Devices/SurfaceBook2/Camera/install.sh @@ -1,6 +1,5 @@ -workingDirectory="$(pwd)"; contextRoot="$(mktemp -d)"; -cd "$contextRoot"; +pushd "$contextRoot"; sudo apt install -y \ build-essential meson ninja-build pkg-config libgnutls28-dev openssl \ @@ -15,5 +14,5 @@ meson build -Dpipelines=uvcvideo,vimc,ipu3 -Dipas=vimc,ipu3 -Dprefix=/usr -Dgstr ninja -C build; sudo ninja -C build install; -cd "$workingDirectory"; +popd; rm -rf "$contextRoot"; diff --git a/scripts/Devices/SurfaceBook2/SecureBoot/install.sh b/scripts/Devices/SurfaceBook2/SecureBoot/install.sh index 8e77c926..e2f63f5b 100755 --- a/scripts/Devices/SurfaceBook2/SecureBoot/install.sh +++ b/scripts/Devices/SurfaceBook2/SecureBoot/install.sh @@ -8,10 +8,9 @@ then bash "$scriptRoot/sign-modules.sh"; else # Create context directory - workingDirectory="$(pwd)"; contextRoot="$(mktemp -d)"; packageName="shim.rpm"; - cd "$contextRoot"; + pushd "$contextRoot"; # Install Prerequisites apt install -y wget rpm2cpio efitools; @@ -89,6 +88,6 @@ else mokutil --import "$keyDir/MOK.der"; # Remove context directory - cd "$workingDirectory"; + popd; rm -rf "$contextRoot"; fi diff --git a/scripts/Software/JetBrains/install-toolbox.sh b/scripts/Software/JetBrains/install-toolbox.sh index d68983c7..4c2d1ac2 100755 --- a/scripts/Software/JetBrains/install-toolbox.sh +++ b/scripts/Software/JetBrains/install-toolbox.sh @@ -4,14 +4,13 @@ if [ ! "$UID" -eq 0 ] then sudo bash "$BASH_SOURCE"; else - workingDirectory="$(pwd)"; contextRoot="$(mktemp -d)"; - cd "$contextRoot"; + pushd "$contextRoot"; curl -fsSL https://raw.githubusercontent.com/nagygergo/jetbrains-toolbox-install/1.1/jetbrains-toolbox.sh \ | bash; - cd "$workingDirectory"; + popd; rm -rf "$contextRoot"; { diff --git a/scripts/Software/Oh My Posh/install.sh b/scripts/Software/Oh My Posh/install.sh index c119f3e1..6a21bf10 100755 --- a/scripts/Software/Oh My Posh/install.sh +++ b/scripts/Software/Oh My Posh/install.sh @@ -5,14 +5,13 @@ then sudo bash "$BASH_SOURCE" "$USER"; else bin=oh-my-posh; - workingDirectory="$(pwd)"; contextRoot="$(mktemp -d)"; - cd "$contextRoot"; + pushd "$contextRoot"; wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O "$bin"; install "$bin" /usr/local/bin; - cd "$workingDirectory"; + popd; rm -rf "$contextRoot"; homeDir="$(sudo -u "$1" bash -c 'realpath ~')"; diff --git a/scripts/Software/Woodpecker CLI/install.sh b/scripts/Software/Woodpecker CLI/install.sh index e5404519..297f7e6a 100755 --- a/scripts/Software/Woodpecker CLI/install.sh +++ b/scripts/Software/Woodpecker CLI/install.sh @@ -4,7 +4,6 @@ if [ ! "$UID" -eq 0 ] then sudo bash "$BASH_SOURCE"; else - workingDirectory="$(pwd)"; contextRoot="$(mktemp -d)"; cd "$contextRoot"; @@ -19,6 +18,6 @@ else tar -xvzf woodpecker-cli.tar.gz; install woodpecker-cli /usr/local/bin; - cd "$workingDirectory"; + popd; rm -rf "$contextRoot"; fi diff --git a/scripts/Software/tea/install.sh b/scripts/Software/tea/install.sh index bfd17b1d..7829435c 100755 --- a/scripts/Software/tea/install.sh +++ b/scripts/Software/tea/install.sh @@ -4,13 +4,12 @@ if [ ! "$UID" -eq 0 ] then sudo bash "$BASH_SOURCE"; else - workingDirectory="$(pwd)"; contextRoot="$(mktemp -d)"; - cd "$contextRoot"; + pushd "$contextRoot"; wget https://dl.gitea.io/tea/0.9.0/tea-0.9.0-linux-amd64 -O tea; install tea /usr/local/bin; - cd "$workingDirectory"; + popd; rm -rf "$contextRoot"; fi