Results 1 to 1 of 1
Hi all,
I was following
Postfix Virtual MailBox Clam Smtp Howto
https://help.ubuntu.com/community/Po...=recall&rev=82
building an mail server, creating /usr/local/sbin/deldovcotuser to delete users.
However it can only work as root. On running;
...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 03-05-2012 #1Linux Guru
- Join Date
- Sep 2004
- Posts
- 1,712
Execute command only works as root
Hi all,
I was following
Postfix Virtual MailBox Clam Smtp Howto
https://help.ubuntu.com/community/Po...=recall&rev=82
building an mail server, creating /usr/local/sbin/deldovcotuser to delete users.
However it can only work as root. On running;
$ sudo deldovecotuser user@mydomain.comit complains.Code:read: 18: Illegal option -n Aborting....
$ cat /usr/local/sbin/deldovecotuseradddovecotuser works on sudo.Code:#!/bin/bash # # deldovecotuser - for deleting virtual dovecot users # if [ ! $# = 1 ] then echo -e "Usage: $0 username@domain" exit 1 else user=`echo "$1" | cut -f1 -d "@"` domain=`echo "$1" | cut -s -f2 -d "@"` if [ -x $domain ] then echo -e "No domain given\nUsage: $0 username@domain: " exit 2 fi fi read -n 1 -p "Delete user $user@$domain from dovecot? [Y/N]? " echo case $REPLY in y | Y) new_users=`grep -v $user@$domain /etc/dovecot/users` new_passwd=`grep -v $user@$domain /etc/dovecot/passwd` new_vmaps=`grep -v $user@$domain /etc/postfix/vmaps` echo "Deleting $user@$domain from /etc/dovecot/users" echo "$new_users" > /etc/dovecot/users echo "Deleting $user@$domain from /etc/dovecot/passwd" echo "$new_passwd" > /etc/dovecot/passwd echo "Deleting $user@$domain from /etc/postfix/vmaps" echo "$new_vmaps" > /etc/postfix/vmaps postmap /etc/postfix/vmaps postfix reload read -n1 -p "Delete all files in /home/vmail/$domain/$user? [Y/N]? " DELETE echo case $DELETE in y | Y) echo "Deleting files in /home/vmail/$domain/$user" rm -fr /home/vmail/$domain/$user ;; * ) echo "Not deleting files in /home/vmail/$domain/$user" ;; esac ;; * ) echo "Aborting..." ;; esac
$ ls -ld /usr/local/sbin/deldovecotuser$ ls -ld /usr/local/sbin/adddovecotuserCode:-rwxr-xr-x 1 root staff 1256 Mar 5 17:13 /usr/local/sbin/deldovecotuser
Google didn't find me a solution. Please help. TIACode:-rwxr-xr-x 1 root staff 1678 Mar 5 16:52 /usr/local/sbin/adddovecotuser
B.R.
satimis


Reply With Quote
