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): "
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
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
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
elif [ -z "$SSH_SERVER" ] ;then
echo "Not cloning anything"
fi
}
create_container