Added scripts

This commit is contained in:
sose 2018-08-28 17:39:44 +00:00
parent bb412f2de0
commit abd5262630
7 changed files with 52 additions and 0 deletions

6
deluser.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
USER=$1
lxc stop $USER
sudo rm -rf $USER
sudo userdel $USER
lxc delete $USER

3
listen.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
nc -l localhost 9191
#cat gamelog.txt | nc -q2 10.161.77.78 9090

3
login.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
. /etc/profile.d/apps-bin-path.sh
lxc exec $(whoami) /usr/bin/tmuxinit.sh

7
lxcinit.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
#WARRNING: THIS SHOULD ONLY BE INVOKED FROM newuser.sh
echo " Launching container for user $(whoami)"
. /etc/profile.d/apps-bin-path.sh \
&& lxc launch ubuntu: $(whoami)
lxc file push /home/slbr/tmuxinit.sh $(whoami)/usr/bin/tmuxinit.sh
lxc file push /home/slbr/suicidebash.bashrc $(whoami)/etc/bash.bashrc

14
newuser.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/sh
USER=$1
echo "Creating homedir..."
mkdir "/home/slbr/$USER"
echo "lxc exec $USER bash" > "/home/slbr/$USER/.profile"
chmod -w "/home/slbr/$USER/.profile"
echo "Creating user..."
sudo useradd $USER -d "/home/slbr/$USER"
sudo usermod -a -G lxd $USER
sudo chown "$USER:$USER" "/home/slbr/$USER"
sudo chsh $USER -s /home/slbr/login.sh
echo "Creating container..."
sudo su $USER -s /bin/sh -c "/home/slbr/lxcinit.sh"

9
sendmsg.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
function send {
ADRESSES=$(lxc list | cut -f 4 -d '|' \
| grep -Eo "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*")
for ADRESS in $ADRESSES
do
echo $1 | nc -q2 $ADRESS 9090
done
}

10
tmuxinit.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
CNFHANDLE="function command_not_found_handle { echo Wrong; }"
tmux new-session -d -n test
tmux select-window -t 0:0
tmux send -t 0:0 'nc -lkp 9090' ENTER
tmux split-window -h bash
tmux send -t 0:1 $CNFHANDLE ENTER
tmux select-layout
tmux resize-pane -t 1 -L 60
tmux a