version 1 of setup env script

This commit is contained in:
viktorbarzin 2020-08-23 14:48:11 +01:00
parent ef54fde4de
commit 2a05b8e7e2

View file

@ -1,41 +1,36 @@
#!/bin/bash
echo "Enter root password:"
read -s password
set -e
# Get packet manager
declare -A osInfo;
osInfo[/etc/redhat-release]=dnf
osInfo[/etc/arch-release]=pacman
osInfo[/etc/gentoo-release]=emerge
osInfo[/etc/SuSE-release]=zypp
osInfo[/etc/debian_version]=apt
# for f in "${!osInfo[@]}" # bash version
for f in "${(@k)osInfo}" # zsh version
do
if [[ -f $f ]];then
pm=${osInfo[$f]}
fi
done
if [[ "$pm" == "apt" ]]; then
sudo $pm update
if [ -x "$(command -v apk)" ]; then pm=apk
elif [ -x "$(command -v apt)" ]; then pm="apt"
elif [ -x "$(command -v dnf)" ]; then pm="dnf"
elif [ -x "$(command -v zypper)" ];then pm="zypper"
else echo "FAILED TO INSTALL PACKAGE: Package manager not found. You must manually install: zsh tmux wget"
fi
# Install zsh
sudo $pm install -y zsh tmux wget && \
if which zsh 2>/dev/null > /dev/null && which tmux 2>/dev/null >/dev/null && which wget 2>/dev/null >/dev/null; then
echo "All needed packages are installed. Skipping install step"
else
echo "Installing zsh, tmux and wget..."
sudo $pm install -y zsh tmux wget
fi
# Setup oh-my-zsh
wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh && chmod +x install.sh && echo "$password" | ./install.sh && \
wget -O /tmp/install.sh https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh
chmod +x /tmp/install.sh
set +e
echo "exit" | /tmp/install.sh
set -e
rm /tmp/install.sh
# Setup zsh config files
wget -O ~/.zshrc https://raw.githubusercontent.com/ViktorBarzin/dot_files/master/.zshrc && \
wget -O ~/.bash_aliases https://raw.githubusercontent.com/ViktorBarzin/dot_files/master/.bash_aliases && \
wget -O ~/.zshenv https://raw.githubusercontent.com/ViktorBarzin/dot_files/master/.zshenv && \
# Setup tmux
bash -c "cd ~ && git clone https://github.com/gpakosz/.tmux.git && ln -s -f .tmux/.tmux.conf && cp .tmux/.tmux.conf.local ."
@ -45,6 +40,7 @@ wget -O ~/.tmux.conf.local https://raw.githubusercontent.com/ViktorBarzin/dot_fi
# git clone https://github.com/agkozak/zsh-z $ZSH_CUSTOM/plugins/zsh-z && \
git clone https://github.com/agkozak/zsh-z ~/.oh-my-zsh/plugins/zsh-z && \
echo '
___ _ _ ___ ___ ___ ___ ___
/ __| | | |/ __/ __/ _ \/ __/ __|
\__ \ |_| | (_| (_| __/\__ \__ \
@ -52,5 +48,5 @@ git clone https://github.com/agkozak/zsh-z ~/.oh-my-zsh/plugins/zsh-z && \
' && \
echo 'Restart your shell to apply changes'
echo ' Run tmux to enter your newly setup environment!'