convert bash to sh

This commit is contained in:
Chris Titus 2024-07-13 21:16:02 -05:00
parent c505afaa47
commit 509514525a
4 changed files with 113 additions and 108 deletions

View File

@ -1,58 +1,60 @@
#!/bin/bash #!/bin/sh
RC='\033[0m'
RC='\e[0m' RED='\033[31m'
RED='\e[31m' YELLOW='\033[33m'
YELLOW='\e[33m' GREEN='\033[32m'
GREEN='\e[32m'
command_exists() { command_exists() {
command -v $1 >/dev/null 2>&1 which $1 >/dev/null 2>&1
} }
checkEnv() { checkEnv() {
## Check for requirements. ## Check for requirements.
REQUIREMENTS='curl groups sudo' REQUIREMENTS='curl groups sudo'
if ! command_exists ${REQUIREMENTS}; then for req in ${REQUIREMENTS}; do
echo -e "${RED}To run me, you need: ${REQUIREMENTS}${RC}" if ! command_exists ${req}; then
exit 1 echo "${RED}To run me, you need: ${REQUIREMENTS}${RC}"
fi exit 1
fi
done
## Check Package Handeler ## Check Package Handler
PACKAGEMANAGER='apt-get dnf pacman zypper' PACKAGEMANAGER='apt-get dnf pacman zypper'
for pgm in ${PACKAGEMANAGER}; do for pgm in ${PACKAGEMANAGER}; do
if command_exists ${pgm}; then if command_exists ${pgm}; then
PACKAGER=${pgm} PACKAGER=${pgm}
echo -e "Using ${pgm}" echo "Using ${pgm}"
break
fi fi
done done
if [ -z "${PACKAGER}" ]; then if [ -z "${PACKAGER}" ]; then
echo -e "${RED}Can't find a supported package manager" echo "${RED}Can't find a supported package manager${RC}"
exit 1 exit 1
fi fi
## Check SuperUser Group ## Check SuperUser Group
SUPERUSERGROUP='wheel sudo root' SUPERUSERGROUP='wheel sudo root'
for sug in ${SUPERUSERGROUP}; do for sug in ${SUPERUSERGROUP}; do
if groups | grep ${sug}; then if groups | grep -q ${sug}; then
SUGROUP=${sug} SUGROUP=${sug}
echo -e "Super user group ${SUGROUP}" echo "Super user group ${SUGROUP}"
break
fi fi
done done
## Check if member of the sudo group. ## Check if member of the sudo group.
if ! groups | grep ${SUGROUP} >/dev/null; then if ! groups | grep -q ${SUGROUP}; then
echo -e "${RED}You need to be a member of the sudo group to run me!" echo "${RED}You need to be a member of the sudo group to run me!${RC}"
exit 1 exit 1
fi fi
DTYPE="unknown" # Default to unknown DTYPE="unknown" # Default to unknown
# Use /etc/os-release for modern distro identification # Use /etc/os-release for modern distro identification
if [ -f /etc/os-release ]; then if [ -f /etc/os-release ]; then
source /etc/os-release . /etc/os-release
DTYPE=$ID DTYPE=$ID
fi fi
} }
setupKitty() { setupKitty() {
@ -71,7 +73,7 @@ setupKitty() {
fi fi
echo "Copy Kitty config files" echo "Copy Kitty config files"
if [ -d "${HOME}/.config/kitty" ]; then if [ -d "${HOME}/.config/kitty" ]; then
cp -r ${HOME}/.config/kitty {HOME}/.config/kitty-bak cp -r ${HOME}/.config/kitty ${HOME}/.config/kitty-bak
fi fi
mkdir -p ${HOME}/.config/kitty/ mkdir -p ${HOME}/.config/kitty/
wget -O ${HOME}/.config/kitty/kitty.conf https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/kitty/kitty.conf wget -O ${HOME}/.config/kitty/kitty.conf https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/kitty/kitty.conf

View File

@ -1,86 +1,88 @@
#!/bin/bash #!/bin/sh
RC='\033[0m'
RC='\e[0m' RED='\033[31m'
RED='\e[31m' YELLOW='\033[33m'
YELLOW='\e[33m' GREEN='\033[32m'
GREEN='\e[32m'
command_exists() { command_exists() {
command -v $1 >/dev/null 2>&1 which "$1" >/dev/null 2>&1
} }
checkEnv() { checkEnv() {
## Check for requirements. ## Check for requirements.
REQUIREMENTS='curl groups sudo' REQUIREMENTS='curl groups sudo'
if ! command_exists ${REQUIREMENTS}; then for req in $REQUIREMENTS; do
echo -e "${RED}To run me, you need: ${REQUIREMENTS}${RC}" if ! command_exists "$req"; then
exit 1 printf "${RED}To run me, you need: %s${RC}\n" "$REQUIREMENTS"
fi exit 1
## Check Package Handeler
PACKAGEMANAGER='apt-get dnf pacman zypper'
for pgm in ${PACKAGEMANAGER}; do
if command_exists ${pgm}; then
PACKAGER=${pgm}
echo -e "Using ${pgm}"
fi fi
done done
if [ -z "${PACKAGER}" ]; then ## Check Package Handler
echo -e "${RED}Can't find a supported package manager" PACKAGEMANAGER='apt-get dnf pacman zypper'
for pgm in $PACKAGEMANAGER; do
if command_exists "$pgm"; then
PACKAGER="$pgm"
printf "Using %s\n" "$pgm"
break
fi
done
if [ -z "$PACKAGER" ]; then
printf "${RED}Can't find a supported package manager${RC}\n"
exit 1 exit 1
fi fi
## Check SuperUser Group ## Check SuperUser Group
SUPERUSERGROUP='wheel sudo root' SUPERUSERGROUP='wheel sudo root'
for sug in ${SUPERUSERGROUP}; do for sug in $SUPERUSERGROUP; do
if groups | grep ${sug}; then if groups | grep -q "$sug"; then
SUGROUP=${sug} SUGROUP="$sug"
echo -e "Super user group ${SUGROUP}" printf "Super user group %s\n" "$SUGROUP"
break
fi fi
done done
## Check if member of the sudo group. ## Check if member of the sudo group.
if ! groups | grep ${SUGROUP} >/dev/null; then if ! groups | grep -q "$SUGROUP"; then
echo -e "${RED}You need to be a member of the sudo group to run me!" printf "${RED}You need to be a member of the sudo group to run me!${RC}\n"
exit 1 exit 1
fi fi
DTYPE="unknown" # Default to unknown DTYPE="unknown" # Default to unknown
# Use /etc/os-release for modern distro identification # Use /etc/os-release for modern distro identification
if [ -f /etc/os-release ]; then if [ -f /etc/os-release ]; then
source /etc/os-release . /etc/os-release
DTYPE=$ID DTYPE="$ID"
fi fi
} }
setupRofi() { setupRofi() {
echo "Install Rofi if not already installed..." echo "Install Rofi if not already installed..."
if ! command_exists rofi; then if ! command_exists rofi; then
case ${PACKAGER} in case "$PACKAGER" in
pacman) pacman)
sudo ${PACKAGER} -S --noconfirm rofi sudo "$PACKAGER" -S --noconfirm rofi
;; ;;
*) *)
sudo ${PACKAGER} install -y rofi sudo "$PACKAGER" install -y rofi
;; ;;
esac esac
else else
echo "Rofi is already installed." echo "Rofi is already installed."
fi fi
echo "Copy Rofi config files" echo "Copy Rofi config files"
if [ -d "${HOME}/.config/rofi" ]; then if [ -d "$HOME/.config/rofi" ]; then
cp -r ${HOME}/.config/rofi ${HOME}/.config/rofi.bak cp -r "$HOME/.config/rofi" "$HOME/.config/rofi.bak"
fi fi
mkdir -p ${HOME}/.config/rofi mkdir -p "$HOME/.config/rofi"
wget -O ${HOME}/.config/rofi/powermenu.sh https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/powermenu.sh wget -O "$HOME/.config/rofi/powermenu.sh" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/powermenu.sh
chmod +x ${HOME}/.config/rofi/powermenu.sh chmod +x "$HOME/.config/rofi/powermenu.sh"
wget -O ${HOME}/.config/rofi/config.rasi https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/config.rasi wget -O "$HOME/.config/rofi/config.rasi" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/config.rasi
mkdir -p ${HOME}/.config/rofi/themes mkdir -p "$HOME/.config/rofi/themes"
wget -O ${HOME}/.config/rofi/themes/nord.rasi https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/themes/nord.rasi wget -O "$HOME/.config/rofi/themes/nord.rasi" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/themes/nord.rasi
wget -O ${HOME}/.config/rofi/themes/sidetab-nord.rasi https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/themes/sidetab-nord.rasi wget -O "$HOME/.config/rofi/themes/sidetab-nord.rasi" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/themes/sidetab-nord.rasi
wget -O ${HOME}/.config/rofi/themes/powermenu.rasi https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/themes/powermenu.rasi wget -O "$HOME/.config/rofi/themes/powermenu.rasi" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/themes/powermenu.rasi
} }
checkEnv checkEnv

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
RC='\e[0m' RC='\e[0m'
RED='\e[31m' RED='\e[31m'
@ -32,8 +32,8 @@ checkEnv() {
fi fi
## Check if the current directory is writable. ## Check if the current directory is writable.
GITPATH="$(dirname "$(realpath "$0")")" GITPATH="$(dirname "$(readlink -f "$0")")"
if [[ ! -w ${GITPATH} ]]; then if [ ! -w ${GITPATH} ]; then
echo -e "${RED}Can't write to ${GITPATH}${RC}" echo -e "${RED}Can't write to ${GITPATH}${RC}"
exit 1 exit 1
fi fi
@ -58,7 +58,7 @@ checkEnv() {
installDepend() { installDepend() {
## Check for dependencies. ## Check for dependencies.
echo -e "${YELLOW}Installing dependencies...${RC}" echo -e "${YELLOW}Installing dependencies...${RC}"
if [[ $PACKAGER == "pacman" ]]; then if [ "$PACKAGER" = "pacman" ]; then
if ! grep -q "^\s*\[multilib\]" /etc/pacman.conf; then if ! grep -q "^\s*\[multilib\]" /etc/pacman.conf; then
echo "[multilib]" | sudo tee -a /etc/pacman.conf echo "[multilib]" | sudo tee -a /etc/pacman.conf
echo "Include = /etc/pacman.d/mirrorlist" | sudo tee -a /etc/pacman.conf echo "Include = /etc/pacman.d/mirrorlist" | sudo tee -a /etc/pacman.conf
@ -88,10 +88,10 @@ lib32-libgpg-error alsa-plugins lib32-alsa-plugins alsa-lib lib32-alsa-lib libjp
sqlite lib32-sqlite libxcomposite lib32-libxcomposite libxinerama lib32-libgcrypt libgcrypt lib32-libxinerama \ sqlite lib32-sqlite libxcomposite lib32-libxcomposite libxinerama lib32-libgcrypt libgcrypt lib32-libxinerama \
ncurses lib32-ncurses ocl-icd lib32-ocl-icd libxslt lib32-libxslt libva lib32-libva gtk3 \ ncurses lib32-ncurses ocl-icd lib32-ocl-icd libxslt lib32-libxslt libva lib32-libva gtk3 \
lib32-gtk3 gst-plugins-base-libs lib32-gst-plugins-base-libs vulkan-icd-loader lib32-vulkan-icd-loader lib32-gtk3 gst-plugins-base-libs lib32-gst-plugins-base-libs vulkan-icd-loader lib32-vulkan-icd-loader
elif [[ $PACKAGER == "apt-get" ]]; then elif [ "$PACKAGER" = "apt-get" ]; then
sudo ${PACKAGER} update sudo ${PACKAGER} update
sudo ${PACKAGER} install -y wine64 wine32 libasound2-plugins:i386 libsdl2-2.0-0:i386 libdbus-1-3:i386 libsqlite3-0:i386 sudo ${PACKAGER} install -y wine64 wine32 libasound2-plugins:i386 libsdl2-2.0-0:i386 libdbus-1-3:i386 libsqlite3-0:i386
elif [[ $PACKAGER == "dnf|zypper" ]]; then elif [ "$PACKAGER" = "dnf" ] || [ "$PACKAGER" = "zypper" ]; then
sudo ${PACKAGER} install -y wine sudo ${PACKAGER} install -y wine
else else
sudo ${PACKAGER} install -y ${DEPENDENCIES} sudo ${PACKAGER} install -y ${DEPENDENCIES}
@ -99,7 +99,7 @@ lib32-gtk3 gst-plugins-base-libs lib32-gst-plugins-base-libs vulkan-icd-loader l
} }
install_additional_dependencies() { install_additional_dependencies() {
case $(command -v apt-get || command -v zypper || command -v dnf || command -v pacman) in case $(which apt-get || which zypper || which dnf || which pacman) in
*apt-get) *apt-get)
version=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://github.com/lutris/lutris | version=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://github.com/lutris/lutris |
grep -v 'beta' | grep -v 'beta' |

View File

@ -1,86 +1,87 @@
#!/bin/bash #!/bin/sh
RC='\033[0m'
RC='\e[0m' RED='\033[31m'
RED='\e[31m' YELLOW='\033[33m'
YELLOW='\e[33m' GREEN='\033[32m'
GREEN='\e[32m'
command_exists() { command_exists() {
command -v $1 >/dev/null 2>&1 which $1 >/dev/null 2>&1
} }
checkEnv() { checkEnv() {
## Check for requirements. ## Check for requirements.
REQUIREMENTS='curl groups sudo' REQUIREMENTS='curl groups sudo'
if ! command_exists ${REQUIREMENTS}; then for req in ${REQUIREMENTS}; do
echo -e "${RED}To run me, you need: ${REQUIREMENTS}${RC}" if ! command_exists ${req}; then
exit 1 printf "${RED}To run me, you need: ${REQUIREMENTS}${RC}\n"
fi exit 1
fi
done
## Check Package Handeler ## Check Package Handler
PACKAGEMANAGER='apt-get dnf pacman zypper' PACKAGEMANAGER='apt-get dnf pacman zypper'
for pgm in ${PACKAGEMANAGER}; do for pgm in ${PACKAGEMANAGER}; do
if command_exists ${pgm}; then if command_exists ${pgm}; then
PACKAGER=${pgm} PACKAGER=${pgm}
echo -e "Using ${pgm}" printf "Using ${pgm}\n"
break
fi fi
done done
if [ -z "${PACKAGER}" ]; then if [ -z "${PACKAGER}" ]; then
echo -e "${RED}Can't find a supported package manager" printf "${RED}Can't find a supported package manager${RC}\n"
exit 1 exit 1
fi fi
## Check SuperUser Group ## Check SuperUser Group
SUPERUSERGROUP='wheel sudo root' SUPERUSERGROUP='wheel sudo root'
for sug in ${SUPERUSERGROUP}; do for sug in ${SUPERUSERGROUP}; do
if groups | grep ${sug}; then if groups | grep ${sug} >/dev/null; then
SUGROUP=${sug} SUGROUP=${sug}
echo -e "Super user group ${SUGROUP}" printf "Super user group ${SUGROUP}\n"
break
fi fi
done done
## Check if member of the sudo group. ## Check if member of the sudo group.
if ! groups | grep ${SUGROUP} >/dev/null; then if ! groups | grep ${SUGROUP} >/dev/null; then
echo -e "${RED}You need to be a member of the sudo group to run me!" printf "${RED}You need to be a member of the sudo group to run me!${RC}\n"
exit 1 exit 1
fi fi
DTYPE="unknown" # Default to unknown DTYPE="unknown" # Default to unknown
# Use /etc/os-release for modern distro identification # Use /etc/os-release for modern distro identification
if [ -f /etc/os-release ]; then if [ -f /etc/os-release ]; then
source /etc/os-release . /etc/os-release
DTYPE=$ID DTYPE=$ID
fi fi
} }
fastUpdate() { fastUpdate() {
case ${PACKAGER} in case ${PACKAGER} in
pacman) pacman)
if ! command_exists yay && ! command_exists paru; then if ! command_exists yay && ! command_exists paru; then
echo "Installing yay as AUR helper..." printf "Installing yay as AUR helper...\n"
sudo ${PACKAGER} --noconfirm -S base-devel sudo ${PACKAGER} --noconfirm -S base-devel
cd /opt && sudo git clone https://aur.archlinux.org/yay-git.git && sudo chown -R ${USER}:${USER} ./yay-git cd /opt && sudo git clone https://aur.archlinux.org/yay-git.git && sudo chown -R ${USER}:${USER} ./yay-git
cd yay-git && makepkg --noconfirm -si cd yay-git && makepkg --noconfirm -si
else else
echo "Aur helper already installed" printf "Aur helper already installed\n"
fi fi
if command_exists yay; then if command_exists yay; then
AUR_HELPER="yay" AUR_HELPER="yay"
elif command_exists paru; then elif command_exists paru; then
AUR_HELPER="paru" AUR_HELPER="paru"
else else
echo "No AUR helper found. Please install yay or paru." printf "No AUR helper found. Please install yay or paru.\n"
exit 1 exit 1
fi fi
${AUR_HELPER} --noconfirm -S rate-mirrors-bin ${AUR_HELPER} --noconfirm -S rate-mirrors-bin
sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
# If for some reason DTYPE is still unknown use always arch so the rate-mirrors does not fail # If for some reason DTYPE is still unknown use always arch so the rate-mirrors does not fail
local dtype_local=${DTYPE} dtype_local=${DTYPE}
if [ ${DTYPE} == "unknown" ]; then if [ "${DTYPE}" = "unknown" ]; then
dtype_local="arch" dtype_local="arch"
fi fi
sudo rate-mirrors --top-mirrors-number-to-retest=5 --disable-comments --save /etc/pacman.d/mirrorlist --allow-root ${dtype_local} sudo rate-mirrors --top-mirrors-number-to-retest=5 --disable-comments --save /etc/pacman.d/mirrorlist --allow-root ${dtype_local}
@ -98,14 +99,14 @@ fastUpdate() {
zypper) zypper)
;; ;;
*) *)
echo -e "${RED}Unsupported package manager: ${PACKAGER}${RC}" printf "${RED}Unsupported package manager: ${PACKAGER}${RC}\n"
exit 1 exit 1
;; ;;
esac esac
} }
updateSystem() { updateSystem() {
echo -e "${GREEN}Updating system${RC}" printf "${GREEN}Updating system${RC}\n"
case ${PACKAGER} in case ${PACKAGER} in
nala) nala)
sudo ${PACKAGER} update -y sudo ${PACKAGER} update -y
@ -127,7 +128,7 @@ updateSystem() {
sudo ${PACKAGER} update -y sudo ${PACKAGER} update -y
;; ;;
*) *)
echo -e "${RED}Unsupported package manager: ${PACKAGER}${RC}" printf "${RED}Unsupported package manager: ${PACKAGER}${RC}\n"
exit 1 exit 1
;; ;;
esac esac