File receive-ip.sh of Package submit-ip
#!/bin/bash
CONFIG="/etc/sysconfig/submit-ip"
DATE=$(date)
function cleanup_and_exit(){
local EXITCODE="$1"
exit $EXITCODE
}
if [ -r "$CONFIG" ]; then
. "$CONFIG"
else
echo "Could not read $CONFIG - exiting" >&2
cleanup_and_exit 1
fi
SYSTEMNAME=$(echo "$SSH_ORIGINAL_COMMAND" | awk '{ print $2 }')
SUBMITTED_IP=$(echo "$SSH_ORIGINAL_COMMAND" | awk '{ print $1 }')
REAL_IP=$(echo $SSH_CONNECTION | awk '{ print $1 }')
# echo "$SSH_ORIGINAL_COMMAND; $REAL_IP"
if [ x"$SUBMITTED_IP" != x"$REAL_IP" ]; then
echo "$DATE [$SYSTEMNAME] : ERROR: submitted was $SUBMITTED_IP; real was $REAL_IP" >> $LOGFILE
else
echo "$DATE [$SYSTEMNAME] : $REAL_IP" >> $LOGFILE
fi