From c146a0ea62b03d9650bdb43986acb0afdf2ecba0 Mon Sep 17 00:00:00 2001 From: Tom Barrett Date: Fri, 20 Mar 2020 04:43:01 -0500 Subject: renaming, and setting error logs --- scripts/debian_roll | 42 ------------------------------------------ scripts/krb | 2 +- scripts/ldap | 2 +- scripts/nfs | 2 +- scripts/roll | 41 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 44 insertions(+), 45 deletions(-) delete mode 100755 scripts/debian_roll create mode 100755 scripts/roll (limited to 'scripts') diff --git a/scripts/debian_roll b/scripts/debian_roll deleted file mode 100755 index caf652c..0000000 --- a/scripts/debian_roll +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -set -e - -NAME=$1 -USER=tom -PASS=tom -ROOT_PASS=root - -# init -lxc-create $NAME -t download -- --dist debian --release buster --arch amd64 -lxc-start $NAME -# TODO maybe just info until ip shows up? -sleep 15 - -# install basics -lxc-attach $NAME -- apt-get update -lxc-attach $NAME -- apt-get dist-upgrade -lxc-attach $NAME -- apt-get install -y apt-utils -lxc-attach $NAME -- apt-get install -y sudo openssh-server x11-xserver-utils - -# setup users -lxc-attach $NAME -- bash -c 'echo -e "'$ROOT_PASS'\n'$ROOT_PASS'" | passwd' -lxc-attach $NAME -- adduser $USER --gecos "" --disabled-password -lxc-attach $NAME -- bash -c 'echo -e "'$PASS'\n'$PASS'" | passwd $USER' - -# setup x11 forwarding -lxc-attach $NAME -- bash -c 'echo "AllowTcpForwarding yes" >> /etc/ssh/sshd_config' -lxc-attach $NAME -- bash -c 'echo "X11UseLocalhost yes" >> /etc/ssh/sshd_config' -lxc-attach $NAME -- bash -c 'echo "PermitRootLogin yes" >> /etc/ssh/sshd_config' -lxc-attach $NAME -- systemctl restart sshd - -# setup networking -IP="$(lxc-info $NAME | grep IP | tr -s ' ' | cut -d ' ' -f 2)" -DESIRED_IP="$(grep $NAME configs/hosts | cut -d ' ' -f 1)" - -sed "s/ADDRESS/$DESIRED_IP/" configs/interfaces > tmp/interfaces -sshpass -p $ROOT_PASS scp -o "StrictHostKeyChecking=no" tmp/interfaces root@$IP:/etc/network/interfaces -sshpass -p $ROOT_PASS scp -o "StrictHostKeyChecking=no" configs/hosts root@$IP:/etc/hosts -lxc-attach $NAME -- systemctl restart networking - -# add ssh key -sshpass -p $ROOT_PASS ssh-copy-id -o "StrictHostKeyChecking=no" root@$DESIRED_IP diff --git a/scripts/krb b/scripts/krb index 4df7fef..d5c15a8 100755 --- a/scripts/krb +++ b/scripts/krb @@ -7,7 +7,7 @@ KRB5_ADMIN_PASS=pass USER_PASS=tommie IP="$(grep krb configs/hosts | cut -d ' ' -f 1)" -scripts/debian_roll krb +scripts/roll krb lxc-attach krb -v DEBIAN_FRONTEND=noninteractive -- apt-get -y install krb5-admin-server scp configs/krb/krb5.conf root@$IP:/etc/ diff --git a/scripts/ldap b/scripts/ldap index 594f37b..c545825 100755 --- a/scripts/ldap +++ b/scripts/ldap @@ -1,5 +1,5 @@ #!/bin/bash set -e -scripts/debian_roll ldap +scripts/roll ldap #lxc-attach ldap -v DEBIAN_FRONTEND=noninteractive -- apt-get -y install slapd ldap-utils ldapscripts diff --git a/scripts/nfs b/scripts/nfs index 4439eba..8ab7ef4 100755 --- a/scripts/nfs +++ b/scripts/nfs @@ -1,4 +1,4 @@ #!/bin/bash set -e -scripts/debian_roll nfs +scripts/roll nfs diff --git a/scripts/roll b/scripts/roll new file mode 100755 index 0000000..d8deb61 --- /dev/null +++ b/scripts/roll @@ -0,0 +1,41 @@ +#!/bin/bash +set -e + +NAME=$1 +USER=tom +PASS=tom +ROOT_PASS=root + +# init +lxc-create $NAME -t download -- --dist debian --release buster --arch amd64 +lxc-start $NAME +# TODO maybe just info until ip shows up? +sleep 15 + +# install basics +lxc-attach $NAME -- apt-get update +lxc-attach $NAME -- apt-get dist-upgrade +lxc-attach $NAME -- apt-get install -y sudo openssh-server x11-xserver-utils apt-utils + +# setup users +lxc-attach $NAME -- bash -c 'echo -e "'$ROOT_PASS'\n'$ROOT_PASS'" | passwd' +lxc-attach $NAME -- adduser $USER --gecos "" --disabled-password +lxc-attach $NAME -- bash -c 'echo -e "'$PASS'\n'$PASS'" | passwd $USER' + +# setup x11 forwarding +lxc-attach $NAME -- bash -c 'echo "AllowTcpForwarding yes" >> /etc/ssh/sshd_config' +lxc-attach $NAME -- bash -c 'echo "X11UseLocalhost yes" >> /etc/ssh/sshd_config' +lxc-attach $NAME -- bash -c 'echo "PermitRootLogin yes" >> /etc/ssh/sshd_config' +lxc-attach $NAME -- systemctl restart sshd + +# setup networking +IP="$(lxc-info $NAME | grep IP | tr -s ' ' | cut -d ' ' -f 2)" +DESIRED_IP="$(grep $NAME configs/hosts | cut -d ' ' -f 1)" + +sed "s/ADDRESS/$DESIRED_IP/" configs/interfaces > tmp/interfaces +sshpass -p $ROOT_PASS scp -o "StrictHostKeyChecking=no" tmp/interfaces root@$IP:/etc/network/interfaces +sshpass -p $ROOT_PASS scp -o "StrictHostKeyChecking=no" configs/hosts root@$IP:/etc/hosts +lxc-attach $NAME -- systemctl restart networking + +# add ssh key +sshpass -p $ROOT_PASS ssh-copy-id -o "StrictHostKeyChecking=no" root@$DESIRED_IP -- cgit v1.2.3