3 # @(#) $Id: ./src/agentlessd/scripts/register_host.sh, 2012/07/23 dcid Exp $
7 # Copyright (C) 2009 Trend Micro Inc.
10 # This program is a free software; you can redistribute it
11 # and/or modify it under the terms of the GNU General Public
12 # License (version 2) as published by the FSF - Free Software
16 MYNAME="register_host.sh"
20 # Checking the location.
21 ls -la $MYNAME > /dev/null 2>&1
23 LOCALDIR=`dirname $0`;
26 ls -la $MYNAME > /dev/null 2>&1
28 echo "ERROR: You must run this script from the same directory."
36 if [ "x$1" = "x" -o "x$1" = "xhelp" -o "x$1" = "x-h" ]; then
38 echo " add <user@host> [<passwd>] (<additional_pass>)"
39 echo " list (passwords)"
44 if [ "x$1" = "xlist" ]; then
45 echo "*Available hosts: "
46 if [ "x$2" = "xpasswords" ]; then
47 cat $MYPASS | sort | uniq;
49 cat $MYPASS | cut -d "|" -f 1 | sort | uniq;
55 elif [ "x$1" = "xadd" ]; then
56 if [ "x$2" = "x" ]; then
57 echo "ERROR: Missing hostname name.";
58 echo "ex: $0 add <user@host> [<passwd>] (<additional_pass>)";
62 grep "$2|" $MYPASS > /dev/null 2>&1
64 echo "ERROR: Host '$2' already added.";
69 # Checking if the password was supplied.
70 if [ "x$3" = "x" ]; then
71 echo "Please provide password for host $2."
77 echo "Please provide additional password for host $2 (<enter> for empty)."
87 echo "$2|$INPASS|$ADDPASS" >> $MYPASS;
89 echo "ERROR: Unable to creating entry (echo failed)."
93 echo "*Host $2 added."
97 echo "ERROR: Invalid argument.";