Fixed deluser.sh

This commit is contained in:
sose 2018-09-26 17:11:40 +02:00
parent e26387bb4c
commit 42b858105a
1 changed files with 6 additions and 3 deletions

View File

@ -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"