Add deploy.sh
This commit is contained in:
parent
f16ac53c3c
commit
89a8647656
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
function find_package_manager() {
|
||||
hash pacman && echo pacman && return 0
|
||||
hash apt-get && echo apt-get && return 0
|
||||
hash apk && echo apk && return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
function install_package() {
|
||||
package_manager=$(find_package_manager)
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo -e "\033[38;5;1mCould not find package manager" >&2
|
||||
exit
|
||||
fi
|
||||
case package_manager in
|
||||
pacman)
|
||||
sudo pacman -S $*
|
||||
;;
|
||||
apt-get)
|
||||
sudo apt-get install $*
|
||||
;;
|
||||
apk)
|
||||
sudo apk add $*
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function check_and_install() {
|
||||
if hash $1 &> /dev/null; then
|
||||
echo -e "\033[38;5;2m$1 is already installed."
|
||||
else
|
||||
echo -e "\033[38;5;2mInstalling $1."
|
||||
if install_package $1; then
|
||||
echo -e "\033[38;5;2m$1 installed."
|
||||
else
|
||||
echo -e "\033[38;5;1mInstalling $1 failed." >&2
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
package_manager=$(find_package_manager)
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo -e "\033[38;5;1mCould not find package manager" >&2
|
||||
else
|
||||
echo -e "\033[38;5;2mPackage manager: $package_manager"
|
||||
fi
|
||||
|
||||
|
||||
check_and_install stow
|
||||
check_and_install bash
|
||||
check_and_install tmux
|
||||
check_and_install vim
|
Loading…
Reference in New Issue