1
0
Fork 0

make it simpler

This commit is contained in:
VirtuBox 2019-09-05 23:19:41 +02:00
parent 18a0c3e8f3
commit 2055e713d6
Signed by: virtubox
GPG Key ID: 22EB296C97BAD476
1 changed files with 23 additions and 17 deletions

View File

@ -1,13 +1,20 @@
#!/usr/bin/env bash
command_exists() {
command -v "$@" > /dev/null 2>&1
}
# if run as root
[ "$(id -u)" = "0" ] && {
if command_exists curl && command_exists git && command_exists lsb_release; then
echo
else
apt-get update -qq
# check if git & curl are installed
[ -z "$(command -v git)" ] && { apt-get -y install git; } >> /dev/null 2>&1
[ -z "$(command -v curl)" ] && { apt-get -y install curl; } >> /dev/null 2>&1
[ -z "$(command -v unzip)" ] && { apt-get -y install unzip; } >> /dev/null 2>&1
[ -e "$(command -v lsb_release)" ] && { apt-get -y install lsb_release; } >> /dev/null 2>&1
fi
[ ! -d "$HOME/.ssh" ] && { mkdir "$HOME/.ssh"; }
# install cht.sh if not already installed
@ -31,39 +38,38 @@
# clone mybashrc or update it
if [ ! -d $HOME/.mybashrc ]; then
git clone --depth=50 https://git.virtubox.net/virtubox/bashrc.git $HOME/.mybashrc
else
if [ ! -d $HOME/.mybashrc/.git ]; then
mkdir $HOME/.mybashrc
wget -O $HOME/.mybashrc/mybashrc https://git.virtubox.net/virtubox/bashrc/raw/branch/master/mybashrc
fi
else
if [ -d $HOME/.mybashrc/.git ]; then
else
git -C $HOME/.mybashrc pull origin master
fi
fi
if [ ! -d $HOME/.history ]; then
mkdir -p $HOME/.history
fi
if [ -f $HOME/.config/htop/htoprc ]; then
cp $HOME/.mybashrc/env/htoprc $HOME/.config/htop/htoprc -f
else
mkdir -p $HOME/.config/htop
cp $HOME/.mybashrc/env/htoprc $HOME/.config/htop/htoprc -f
fi
#if [ -f $HOME/.config/htop/htoprc ]; then
# cp $HOME/.mybashrc/env/htoprc $HOME/.config/htop/htoprc -f
#else
# mkdir -p $HOME/.config/htop
# cp $HOME/.mybashrc/env/htoprc $HOME/.config/htop/htoprc -f
#fi
if [ -f $HOME/.bashrc ]; then
check_mybashrc=$(grep "mybashrc" $HOME/.bashrc)
if [ -z "$check_mybashrc" ]; then
if ! grep -q "mybashrc" $HOME/.bashrc; then
echo ". $HOME/.mybashrc/mybashrc" >> $HOME/.bashrc
fi
else
[ ! -f $HOME/.profile ] && {
wget -O $HOME/.profile https://git.virtubox.net/virtubox/ubuntu-nginx-web-server/raw/branch/master/var/www/.profile
wget -qO $HOME/.profile https://git.virtubox.net/virtubox/ubuntu-nginx-web-server/raw/branch/master/var/www/.profile
}
wget -O $HOME/.bashrc https://git.virtubox.net/virtubox/ubuntu-nginx-web-server/raw/branch/master/var/www/.bashrc
echo ". $HOME/.mybashrc/mybashrc" >> "$HOME/.bashrc"
wget -qO $HOME/.bashrc https://git.virtubox.net/virtubox/ubuntu-nginx-web-server/raw/branch/master/var/www/.bashrc
echo -e "if [ -f $HOME/.mybashrc/mybashrc ]; then\n. $HOME/.mybashrc/mybashrc\nfi" >> "$HOME/.bashrc"
fi
/bin/bash --init-file <(echo 'source ~/.bashrc')
echo -e "#!/bin/bash --init-file\nsource $HOME/.bashrc" > /tmp/init-file
/bin/bash --init-file /tmp/init-file