diff --git a/deluser.sh b/deluser.sh index 1687dcd..5773af4 100755 --- a/deluser.sh +++ b/deluser.sh @@ -1,7 +1,11 @@ #!/bin/sh SLBRUSER=$1 test -z "$SLBRUSER" && echo "no user provided" && exit -grep -qvx "$SLBRUSER" users.txt && echo "user not found in users.txt, will not delete" && exit +if !(grep -qx "$SLBRUSER" users.txt) +then + echo "user not found in users.txt, will not delete" + exit +fi if ps -o stat= -p $PPID | grep -qv S+ #check if this is being called from listen.py then @@ -13,5 +17,4 @@ lxc stop "$SLBRUSER" lxc delete "$SLBRUSER" sudo rm -rf "$SLBRUSER" sudo userdel "$SLBRUSER" -tr '\n' ' ' < users.txt | sed "s/$SLBRUSER//g" | tr ' ' '\n' > users.temp -mv users.temp users +sed -ie "s/$SLBRUSER .*$//g"