Use Config.pm settings to avoid hard-coding /srv/git
[girocco.git] / toolbox / edit-user-email.sh
blob089a3d4921697e294634ce3248b3783813857d48
1 #!/bin/sh
3 . @basedir@/shlib.sh
5 if [ -z "$1" -o -z "$2" -o -z "$3" ]; then
6 echo "Syntax: ./edit-user-email.sh <username> <old e-mail> <new e-mail>"
7 exit 1
8 fi
9 ETC="$cfg_chroot/etc"
10 COUNT=`grep -E -c "^$1:" $ETC/passwd`
11 if [ "$COUNT" -ne "1" ]; then
12 echo "fatal: user '$1' doesn't appear to exist (or exists multiple times, or contains regexpy characters)."
13 exit 1
15 sed -i "s/^$1\(:[^:]*:[^:]*:[^:]*:\)$2:/$1\\1$3:/; t show; b; : show; w /dev/stderr" $ETC/passwd
16 echo "All changed lines listed above."