From ca7d893784e7a1a6b17af37f66ced74e4861d251 Mon Sep 17 00:00:00 2001 From: Sonny Date: Sat, 17 Jun 2017 21:46:37 +0200 Subject: [PATCH] Install without confirmation --- scripts/create_container | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/scripts/create_container b/scripts/create_container index 40f523a..a7215d7 100755 --- a/scripts/create_container +++ b/scripts/create_container @@ -10,6 +10,17 @@ function create_container { echo -n "Enter (private) ssh key for git (absolute path): " read -e KEY + echo -n "Start a ssh server? [y/n]: " + read SSH_SERVER + + if [ "$SSH_SERVER" == "y" ];then + echo -n "Enter ssh listening port: " + read PORT + fi + + echo -n "Add dotfiles? [y/n]: " + read DOTFILES + echo "Creating container.." debootstrap $CHANNEL $CONTAINER_PATH mkdir $CONTAINER_PATH/root/.bin/ @@ -18,29 +29,28 @@ function create_container { mkdir $CONTAINER_PATH/root/.ssh cp $KEY $KEY.pub $CONTAINER_PATH/root/.ssh/ - echo -n "Start a ssh server? [y/n]: " - read SSH_SERVER if [ "$SSH_SERVER" == "y" ] ;then - systemd-nspawn -D $CONTAINER_PATH apt-get install ssh - add_ssh $CONTAINER_PATH + systemd-nspawn -D $CONTAINER_PATH apt-get -y install ssh + add_ssh $CONTAINER_PATH $PORT elif [ -z "$SSH_SERVER" ] ;then echo "Not creating a ssh server" fi echo "Installing vim & git" - systemd-nspawn -D $CONTAINER_PATH apt-get install vim git + systemd-nspawn -D $CONTAINER_PATH apt-get -y install vim git echo "Starting container first time, enter root pass" systemd-nspawn -D $CONTAINER_PATH passwd - dotfiles $CONTAINER_PATH + if [ "$DOTFILES" == "y" ] ;then + dotfiles $CONTAINER_PATH + fi } function add_ssh { CONTAINER_PATH=$1 - echo -n "Enter ssh listening port: " - read PORT + PORT=$2 echo "Editing ssh config" sed -i 's/^#Port .*/Port '"$PORT"'/' $CONTAINER_PATH/etc/ssh/sshd_config @@ -50,15 +60,9 @@ function add_ssh { } function dotfiles { - echo -n "Add dotfiles? [y/n]: " - read DOTFILES - - if [ "$DOTFILES" == "y" ] ;then - systemd-nspawn -D $1 git clone https://www.github.com/SonnyBA/dotfiles.git $1/root/dotfiles - systemd-nspawn -D $1 $1/root/dotfiles/initialize_script - elif [ -z "$SSH_SERVER" ] ;then - echo "Not cloning anything" - fi + CONTAINER_PATH=$1 + systemd-nspawn -D $1 git clone https://www.github.com/SonnyBA/dotfiles.git $1/root/dotfiles + systemd-nspawn -D $1 $1/root/dotfiles/initialize_script } create_container