From d5fad7e84a1cc8146fb3250d4c1d4d18045f4c52 Mon Sep 17 00:00:00 2001 From: Tom Barrett Date: Thu, 13 Feb 2020 08:47:33 -0600 Subject: create a basic debian box for sysadmin testing --- lxc/arch_roll | 38 ++++++++++++++++++++++++++++++++++++++ lxc/debian_roll | 38 ++++++++++++++++++++++++++++++++++++++ lxc/roll | 38 -------------------------------------- lxc/setup | 1 - 4 files changed, 76 insertions(+), 39 deletions(-) create mode 100755 lxc/arch_roll create mode 100755 lxc/debian_roll delete mode 100755 lxc/roll diff --git a/lxc/arch_roll b/lxc/arch_roll new file mode 100755 index 0000000..ce97bfe --- /dev/null +++ b/lxc/arch_roll @@ -0,0 +1,38 @@ +#!/bin/bash +set -e + +NAME=$1 +USER=tom +PASS=durr + +# init +lxc-create -n $NAME -t download -- --dist archlinux --release current --arch amd64 +lxc-start -n $NAME +sleep 10 + +# install basics +lxc-attach -n $NAME -- pacman -Syu --noconfirm +lxc-attach -n $NAME -- pacman -Sy --noconfirm \ + git sudo vim openssh xorg-xauth xorg-xhost fakeroot binutils + +# setup user +lxc-attach -n $NAME -- useradd $USER +lxc-attach -n $NAME -- mkdir /home/$USER +lxc-attach -n $NAME -- bash -c 'echo "'$USER' ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers' +lxc-attach -n $NAME -- bash -c 'echo -e "'$PASS'\n'$PASS'" | passwd $USER' + +# setup for yay +lxc-attach -n $NAME -- mkdir /home/$USER/yay +lxc-attach -n $NAME -- git clone https://aur.archlinux.org/yay-bin.git /home/$USER/yay +lxc-attach -n $NAME -- chown $USER:$USER -R /home/$USER +lxc-attach -n $NAME -- bash -c 'cd /home/'$USER'/yay && sudo -u '$USER' makepkg -si --noconfirm' +lxc-attach -n $NAME -- bash -c 'sudo -u '$USER' yay -Syu --noconfirm' + +# setup x11 forwarding +lxc-attach -n $NAME -- bash -c 'echo "X11Forwarding yes" >> /etc/ssh/sshd_config' +lxc-attach -n $NAME -- bash -c 'echo "AllowTcpForwarding yes" >> /etc/ssh/sshd_config' +lxc-attach -n $NAME -- bash -c 'echo "X11UseLocalhost yes" >> /etc/ssh/sshd_config' +lxc-attach -n $NAME -- systemctl start sshd + +# display info +lxc-info -n $NAME diff --git a/lxc/debian_roll b/lxc/debian_roll new file mode 100755 index 0000000..474e990 --- /dev/null +++ b/lxc/debian_roll @@ -0,0 +1,38 @@ +#!/bin/bash +set -e + +NAME=$1 +USER=tom +PASS=durr + +# init +lxc-create -n $NAME -t download -- --dist debian --release buster --arch amd64 +lxc-start -n $NAME +sleep 10 + +# install basics +lxc-attach -n $NAME -- apt update +lxc-attach -n $NAME -- apt dist-upgrade +lxc-attach -n $NAME -- apt install -y sudo openssh-server x11-xserver-utils + +# setup user +#lxc-attach -n $NAME -- useradd $USER +#lxc-attach -n $NAME -- mkdir /home/$USER +#lxc-attach -n $NAME -- bash -c 'echo "'$USER' ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers' +#lxc-attach -n $NAME -- bash -c 'echo -e "'$PASS'\n'$PASS'" | passwd $USER' + +# setup for yay +#lxc-attach -n $NAME -- mkdir /home/$USER/yay +#lxc-attach -n $NAME -- git clone https://aur.archlinux.org/yay-bin.git /home/$USER/yay +#lxc-attach -n $NAME -- chown $USER:$USER -R /home/$USER +#lxc-attach -n $NAME -- bash -c 'cd /home/'$USER'/yay && sudo -u '$USER' makepkg -si --noconfirm' +#lxc-attach -n $NAME -- bash -c 'sudo -u '$USER' yay -Syu --noconfirm' + +# setup x11 forwarding +#lxc-attach -n $NAME -- bash -c 'echo "X11Forwarding yes" >> /etc/ssh/sshd_config' +#lxc-attach -n $NAME -- bash -c 'echo "AllowTcpForwarding yes" >> /etc/ssh/sshd_config' +#lxc-attach -n $NAME -- bash -c 'echo "X11UseLocalhost yes" >> /etc/ssh/sshd_config' +#lxc-attach -n $NAME -- systemctl start sshd + +# display info +#lxc-info -n $NAME diff --git a/lxc/roll b/lxc/roll deleted file mode 100755 index 5af4cca..0000000 --- a/lxc/roll +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -#set -e - -NAME=$1 -USER=tom -PASS=durr - -# init -lxc-create -n $NAME -t download -- --dist archlinux --release current --arch amd64 -lxc-start -n $NAME -sleep 10 - -# install basics -lxc-attach -n $NAME -- pacman -Syu --noconfirm -lxc-attach -n $NAME -- pacman -Sy --noconfirm \ - git sudo vim openssh xorg-xauth xorg-xhost fakeroot binutils - -# setup user -lxc-attach -n $NAME -- useradd $USER -lxc-attach -n $NAME -- mkdir /home/$USER -lxc-attach -n $NAME -- bash -c 'echo "'$USER' ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers' -lxc-attach -n $NAME -- bash -c 'echo -e "'$PASS'\n'$PASS'" | passwd $USER' - -# setup for yay -lxc-attach -n $NAME -- mkdir /home/$USER/yay -lxc-attach -n $NAME -- git clone https://aur.archlinux.org/yay-bin.git /home/$USER/yay -lxc-attach -n $NAME -- chown $USER:$USER -R /home/$USER -lxc-attach -n $NAME -- bash -c 'cd /home/'$USER'/yay && sudo -u '$USER' makepkg -si --noconfirm' -lxc-attach -n $NAME -- bash -c 'sudo -u '$USER' yay -Syu --noconfirm' - -# setup x11 forwarding -lxc-attach -n $NAME -- bash -c 'echo "X11Forwarding yes" >> /etc/ssh/sshd_config' -lxc-attach -n $NAME -- bash -c 'echo "AllowTcpForwarding yes" >> /etc/ssh/sshd_config' -lxc-attach -n $NAME -- bash -c 'echo "X11UseLocalhost yes" >> /etc/ssh/sshd_config' -lxc-attach -n $NAME -- systemctl start sshd - -# display info -lxc-info -n $NAME diff --git a/lxc/setup b/lxc/setup index 5fdf825..6cfe699 100755 --- a/lxc/setup +++ b/lxc/setup @@ -7,4 +7,3 @@ virsh net-autostart default echo "kernel.unprivileged_userns_clone=1" > /etc/sysctl.d/80-lxc-userns.conf echo "tom veth virbr0 2" > /etc/lxc/lxc-usernet echo "you should reboot now." - -- cgit v1.2.3