3 # Renumber (change IP address) an OSSEC agent (must be run on both agent
9 echo Usage: $0 agent-name new-IP-address
13 if ! [ -e /etc/ossec-init.conf ]; then
14 echo ossec-init.conf not found. Exiting...
18 . /etc/ossec-init.conf
19 KEYFILE=$DIRECTORY/etc/client.keys
21 # Get the IP address from the key file
22 IPADDR=`grep -w "${1}" $KEYFILE | cut -d " " -f 3`
23 if [ -z ${IPADDR} ]; then
24 echo Agent ${1} not found. Exiting...
29 /var/ossec/bin/ossec-control stop
31 # Update the key record
32 sed -i $KEYFILE -e "s/${IPADDR}/${2}/"
34 # Rename files and directories (manager)
38 if [ -e "agent-info/${1}-${IPADDR}" ]; then
39 mv "agent-info/${1}-${IPADDR}" \
40 "agent-info/${1}-${2}"
43 if [ -e "rootcheck/(${1}) ${IPADDR}->rootcheck" ]; then
44 mv "rootcheck/(${1}) ${IPADDR}->rootcheck" \
45 "rootcheck/(${1}) ${2}->rootcheck"
48 if [ -e "syscheck/(${1}) ${IPADDR}->syscheck" ]; then
49 mv "syscheck/(${1}) ${IPADDR}->syscheck" \
50 "syscheck/(${1}) ${2}->syscheck"
53 if [ -e "syscheck/.(${1}) ${IPADDR}->syscheck.cpt" ]; then
54 mv "syscheck/.(${1}) ${IPADDR}->syscheck.cpt" \
55 "syscheck/.(${1}) ${2}->syscheck.cpt"
59 /var/ossec/bin/ossec-control start