forked from tildeverse/SLBR
New death mechanics fully functional, general cleanup
This commit is contained in:
parent
0ff808414e
commit
19c77b34d0
|
@ -10,10 +10,9 @@ contact ~ben or sose on tilde.chat (in the #slbr channel) to sign up.
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
- LXC
|
- LXC
|
||||||
- LXD with an lxdbr0 device configured
|
- LXD with an lxdbr0 device configured
|
||||||
|
- inotifywait
|
||||||
- BSD style netcat
|
- BSD style netcat
|
||||||
- Tmux
|
- Tmux
|
||||||
- Python 3
|
|
||||||
- An open ssh port
|
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
- Switch to the directory you would like to run SLBR in.
|
- Switch to the directory you would like to run SLBR in.
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
#!/bin/sh
|
#!/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
|
do
|
||||||
echo "$dir" | grep -q 'ISDIR .ssh' \
|
echo "$dir" | grep -q 'ISDIR .ssh' \
|
||||||
&& ./deluser.sh "$(echo $dir | cut -f 2 -d '/')"
|
&& ./deluser.sh "$(echo "$dir" | cut -f 2 -d '/')"
|
||||||
done
|
done
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# deluser.sh
|
||||||
|
# deletes a user, their container, and their home direcory
|
||||||
|
# can be called manually or by a script
|
||||||
|
|
||||||
SLBRUSER=$1
|
SLBRUSER=$1
|
||||||
test -z "$SLBRUSER" && echo "no user provided" && exit
|
test -z "$SLBRUSER" && echo "no user provided" && exit
|
||||||
if !(grep -qE "^$SLBRUSER$" users.txt)
|
if ! (grep -qE "^$SLBRUSER$" users.txt)
|
||||||
then
|
then
|
||||||
echo "user $SLBRUSER not found in users.txt, will not delete"
|
echo "user $SLBRUSER not found in users.txt, will not delete"
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
#!/bin/sh
|
#!/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)
|
SLBRUSER=$(whoami)
|
||||||
test -z "$SLBRUSER" && echo "no user provided" && exit
|
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
|
then
|
||||||
echo "user not found in users.txt, will not delete"
|
echo "user not found in users.txt, will not delete"
|
||||||
exit
|
exit
|
||||||
|
@ -10,5 +14,4 @@ fi
|
||||||
|
|
||||||
echo "removing /home/slbr/users/$SLBRUSER"
|
echo "removing /home/slbr/users/$SLBRUSER"
|
||||||
rm -rf "/home/slbr/users/$SLBRUSER/.ssh"
|
rm -rf "/home/slbr/users/$SLBRUSER/.ssh"
|
||||||
sleep 10
|
|
||||||
lxc delete -f "$SLBRUSER"
|
lxc delete -f "$SLBRUSER"
|
||||||
|
|
8
login.sh
8
login.sh
|
@ -1,7 +1,13 @@
|
||||||
#!/bin/sh
|
#!/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
|
. /etc/profile.d/apps-bin-path.sh
|
||||||
SLBRUSER="$(whoami)"
|
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."
|
echo "The game has not started yet! Grab a cup of tea, or just wait here."
|
||||||
while test -z "$(cat /home/slbr/gamestatus)" || break
|
while test -z "$(cat /home/slbr/gamestatus)" || break
|
||||||
do
|
do
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
#WARRNING: THIS SHOULD ONLY BE INVOKED FROM newuser.sh
|
# lxcinit.sh
|
||||||
|
# called from newuser.sh to set up an lxc container with the proper files
|
||||||
|
|
||||||
echo " Launching container for user $(whoami)"
|
echo " Launching container for user $(whoami)"
|
||||||
. /etc/profile.d/apps-bin-path.sh \
|
. /etc/profile.d/apps-bin-path.sh \
|
||||||
&& lxc launch ubuntu: "$(whoami)"
|
&& lxc launch ubuntu: "$(whoami)"
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# newuser.sh
|
||||||
|
# creates a new player
|
||||||
|
|
||||||
SLBRUSER=$1
|
SLBRUSER=$1
|
||||||
PUBKEY=$2
|
PUBKEY=$2
|
||||||
test -z "$SLBRUSER" && echo "no user provided" && exit
|
test -z "$SLBRUSER" && echo "no user provided" && exit
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
# sendmsg.sh
|
||||||
|
# sends a message to all conatiners
|
||||||
|
|
||||||
ADDRESSES=$(lxc list | cut -f 4 -d '|' \
|
ADDRESSES=$(lxc list | cut -f 4 -d '|' \
|
||||||
| grep -Eo "[0-9]*\\.[0-9]*\\.[0-9]*\\.[0-9]*")
|
| grep -Eo "[0-9]*\\.[0-9]*\\.[0-9]*\\.[0-9]*")
|
||||||
for ADDRESS in $ADDRESSES
|
for ADDRESS in $ADDRESSES
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# tmuxinit.sh
|
||||||
|
# sets up a tmux session within the user's container
|
||||||
|
|
||||||
tmux new-session -d -n test
|
tmux new-session -d -n test
|
||||||
tmux select-window -t 0:0
|
tmux select-window -t 0:0
|
||||||
tmux send -t 0:0 'nc -lkp 9090' ENTER
|
tmux send -t 0:0 'nc -lkp 9090' ENTER
|
||||||
|
|
Loading…
Reference in New Issue