7 if [ -z "$1" ] ||
[ -z "$2" ] ||
[ -z "$3" ]; then
8 echo "Usage: $0 <username> <old e-mail> <new e-mail>"
12 COUNT
="$(grep -E -c "^
$1:" "$ETC/passwd
")"
13 if [ "$COUNT" -ne "1" ]; then
14 echo "fatal: user '$1' doesn't appear to exist (or exists multiple times, or contains regexpy characters)."
17 if echo "$2" |
grep -q '[,:]'; then
18 echo "fatal: e-mail '$2' has illegal characters ([,:])."
21 if ! echo "$3" |
grep -E -q '^[a-zA-Z0-9+._-]+@[a-zA-Z0-9.-]+$'; then
22 echo "fatal: e-mail '$3' is not valid (^[a-zA-Z0-9+._-]+@[a-zA-Z0-9.-]+$)."
26 -e "s/^$1\(:[^:]*:[^:]*:[^:]*:\)$2\([,:]\)/$1\\1$3\\2/" \
31 "$ETC/passwd" >"$ETC/passwd.$$"
32 mv -f "$ETC/passwd.$$" "$ETC/passwd"
33 rm -f "$ETC/passwd.$$"
34 if [ -n "$cfg_update_pwd_db" ] && [ "$cfg_update_pwd_db" != "0" ]; then
35 "$cfg_basedir/bin/update-pwd-db" "$ETC/passwd" "$1"
37 echo "All changed lines listed above."