mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-22 05:12:27 +00:00
convert bash to sh
This commit is contained in:
parent
c505afaa47
commit
509514525a
|
@ -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() {
|
||||
|
@ -71,7 +73,7 @@ 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
|
||||
|
@ -79,4 +81,4 @@ setupKitty() {
|
|||
}
|
||||
|
||||
checkEnv
|
||||
setupKitty
|
||||
setupKitty
|
|
@ -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
|
||||
|
||||
## 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}"
|
||||
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
|
||||
|
||||
if [ -z "${PACKAGER}" ]; then
|
||||
echo -e "${RED}Can't find a supported package manager"
|
||||
## Check Package Handler
|
||||
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
|
||||
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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
RC='\e[0m'
|
||||
RED='\e[31m'
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 \
|
||||
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}
|
||||
|
@ -99,7 +99,7 @@ lib32-gtk3 gst-plugins-base-libs lib32-gst-plugins-base-libs vulkan-icd-loader l
|
|||
}
|
||||
|
||||
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' |
|
||||
|
|
|
@ -1,86 +1,87 @@
|
|||
#!/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: ${REQUIREMENTS}${RC}\n"
|
||||
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}"
|
||||
printf "Using ${pgm}\n"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
## Check SuperUser Group
|
||||
SUPERUSERGROUP='wheel sudo root'
|
||||
for sug in ${SUPERUSERGROUP}; do
|
||||
if groups | grep ${sug}; then
|
||||
if groups | grep ${sug} >/dev/null; then
|
||||
SUGROUP=${sug}
|
||||
echo -e "Super user group ${SUGROUP}"
|
||||
printf "Super user group ${SUGROUP}\n"
|
||||
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!"
|
||||
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
|
||||
. /etc/os-release
|
||||
DTYPE=$ID
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
fastUpdate() {
|
||||
case ${PACKAGER} in
|
||||
pacman)
|
||||
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
|
||||
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
|
||||
else
|
||||
echo "Aur helper already installed"
|
||||
printf "Aur helper already installed\n"
|
||||
fi
|
||||
if command_exists yay; then
|
||||
AUR_HELPER="yay"
|
||||
elif command_exists paru; then
|
||||
AUR_HELPER="paru"
|
||||
else
|
||||
echo "No AUR helper found. Please install yay or paru."
|
||||
printf "No AUR helper found. Please install yay or paru.\n"
|
||||
exit 1
|
||||
fi
|
||||
${AUR_HELPER} --noconfirm -S rate-mirrors-bin
|
||||
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
|
||||
local dtype_local=${DTYPE}
|
||||
if [ ${DTYPE} == "unknown" ]; then
|
||||
dtype_local=${DTYPE}
|
||||
if [ "${DTYPE}" = "unknown" ]; then
|
||||
dtype_local="arch"
|
||||
fi
|
||||
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)
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Unsupported package manager: ${PACKAGER}${RC}"
|
||||
printf "${RED}Unsupported package manager: ${PACKAGER}${RC}\n"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
updateSystem() {
|
||||
echo -e "${GREEN}Updating system${RC}"
|
||||
printf "${GREEN}Updating system${RC}\n"
|
||||
case ${PACKAGER} in
|
||||
nala)
|
||||
sudo ${PACKAGER} update -y
|
||||
|
@ -127,7 +128,7 @@ updateSystem() {
|
|||
sudo ${PACKAGER} update -y
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Unsupported package manager: ${PACKAGER}${RC}"
|
||||
printf "${RED}Unsupported package manager: ${PACKAGER}${RC}\n"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
@ -135,4 +136,4 @@ updateSystem() {
|
|||
|
||||
checkEnv
|
||||
fastUpdate
|
||||
updateSystem
|
||||
updateSystem
|
Loading…
Reference in New Issue
Block a user