diff --git a/scripts/setup.sh b/scripts/setup.sh index 6e0dbc2..9772388 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -1,11 +1,14 @@ -#!/bin/sh +#!/bin/bash -install_package() { - /usr/bin/apt install $* -} +set -e + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +# Load default shell scripts +. $SCRIPT_DIR/../sh/load.sh update_default_shell() { - /usr/sbin/usermod -s /usr/bin/zsh $1 + /usr/sbin/usermod -sf /usr/bin/zsh $1 } install_shell_config() { @@ -22,4 +25,7 @@ install_shell_config /home/coby/.zshrc # Replace old ssh server config rm /etc/ssh/sshd_config -ln -s /etc/toolkit/sshd/sshd_config /etc/ssh/. +ln -sf /etc/toolkit/sshd/sshd_config /etc/ssh/. + +# Pull submodules +. $SCRIPT_DIR/update.sh diff --git a/scripts/update.sh b/scripts/update.sh index 2894f27..be2756b 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash git reset --hard git pull diff --git a/sh/custom-scripts/pkg-mgr.sh b/sh/custom-scripts/pkg-mgr.sh new file mode 100755 index 0000000..b1ca58a --- /dev/null +++ b/sh/custom-scripts/pkg-mgr.sh @@ -0,0 +1,22 @@ +declare -A osInfo; +osInfo[/etc/redhat-release]=yum +osInfo[/etc/arch-release]=pacman +osInfo[/etc/gentoo-release]=emerge +osInfo[/etc/SuSE-release]=zypp +osInfo[/etc/debian_version]=apt-get +osInfo[/etc/alpine-release]=apk + +for key val in "${(@kv)osInfo}"; do + if [[ -f $key ]];then + PACKAGE_MANAGER=$val + fi +done + +install_package() { +if [ "$PACKAGE_MANAGER" == "yum" ]; then yum install -y $1 +elif [ "$PACKAGE_MANAGER" == "pacman" ]; then pacman -S --noconfirm $1 +elif [ "$PACKAGE_MANAGER" == "emerge" ]; then emerge $1 +elif [ "$PACKAGE_MANAGER" == "zypp" ]; then zypper install $1 +elif [ "$PACKAGE_MANAGER" == "apt-get" ]; then apt-get install -y $1 +elif [ "$PACKAGE_MANAGER" == "apk" ]; then apk add $1; fi +}