working remove-user.sh for extrausers
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 8 Oct 2011 13:53:28 +0000 (15:53 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 8 Oct 2011 13:53:28 +0000 (15:53 +0200)
remove-user.sh

index f2197f4..bc143bc 100755 (executable)
@@ -1,10 +1,17 @@
 #!/bin/sh -xe
 
-login=$1
+. ./env.sh
 
-if [ -z "$login" ]; then
-       ls -al users/
+email=$1
+passwd=/var/lib/extrausers/passwd
+
+if [ -z "$email" ]; then
+       cat $passwd | cut -d: -f5
        exit 1
 fi
 
-rm -Rvf users/$login
+if dir=`grep ":$email:" $passwd | cut -d: -f6` ; then
+       rm -Rfv $dir
+       grep -v ":$email:" $passwd > $passwd.new && mv $passwd.new $passwd
+fi
+