diff --git a/README.md b/README.md index 96f766a..af2b555 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,9 @@ contact ~ben or sose on tilde.chat (in the #slbr channel) to sign up. ## Prerequisites - LXC - LXD with an lxdbr0 device configured +- inotifywait - BSD style netcat - Tmux -- Python 3 -- An open ssh port ## Setup - Switch to the directory you would like to run SLBR in. diff --git a/deathwatch.sh b/deathwatch.sh index f710694..8d9755c 100755 --- a/deathwatch.sh +++ b/deathwatch.sh @@ -1,6 +1,10 @@ #!/bin/sh -inotifywait -mrqe delete users | while read dir +# deathwatch.sh +# efficiently checks each user directory to see if the .ssh folder has been deleted +# deletes the user if it has + +inotifywait -mrqe delete users | while read -r dir do echo "$dir" | grep -q 'ISDIR .ssh' \ - && ./deluser.sh "$(echo $dir | cut -f 2 -d '/')" + && ./deluser.sh "$(echo "$dir" | cut -f 2 -d '/')" done diff --git a/deluser.sh b/deluser.sh index 58974d1..c3ebc0a 100755 --- a/deluser.sh +++ b/deluser.sh @@ -1,7 +1,11 @@ #!/bin/sh +# deluser.sh +# deletes a user, their container, and their home direcory +# can be called manually or by a script + SLBRUSER=$1 test -z "$SLBRUSER" && echo "no user provided" && exit -if !(grep -qE "^$SLBRUSER$" users.txt) +if ! (grep -qE "^$SLBRUSER$" users.txt) then echo "user $SLBRUSER not found in users.txt, will not delete" exit diff --git a/killme.sh b/killme.sh index 2a2eee7..5187060 100755 --- a/killme.sh +++ b/killme.sh @@ -1,8 +1,12 @@ #!/bin/sh -#This should only be run by users who have been eliminated +# killme.sh +# deletes a user's .ssh folder signifying they have been eliminated +# run by the user's account, hopefully without their control +# This should only be run by users who have been eliminated, obviously + SLBRUSER=$(whoami) test -z "$SLBRUSER" && echo "no user provided" && exit -if !(grep -qE "^$SLBRUSER$" /home/slbr/users.txt) +if ! (grep -qE "^$SLBRUSER$" /home/slbr/users.txt) then echo "user not found in users.txt, will not delete" exit @@ -10,5 +14,4 @@ fi echo "removing /home/slbr/users/$SLBRUSER" rm -rf "/home/slbr/users/$SLBRUSER/.ssh" -sleep 10 lxc delete -f "$SLBRUSER" diff --git a/login.sh b/login.sh index f4ef058..f178c43 100755 --- a/login.sh +++ b/login.sh @@ -1,7 +1,13 @@ #!/bin/sh +# login.sh +# the script that runs when a player logs into their account +# will put the player in their container and setup a tmux session for them +# will also run killme.sh if called from a container +# a bit hacky, perhaps we should find a better method? + . /etc/profile.d/apps-bin-path.sh SLBRUSER="$(whoami)" -lxc list | grep -q "$(echo $SSH_CLIENT | cut -f 1 -d ' ')" && ~/killme.sh && exit #this is a bit hacky, maybe something better? +lxc list | grep -q "$(echo "$SSH_CLIENT" | cut -f 1 -d ' ')" && ~/killme.sh && exit echo "The game has not started yet! Grab a cup of tea, or just wait here." while test -z "$(cat /home/slbr/gamestatus)" || break do diff --git a/lxcinit.sh b/lxcinit.sh index 0035666..55604b1 100755 --- a/lxcinit.sh +++ b/lxcinit.sh @@ -1,5 +1,7 @@ -#!/bin/bash -#WARRNING: THIS SHOULD ONLY BE INVOKED FROM newuser.sh +#!/bin/sh +# lxcinit.sh +# called from newuser.sh to set up an lxc container with the proper files + echo " Launching container for user $(whoami)" . /etc/profile.d/apps-bin-path.sh \ && lxc launch ubuntu: "$(whoami)" diff --git a/newuser.sh b/newuser.sh index 28ba784..9b0ef20 100755 --- a/newuser.sh +++ b/newuser.sh @@ -1,4 +1,7 @@ #!/bin/sh +# newuser.sh +# creates a new player + SLBRUSER=$1 PUBKEY=$2 test -z "$SLBRUSER" && echo "no user provided" && exit diff --git a/sendmsg.sh b/sendmsg.sh index 1b2f905..3cc9973 100755 --- a/sendmsg.sh +++ b/sendmsg.sh @@ -1,4 +1,7 @@ -#!/bin/bash +#!/bin/sh +# sendmsg.sh +# sends a message to all conatiners + ADDRESSES=$(lxc list | cut -f 4 -d '|' \ | grep -Eo "[0-9]*\\.[0-9]*\\.[0-9]*\\.[0-9]*") for ADDRESS in $ADDRESSES diff --git a/tmuxinit.sh b/tmuxinit.sh index 1e9bc27..9b5d995 100755 --- a/tmuxinit.sh +++ b/tmuxinit.sh @@ -1,4 +1,7 @@ #!/bin/sh +# tmuxinit.sh +# sets up a tmux session within the user's container + tmux new-session -d -n test tmux select-window -t 0:0 tmux send -t 0:0 'nc -lkp 9090' ENTER