From 4a2e1edc54b8d624a659d1ecc7e6e7869921f0c5 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sat, 15 Sep 2018 23:11:58 -0700 Subject: [PATCH] Shellchecked scripts, fixed spelling errors --- deluser.sh | 14 +++++++------- login.sh | 4 ++-- lxcinit.sh | 6 +++--- newuser.sh | 12 ++++++------ sendmsg.sh | 8 ++++---- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/deluser.sh b/deluser.sh index 3b4e773..926ada7 100755 --- a/deluser.sh +++ b/deluser.sh @@ -1,15 +1,15 @@ #!/bin/sh SLBRUSER=$1 -test -z $SLBRUSER && echo "no user provided" && exit +test -z "$SLBRUSER" && echo "no user provided" && exit if ps -o stat= -p $PPID | grep -qv S+ #check if this is being called from listen.py then echo "YOU ARE ABOUT TO PERMANENTLY DELETE USER $SLBRUSER AND ALL OF THEIR DATA. RE-ENTER THE USERS NAME TO CONTINUE" - read ENTEREDUSER - [ $ENTEREDUSER != $SLBRUSER ] && echo "users did not match, exiting..." && exit + read -r ENTEREDUSER + [ "$ENTEREDUSER" != "$SLBRUSER" ] && echo "users did not match, exiting..." && exit fi -lxc stop $SLBRUSER -lxc delete $SLBRUSER -sudo rm -rf $SLBRUSER -sudo userdel $SLBRUSER +lxc stop "$SLBRUSER" +lxc delete "$SLBRUSER" +sudo rm -rf "$SLBRUSER" +sudo userdel "$SLBRUSER" tr '\n' ' ' < users | sed "s/$SLBRUSER //" | tr ' ' '\n' > users.temp mv users.temp users diff --git a/login.sh b/login.sh index b4c288b..80a2968 100755 --- a/login.sh +++ b/login.sh @@ -1,11 +1,11 @@ #!/bin/sh . /etc/profile.d/apps-bin-path.sh 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 printf "." sleep 1 done echo "READY.......BEGIN!" sleep 1 -lxc exec $(whoami) /usr/bin/tmuxinit.sh +lxc exec "$(whoami)" /usr/bin/tmuxinit.sh diff --git a/lxcinit.sh b/lxcinit.sh index 0bb87ad..007c2a2 100755 --- a/lxcinit.sh +++ b/lxcinit.sh @@ -2,6 +2,6 @@ #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 + && 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" diff --git a/newuser.sh b/newuser.sh index bb26684..bfbe5a2 100755 --- a/newuser.sh +++ b/newuser.sh @@ -1,16 +1,16 @@ #!/bin/sh SLBRUSER=$1 -test -z $SLBRUSER && echo "no user provided" && exit +test -z "$SLBRUSER" && echo "no user provided" && exit echo "Creating homedir..." mkdir "/home/slbr/$SLBRUSER" -echo $SLBRUSER >> users +echo "$SLBRUSER" >> users echo "lxc exec $SLBRUSER bash" > "/home/slbr/$SLBRUSER/.profile" chmod -w "/home/slbr/$SLBRUSER/.profile" echo "Creating user..." -sudo useradd $SLBRUSER -d "/home/slbr/$SLBRUSER" -sudo usermod -a -G lxd $SLBRUSER +sudo useradd "$SLBRUSER" -d "/home/slbr/$SLBRUSER" +sudo usermod -a -G lxd "$SLBRUSER" sudo chown "$SLBRUSER:$SLBRUSER" "/home/slbr/$SLBRUSER" -sudo chsh $SLBRUSER -s /home/slbr/login.sh +sudo chsh "$SLBRUSER" -s /home/slbr/login.sh echo "Creating container..." -sudo su $SLBRUSER -s /bin/sh -c "/home/slbr/lxcinit.sh" +sudo su "$SLBRUSER" -s /bin/sh -c "/home/slbr/lxcinit.sh" diff --git a/sendmsg.sh b/sendmsg.sh index f5685e9..6320d75 100755 --- a/sendmsg.sh +++ b/sendmsg.sh @@ -1,9 +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 + ADDRESSES=$(lxc list | cut -f 4 -d '|' \ + | grep -Eo "[0-9]*\\.[0-9]*\\.[0-9]*\\.[0-9]*") + for ADDRESS in $ADDRESSES do - echo $1 | nc -q2 $ADRESS 9090 + echo "$1" | nc -q2 "$ADDRESS" 9090 done }