Put dynamic expressions in quotes

This commit is contained in:
Manuel Thalmann 2023-01-23 16:11:51 +01:00
parent c59b48b50b
commit d6234bd7c9
15 changed files with 102 additions and 102 deletions
scripts/Software
Brave
JetBrains
Oh My Posh
Visual Studio Code
Woodpecker CLI
logo-ls
rclone
tea

View file

@ -5,46 +5,46 @@ then
sudo bash "$BASH_SOURCE" "$USER";
else
# Download and extract `youtube-music-dl`
archiveName=$(sudo -u $1 mktemp);
sudo -u $1 wget https://github.com/dougppaz/youtube-music-dl/releases/download/v1.2.1/youtube-music-dl.zip -O $archiveName;
archiveName="$(sudo -u "$1" mktemp)";
sudo -u "$1" wget https://github.com/dougppaz/youtube-music-dl/releases/download/v1.2.1/youtube-music-dl.zip -O "$archiveName";
extensionName=youtube-music-dl;
contextRoot=$(sudo -u $1 mktemp -d);
extensionDir=$contextRoot/$extensionName;
keyFile=$extensionDir.pem;
extensionFile=$extensionDir.crx;
manifestFile=$extensionDir/manifest.json;
contextRoot="$(sudo -u "$1" mktemp -d)";
extensionDir="$contextRoot/$extensionName";
keyFile="$extensionDir.pem";
extensionFile="$extensionDir.crx";
manifestFile="$extensionDir/manifest.json";
extensionRoot=/usr/share/brave-extensions;
destination=$extensionRoot/$extensionName.crx;
destination="$extensionRoot/$extensionName.crx";
# Prepare extension
mkdir -p $extensionRoot;
sudo -u $1 unzip $archiveName -d $extensionDir;
sudo -u $1 brave-browser --pack-extension=$extensionDir;
rm $archiveName;
mkdir -p "$extensionRoot";
sudo -u "$1" unzip "$archiveName" -d "$extensionDir";
sudo -u "$1" brave-browser --pack-extension="$extensionDir";
rm "$archiveName";
# Tamper manifest file
manifest="$(cat $manifestFile | jq ". + {key: "'"'"$(openssl rsa -in $keyFile -pubout -outform DER | openssl base64 -A)"'"'"}")";
manifest="$(echo $manifest | jq ".background.persistent = false")";
echo $manifest | sudo -u $1 tee $manifestFile;
manifest="$(cat "$manifestFile" | jq ". + {key: "'"'"$(openssl rsa -in "$keyFile" -pubout -outform DER | openssl base64 -A)"'"'"}")";
manifest="$(echo "$manifest" | jq ".background.persistent = false")";
echo "$manifest" | sudo -u "$1" tee "$manifestFile";
# Pack extension
extensionID=$(openssl rsa -in $keyFile -pubout -outform DER | sha256sum | head -c32 | tr 0-9a-f a-p);
extensionVersion=$(cat $manifestFile | jq -r '.version');
sudo -u $1 brave-browser --pack-extension=$extensionDir --pack-extension-key=$keyFile;
extensionID="$(openssl rsa -in "$keyFile" -pubout -outform DER | sha256sum | head -c32 | tr 0-9a-f a-p)";
extensionVersion="$(cat "$manifestFile" | jq -r '.version')";
sudo -u "$1" brave-browser --pack-extension="$extensionDir" --pack-extension-key="$keyFile";
# Install extension and preinstall it
cp $extensionFile $extensionRoot;
configRoot=/opt/brave.com/brave/extensions/;
rm -rf $contextRoot;
chmod -R a+rx $extensionRoot;
chmod -R u+w $extensionRoot;
mkdir -p $configRoot;
cp "$extensionFile" "$extensionRoot";
configRoot=/opt/brave.com/brave/extensions/
rm -rf "$contextRoot";
chmod -R a+rx "$extensionRoot";
chmod -R u+w "$extensionRoot";
mkdir -p "$configRoot";
{
echo "{";
echo ' "external_crx": "'"$destination"'",';
echo ' "external_version": "'"$extensionVersion"'"';
echo "}";
} | tee $configRoot/$extensionID.json;
} | tee "$configRoot/$extensionID.json";
fi

View file

@ -4,15 +4,15 @@ if [ ! "$UID" -eq 0 ]
then
sudo bash "$BASH_SOURCE";
else
workingDirectory=$(pwd);
contextRoot=$(mktemp -d);
cd $contextRoot;
workingDirectory="$(pwd)";
contextRoot="$(mktemp -d)";
cd "$contextRoot";
curl -fsSL https://raw.githubusercontent.com/nagygergo/jetbrains-toolbox-install/1.1/jetbrains-toolbox.sh \
| bash;
cd $workingDirectory;
rm -rf $contextRoot;
cd "$workingDirectory";
rm -rf "$contextRoot";
{
echo "[Desktop Entry]";

View file

@ -5,21 +5,21 @@ then
sudo bash "$BASH_SOURCE" "$USER";
else
bin=oh-my-posh;
workingDirectory=$(pwd);
contextRoot=$(mktemp -d);
cd $contextRoot;
workingDirectory="$(pwd)";
contextRoot="$(mktemp -d)";
cd "$contextRoot";
wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O $bin;
install $bin /usr/local/bin;
wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O "$bin";
install "$bin" /usr/local/bin;
cd $workingDirectory;
rm -rf $contextRoot;
cd "$workingDirectory";
rm -rf "$contextRoot";
homeDir=$(sudo -u $1 bash -c 'realpath ~');
homeDir="$(sudo -u "$1" bash -c 'realpath ~')";
sudo -u $1 mkdir -p $homeDir/.omp;
sudo -u $1 cp $homeDir/Nextcloud/.omp/manuel.omp.json $homeDir/.omp/manuel.omp.json;
sudo -u "$1" mkdir -p "$homeDir/.omp";
sudo -u "$1" cp "$homeDir/Nextcloud/.omp/manuel.omp.json" "$homeDir/.omp/manuel.omp.json";
echo 'eval "$(oh-my-posh init bash --config ~/.omp/manuel.omp.json)"' \
| sudo -u $1 tee -a $homeDir/.bashrc;
| sudo -u "$1" tee -a "$homeDir/.bashrc";
fi

View file

@ -5,17 +5,17 @@ then
sudo bash "$BASH_SOURCE";
else
apt install -y wget gpg;
keyFile=$(mktemp);
keyFile="$(mktemp)";
wget -qO- https://packages.microsoft.com/keys/microsoft.asc \
| gpg --dearmor > $keyFile;
| gpg --dearmor > "$keyFile";
install -D -o root -g root -m 644 $keyFile /etc/apt/keyrings/packages.microsoft.gpg;
install -D -o root -g root -m 644 "$keyFile" /etc/apt/keyrings/packages.microsoft.gpg;
echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" \
| tee /etc/apt/sources.list.d/vscode.list;
rm -f $keyFile;
rm -f "$keyFile";
apt update;
apt install -y code;

View file

@ -4,9 +4,9 @@ if [ ! "$UID" -eq 0 ]
then
sudo bash "$BASH_SOURCE";
else
workingDirectory=$(pwd);
contextRoot=$(mktemp -d);
cd $contextRoot;
workingDirectory="$(pwd)";
contextRoot="$(mktemp -d)";
cd "$contextRoot";
# Preview from docker container
# container_id="$(docker create woodpeckerci/woodpecker-cli:next)"
@ -19,6 +19,6 @@ else
tar -xvzf woodpecker-cli.tar.gz;
install woodpecker-cli /usr/local/bin;
cd $workingDirectory;
rm -rf $contextRoot;
cd "$workingDirectory";
rm -rf "$contextRoot";
fi

View file

@ -4,16 +4,16 @@ if [ ! "$UID" -eq 0 ]
then
sudo bash "$BASH_SOURCE" "$USER";
else
package=$(mktemp);
wget https://github.com/Yash-Handa/logo-ls/releases/download/v1.3.7/logo-ls_amd64.deb -O $package;
dpkg -i $package;
rm -f $package;
package="$(mktemp)";
wget https://github.com/Yash-Handa/logo-ls/releases/download/v1.3.7/logo-ls_amd64.deb -O "$package";
dpkg -i "$package";
rm -f "$package";
homeDir=$(sudo -u $1 bash -c 'realpath ~');
homeDir="$(sudo -u "$1" bash -c 'realpath ~')";
{
echo "alias ls='logo-ls -D'";
echo "alias ll='ls -al'";
echo "alias l='ls'";
} | sudo -u $1 tee -a $homeDir/.bashrc;
} | sudo -u "$1" tee -a "$homeDir/.bashrc";
fi

View file

@ -4,10 +4,10 @@ if [ ! "$UID" -eq 0 ]
then
sudo bash "$BASH_SOURCE";
else
package=$(mktemp);
wget https://github.com/rclone/rclone/releases/download/v1.60.0/rclone-v1.60.0-linux-amd64.deb -O $package;
dpkg -i $package;
rm -f $package;
package="$(mktemp)";
wget https://github.com/rclone/rclone/releases/download/v1.60.0/rclone-v1.60.0-linux-amd64.deb -O "$package";
dpkg -i "$package";
rm -f "$package";
cp ${BASH_SOURCE%/*}/rclone@.service /etc/systemd/user;
cp "${BASH_SOURCE%/*}/rclone@.service" /etc/systemd/user;
fi

View file

@ -4,13 +4,13 @@ if [ ! "$UID" -eq 0 ]
then
sudo bash "$BASH_SOURCE";
else
workingDirectory=$(pwd);
contextRoot=$(mktemp -d);
cd $contextRoot;
workingDirectory="$(pwd)";
contextRoot="$(mktemp -d)";
cd "$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;
rm -rf $contextRoot;
cd "$workingDirectory";
rm -rf "$contextRoot";
fi