2 # This is part of sync-accounts, a tool for synchronising UN*X password data.
5 # Copyright 1999-2000,2002 Ian Jackson <ian@davenant.greenend.org.uk>
6 # Copyright 2000-2001 nCipher Corporation Ltd
8 # sync-accounts is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation; either version 3, or (at
11 # your option) any later version.
13 # sync-accounts is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # General Public License for more details.
18 # You should already have a copy of the GNU General Public License.
19 # If not, consult the Free Software Foundation's website at
20 # www.fsf.org, or the GNU Project website at www.gnu.org.
22 # $Id: grab-account,v 1.5 2007-09-21 21:21:15 ianmdlvl Exp $
26 if [ $# -lt 2 -o $# -gt 3 ]
29 'usage: grab-account <localuser> <shorthostname> [<remoteuser>]
30 creates an entry in /etc/sync-accounts, and runs sync-accounts
31 $Id: grab-account,v 1.5 2007-09-21 21:21:15 ianmdlvl Exp $'
47 if perl -ne 'exit 1 if m/^\s*user\s+'$lu'\s/;' <$cf
50 next unless m/^\s*host\s+'$sh'\s*$/...m/^host|^end/;
51 next unless m/^\s*addhere\s*$/;
53 print "user '$lu'".("'$lu'" eq "'$ru'" ? "" : " remote='$ru'")."\n"
56 print(STDERR "\`addhere'\'' line not found\n"), $?=1 if !$? && !$done;
61 echo "entry already exists in $cf, leaving alone"