From 857475b3feab781e5a0d5934b193dc3d938777b3 Mon Sep 17 00:00:00 2001 From: pvincent Date: Fri, 13 Nov 2020 17:34:53 +0400 Subject: [PATCH] install host|containers --- install.sh | 122 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 85 insertions(+), 37 deletions(-) diff --git a/install.sh b/install.sh index 762d921..85683ed 100755 --- a/install.sh +++ b/install.sh @@ -1,43 +1,67 @@ #!/bin/bash -[ `id -u` -ne 0 ] && echo 'root privilege required' && exit 1 BASEDIR=$PWD -if [[ ! $BASEDIR == '/opt/debian-bash' ]]; then - # download and filfull /opt/debian-bash, then run it from folder - - rm -rf /opt/debian-bash - TEMP=`mktemp -d` - cd $TEMP - echo $TEMP - wget https://git.artcode.re/pvincent/debian-bash/archive/master.tar.gz - tar -xzf master.tar.gz - mv debian-bash /opt/ - cd /opt/debian-bash - ./install.sh - rm -rf $TEMP - exit 0 - -else - - #remove /etc/skel/.bashrc - rm /etc/skel/.bashrc - - ORIGINAL="ORIGINAL" - declare -a arr=(/etc/bash.bashrc /etc/inputrc /etc/vim/vimrc) - - for i in "${arr[@]}" - do - if [ ! -f "$i.$ORIGINAL" ]; then - - echo "$i needs installation $(basename $i)" - mv "$i" "$i.$ORIGINAL" - ln -s "$BASEDIR/$(basename $i)" "$i" - else - echo "$i" already overriden - fi - done +function usage { + echo 'usage: --host | --containers | --full' + exit -1 +} + +function install_host { + echo "install host" + echo -------------- + + [ `id -u` -ne 0 ] && echo 'root privilege required' && exit 1 + + if [[ ! $BASEDIR == '/opt/debian-bash' ]]; then + # download and filfull /opt/debian-bash, then run it from folder + + rm -rf /opt/debian-bash + TEMP=`mktemp -d` + cd $TEMP + echo $TEMP + wget https://git.artcode.re/pvincent/debian-bash/archive/master.tar.gz + tar -xzf master.tar.gz + mv debian-bash /opt/ + cd /opt/debian-bash + ./install.sh -- + rm -rf $TEMP + exit 0 + + else + + #remove /etc/skel/.bashrc + rm /etc/skel/.bashrc + + ORIGINAL="ORIGINAL" + declare -a arr=(/etc/bash.bashrc /etc/inputrc /etc/vim/vimrc) + + for i in "${arr[@]}" + do + if [ ! -f "$i.$ORIGINAL" ]; then + + echo "$i needs installation $(basename $i)" + mv "$i" "$i.$ORIGINAL" + ln -s "$BASEDIR/$(basename $i)" "$i" + else + echo "$i" already overriden + fi + done + + + source /etc/bash.bashrc + fi + + + + + +} + +function install_containers { + echo "install containers" + echo -------------------- # install inside active LXC containers if [[ -f '/snap/bin/lxc' ]]; then @@ -48,5 +72,29 @@ else done fi - source /etc/bash.bashrc -fi +} + +function install_one_container { + echo "install container " + echo ------------------------- +} + +PARAM1=$1 + +case $PARAM1 in + "--host") + install_host + ;; + "--containers") + install_containers + ;; + "--full") + install_host + install_containers + ;; + *) + usage + ;; +esac + +