Skip to content

Commit

Permalink
convert bash to sh
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisTitusTech committed Jul 14, 2024
1 parent c505afa commit 5095145
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 106 deletions.
54 changes: 28 additions & 26 deletions src/commands/kitty-setup.sh
Original file line number Diff line number Diff line change
@@ -1,58 +1,60 @@
#!/bin/bash

RC='\e[0m'
RED='\e[31m'
YELLOW='\e[33m'
GREEN='\e[32m'
#!/bin/sh
RC='\033[0m'
RED='\033[31m'
YELLOW='\033[33m'
GREEN='\033[32m'

command_exists() {
command -v $1 >/dev/null 2>&1
which $1 >/dev/null 2>&1
}

checkEnv() {
## Check for requirements.
REQUIREMENTS='curl groups sudo'
if ! command_exists ${REQUIREMENTS}; then
echo -e "${RED}To run me, you need: ${REQUIREMENTS}${RC}"
exit 1
fi
for req in ${REQUIREMENTS}; do
if ! command_exists ${req}; then
echo "${RED}To run me, you need: ${REQUIREMENTS}${RC}"
exit 1
fi
done

## Check Package Handeler
## Check Package Handler
PACKAGEMANAGER='apt-get dnf pacman zypper'
for pgm in ${PACKAGEMANAGER}; do
if command_exists ${pgm}; then
PACKAGER=${pgm}
echo -e "Using ${pgm}"
echo "Using ${pgm}"
break
fi
done

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
fi

## Check SuperUser Group
SUPERUSERGROUP='wheel sudo root'
for sug in ${SUPERUSERGROUP}; do
if groups | grep ${sug}; then
if groups | grep -q ${sug}; then
SUGROUP=${sug}
echo -e "Super user group ${SUGROUP}"
echo "Super user group ${SUGROUP}"
break
fi
done

## Check if member of the sudo group.
if ! groups | grep ${SUGROUP} >/dev/null; then
echo -e "${RED}You need to be a member of the sudo group to run me!"
if ! groups | grep -q ${SUGROUP}; then
echo "${RED}You need to be a member of the sudo group to run me!${RC}"
exit 1
fi


DTYPE="unknown" # Default to unknown
# Use /etc/os-release for modern distro identification
if [ -f /etc/os-release ]; then
source /etc/os-release
DTYPE=$ID
fi
# Use /etc/os-release for modern distro identification
if [ -f /etc/os-release ]; then
. /etc/os-release
DTYPE=$ID
fi
}

setupKitty() {
Expand All @@ -71,12 +73,12 @@ setupKitty() {
fi
echo "Copy Kitty config files"
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
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/nord.conf https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/kitty/nord.conf
}

checkEnv
setupKitty
setupKitty
88 changes: 45 additions & 43 deletions src/commands/rofi-setup.sh
Original file line number Diff line number Diff line change
@@ -1,86 +1,88 @@
#!/bin/bash

RC='\e[0m'
RED='\e[31m'
YELLOW='\e[33m'
GREEN='\e[32m'
#!/bin/sh
RC='\033[0m'
RED='\033[31m'
YELLOW='\033[33m'
GREEN='\033[32m'

command_exists() {
command -v $1 >/dev/null 2>&1
which "$1" >/dev/null 2>&1
}

checkEnv() {
## Check for requirements.
REQUIREMENTS='curl groups sudo'
if ! command_exists ${REQUIREMENTS}; then
echo -e "${RED}To run me, you need: ${REQUIREMENTS}${RC}"
exit 1
fi
for req in $REQUIREMENTS; do
if ! command_exists "$req"; then
printf "${RED}To run me, you need: %s${RC}\n" "$REQUIREMENTS"
exit 1
fi
done

## Check Package Handeler
## Check Package Handler
PACKAGEMANAGER='apt-get dnf pacman zypper'
for pgm in ${PACKAGEMANAGER}; do
if command_exists ${pgm}; then
PACKAGER=${pgm}
echo -e "Using ${pgm}"
for pgm in $PACKAGEMANAGER; do
if command_exists "$pgm"; then
PACKAGER="$pgm"
printf "Using %s\n" "$pgm"
break
fi
done

if [ -z "${PACKAGER}" ]; then
echo -e "${RED}Can't find a supported package manager"
if [ -z "$PACKAGER" ]; then
printf "${RED}Can't find a supported package manager${RC}\n"
exit 1
fi

## Check SuperUser Group
SUPERUSERGROUP='wheel sudo root'
for sug in ${SUPERUSERGROUP}; do
if groups | grep ${sug}; then
SUGROUP=${sug}
echo -e "Super user group ${SUGROUP}"
for sug in $SUPERUSERGROUP; do
if groups | grep -q "$sug"; then
SUGROUP="$sug"
printf "Super user group %s\n" "$SUGROUP"
break
fi
done

## Check if member of the sudo group.
if ! groups | grep ${SUGROUP} >/dev/null; then
echo -e "${RED}You need to be a member of the sudo group to run me!"
if ! groups | grep -q "$SUGROUP"; then
printf "${RED}You need to be a member of the sudo group to run me!${RC}\n"
exit 1
fi


DTYPE="unknown" # Default to unknown
# Use /etc/os-release for modern distro identification
if [ -f /etc/os-release ]; then
source /etc/os-release
DTYPE=$ID
fi
# Use /etc/os-release for modern distro identification
if [ -f /etc/os-release ]; then
. /etc/os-release
DTYPE="$ID"
fi
}

setupRofi() {
echo "Install Rofi if not already installed..."
if ! command_exists rofi; then
case ${PACKAGER} in
case "$PACKAGER" in
pacman)
sudo ${PACKAGER} -S --noconfirm rofi
sudo "$PACKAGER" -S --noconfirm rofi
;;
*)
sudo ${PACKAGER} install -y rofi
sudo "$PACKAGER" install -y rofi
;;
esac
else
echo "Rofi is already installed."
fi
echo "Copy Rofi config files"
if [ -d "${HOME}/.config/rofi" ]; then
cp -r ${HOME}/.config/rofi ${HOME}/.config/rofi.bak
if [ -d "$HOME/.config/rofi" ]; then
cp -r "$HOME/.config/rofi" "$HOME/.config/rofi.bak"
fi
mkdir -p ${HOME}/.config/rofi
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
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
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/powermenu.rasi https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/themes/powermenu.rasi
mkdir -p "$HOME/.config/rofi"
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"
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"
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/powermenu.rasi" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/themes/powermenu.rasi
}

checkEnv
Expand Down
14 changes: 7 additions & 7 deletions src/commands/system-setup/2-gaming-setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

RC='\e[0m'
RED='\e[31m'
Expand Down Expand Up @@ -32,8 +32,8 @@ checkEnv() {
fi

## Check if the current directory is writable.
GITPATH="$(dirname "$(realpath "$0")")"
if [[ ! -w ${GITPATH} ]]; then
GITPATH="$(dirname "$(readlink -f "$0")")"
if [ ! -w ${GITPATH} ]; then
echo -e "${RED}Can't write to ${GITPATH}${RC}"
exit 1
fi
Expand All @@ -58,7 +58,7 @@ checkEnv() {
installDepend() {
## Check for dependencies.
echo -e "${YELLOW}Installing dependencies...${RC}"
if [[ $PACKAGER == "pacman" ]]; then
if [ "$PACKAGER" = "pacman" ]; then
if ! grep -q "^\s*\[multilib\]" /etc/pacman.conf; then
echo "[multilib]" | sudo tee -a /etc/pacman.conf
echo "Include = /etc/pacman.d/mirrorlist" | sudo tee -a /etc/pacman.conf
Expand Down Expand Up @@ -88,18 +88,18 @@ 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 \
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
elif [[ $PACKAGER == "apt-get" ]]; then
elif [ "$PACKAGER" = "apt-get" ]; then
sudo ${PACKAGER} update
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
else
sudo ${PACKAGER} install -y ${DEPENDENCIES}
fi
}

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)
version=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://github.com/lutris/lutris |
grep -v 'beta' |
Expand Down
Loading

0 comments on commit 5095145

Please sign in to comment.