5 # Copyright (C) 2009 Trend Micro Inc.
8 # This program is a free software; you can redistribute it
9 # and/or modify it under the terms of the GNU General Public
10 # License (version 2) as published by the FSF - Free Software
13 MYNAME="register_host.sh"
17 ls -la $MYNAME > /dev/null 2>&1
19 LOCALDIR=`dirname $0`;
22 ls -la $MYNAME > /dev/null 2>&1
24 echo "ERROR: You must run this script from the same directory."
30 if [ "x$1" = "x" -o "x$1" = "xhelp" -o "x$1" = "x-h" ]; then
32 echo " add <user@host> [<passwd>] (<additional_pass>)"
33 echo " list (passwords)"
37 if [ "x$1" = "xlist" ]; then
38 echo "*Available hosts: "
39 if [ "x$2" = "xpasswords" ]; then
40 cat $MYPASS | sort | uniq;
42 cat $MYPASS | cut -d "|" -f 1 | sort | uniq;
46 elif [ "x$1" = "xadd" ]; then
47 if [ "x$2" = "x" ]; then
48 echo "ERROR: Missing hostname name.";
49 echo "ex: $0 add <user@host> [<passwd>] (<additional_pass>)";
53 grep "$2|" $MYPASS > /dev/null 2>&1
55 echo "ERROR: Host '$2' already added.";
59 # Check if the password was supplied
60 if [ "x$3" = "x" ]; then
61 echo "Please provide password for host $2."
67 echo "Please provide additional password for host $2 (<enter> for empty)."
77 echo "$2|$INPASS|$ADDPASS" >> $MYPASS;
79 echo "ERROR: Unable to creating entry (echo failed)."
83 echo "*Host $2 added."
86 echo "ERROR: Invalid argument.";