forked from extern/nix-config
Quote all variables in shell scripts
Not quoting variables in shell scripts is a security vulnerability. See: https://unix.stackexchange.com/a/171347/96035
This commit is contained in:
parent
7bc7645094
commit
7873f9deeb
@ -18,7 +18,7 @@ if [ "$#" -ne 2 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Raise an error if the distro isn't either arch or fedora
|
# Raise an error if the distro isn't either arch or fedora
|
||||||
if ! [ $1 == "arch" ] && ! [ $1 == "fedora" ]; then
|
if ! [ "$1" == "arch" ] && ! [ "$1" == "fedora" ]; then
|
||||||
echo 'Error: distro must either be "arch" or "fedora"'
|
echo 'Error: distro must either be "arch" or "fedora"'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -26,20 +26,20 @@ fi
|
|||||||
# Install common packages if tig isn't found (one of the common packages)
|
# Install common packages if tig isn't found (one of the common packages)
|
||||||
if ! hash tig 2>/dev/null; then
|
if ! hash tig 2>/dev/null; then
|
||||||
echo 'Installing common packages...'
|
echo 'Installing common packages...'
|
||||||
if [ $1 == "arch" ]; then sudo pacman -Syu --needed --noconfirm - < ./packages/arch/common; fi
|
if [ "$1" == "arch" ]; then sudo pacman -Syu --needed --noconfirm - < ./packages/arch/common; fi
|
||||||
if [ $1 == "fedora" ]; then sudo dnf install $(cat ./packages/fedora/common) --assumeyes; fi
|
if [ "$1" == "fedora" ]; then sudo dnf install $(cat ./packages/fedora/common) --assumeyes; fi
|
||||||
|
|
||||||
echo 'Stowing common dotfiles...'
|
echo 'Stowing common dotfiles...'
|
||||||
stow -S common --dir=dots --target=$HOME --no-folding --verbose=2
|
stow -S common --dir=dots --target="$HOME" --no-folding --verbose=2
|
||||||
|
|
||||||
echo 'Configuring common packages...'
|
echo 'Configuring common packages...'
|
||||||
sh ./scripts/006-common
|
sh ./scripts/006-common
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If Arch Linux
|
# If Arch Linux
|
||||||
if [ $1 == "arch" ]; then
|
if [ "$1" == "arch" ]; then
|
||||||
# Raise an error if given an invalid environment
|
# Raise an error if given an invalid environment
|
||||||
if ! [ $2 == "plasma" ] && ! [ $2 == "bspwm" ]; then
|
if ! [ "$2" == "plasma" ] && ! [ "$2" == "bspwm" ]; then
|
||||||
echo 'Invalid environment specified. Must be either "plasma" or "bspwm"'
|
echo 'Invalid environment specified. Must be either "plasma" or "bspwm"'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -55,7 +55,7 @@ if [ $1 == "arch" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Install plasma
|
# Install plasma
|
||||||
if [ $2 == "plasma" ]; then
|
if [ "$2" == "plasma" ]; then
|
||||||
echo 'Installing plasma packages...'
|
echo 'Installing plasma packages...'
|
||||||
sudo pacman -Syu --needed --noconfirm --ignore discover - < ./packages/arch/plasma
|
sudo pacman -Syu --needed --noconfirm --ignore discover - < ./packages/arch/plasma
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ if [ $1 == "arch" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Install bspwm
|
# Install bspwm
|
||||||
if [ $2 == "bspwm" ]; then
|
if [ "$2" == "bspwm" ]; then
|
||||||
echo 'Installing bspwm packages...'
|
echo 'Installing bspwm packages...'
|
||||||
sudo pacman -Syu --needed --noconfirm - < ./packages/arch/bspwm
|
sudo pacman -Syu --needed --noconfirm - < ./packages/arch/bspwm
|
||||||
|
|
||||||
@ -71,22 +71,22 @@ if [ $1 == "arch" ]; then
|
|||||||
yay -S polybar rtv shotgun launch-cmd
|
yay -S polybar rtv shotgun launch-cmd
|
||||||
|
|
||||||
echo 'Stowing bspwm dotfiles...'
|
echo 'Stowing bspwm dotfiles...'
|
||||||
stow -S bspwm --dir=dots --target=$HOME --no-folding --verbose=2
|
stow -S bspwm --dir=dots --target="$HOME" --no-folding --verbose=2
|
||||||
|
|
||||||
echo 'Bspwm installed and configured. Now startx.'
|
echo 'Bspwm installed and configured. Now startx.'
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If Fedora
|
# If Fedora
|
||||||
if [ $1 == "fedora" ]; then
|
if [ "$1" == "fedora" ]; then
|
||||||
# Raise an error if given an invalid environment
|
# Raise an error if given an invalid environment
|
||||||
if ! [ $2 == "gnome" ] && ! [ $2 == "xfce" ]; then
|
if ! [ "$2" == "gnome" ] && ! [ "$2" == "xfce" ]; then
|
||||||
echo 'Invalid environment specified. Must be either "gnome" or "xfce"'
|
echo 'Invalid environment specified. Must be either "gnome" or "xfce"'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install gnome packages if requested
|
# Install gnome packages if requested
|
||||||
if [ $2 == "gnome" ]; then
|
if [ "$2" == "gnome" ]; then
|
||||||
echo 'Installing gnome packages...'
|
echo 'Installing gnome packages...'
|
||||||
sudo dnf install $(cat ./packages/fedora/gnome) --assumeyes
|
sudo dnf install $(cat ./packages/fedora/gnome) --assumeyes
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ if [ $1 == "fedora" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Install xfce packages if requested
|
# Install xfce packages if requested
|
||||||
if [ $2 == "xfce" ]; then
|
if [ "$2" == "xfce" ]; then
|
||||||
echo 'Installing xfce packages...'
|
echo 'Installing xfce packages...'
|
||||||
sudo dnf install $(cat ./packages/fedora/xfce) --assumeyes
|
sudo dnf install $(cat ./packages/fedora/xfce) --assumeyes
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ sed -i '/Color/s/^#//g' /etc/pacman.conf
|
|||||||
echo "%wheel ALL=(ALL) ALL" >> /etc/sudoers
|
echo "%wheel ALL=(ALL) ALL" >> /etc/sudoers
|
||||||
|
|
||||||
# Create a new user account with sudo privileges and the fish shell.
|
# Create a new user account with sudo privileges and the fish shell.
|
||||||
arch-chroot /mnt useradd -m -g users -G wheel -s /usr/bin/fish $USERNAME
|
arch-chroot /mnt useradd -m -g users -G wheel -s /usr/bin/fish "$USERNAME"
|
||||||
|
|
||||||
# Then, set the password equal to the username (change this later).
|
# Then, set the password equal to the username (change this later).
|
||||||
echo "$USERNAME:$USERNAME" | chpasswd
|
echo "$USERNAME:$USERNAME" | chpasswd
|
||||||
|
Loading…
Reference in New Issue
Block a user