Install without confirmation

This commit is contained in:
Sonny 2017-06-17 21:46:37 +02:00
parent aaeedbe60c
commit ca7d893784

View file

@ -10,6 +10,17 @@ function create_container {
echo -n "Enter (private) ssh key for git (absolute path): " echo -n "Enter (private) ssh key for git (absolute path): "
read -e KEY 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.." echo "Creating container.."
debootstrap $CHANNEL $CONTAINER_PATH debootstrap $CHANNEL $CONTAINER_PATH
mkdir $CONTAINER_PATH/root/.bin/ mkdir $CONTAINER_PATH/root/.bin/
@ -18,29 +29,28 @@ function create_container {
mkdir $CONTAINER_PATH/root/.ssh mkdir $CONTAINER_PATH/root/.ssh
cp $KEY $KEY.pub $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 if [ "$SSH_SERVER" == "y" ] ;then
systemd-nspawn -D $CONTAINER_PATH apt-get install ssh systemd-nspawn -D $CONTAINER_PATH apt-get -y install ssh
add_ssh $CONTAINER_PATH add_ssh $CONTAINER_PATH $PORT
elif [ -z "$SSH_SERVER" ] ;then elif [ -z "$SSH_SERVER" ] ;then
echo "Not creating a ssh server" echo "Not creating a ssh server"
fi fi
echo "Installing vim & git" 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" echo "Starting container first time, enter root pass"
systemd-nspawn -D $CONTAINER_PATH passwd systemd-nspawn -D $CONTAINER_PATH passwd
if [ "$DOTFILES" == "y" ] ;then
dotfiles $CONTAINER_PATH dotfiles $CONTAINER_PATH
fi
} }
function add_ssh { function add_ssh {
CONTAINER_PATH=$1 CONTAINER_PATH=$1
echo -n "Enter ssh listening port: " PORT=$2
read PORT
echo "Editing ssh config" echo "Editing ssh config"
sed -i 's/^#Port .*/Port '"$PORT"'/' $CONTAINER_PATH/etc/ssh/sshd_config sed -i 's/^#Port .*/Port '"$PORT"'/' $CONTAINER_PATH/etc/ssh/sshd_config
@ -50,15 +60,9 @@ function add_ssh {
} }
function dotfiles { function dotfiles {
echo -n "Add dotfiles? [y/n]: " CONTAINER_PATH=$1
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 git clone https://www.github.com/SonnyBA/dotfiles.git $1/root/dotfiles
systemd-nspawn -D $1 $1/root/dotfiles/initialize_script systemd-nspawn -D $1 $1/root/dotfiles/initialize_script
elif [ -z "$SSH_SERVER" ] ;then
echo "Not cloning anything"
fi
} }
create_container create_container