#!/bin/bash

#$1: host ip address
#$2: host port number
#$3: transmit protocol
if [ $2 ]; then
    port=$2
else
    port=514
fi
if [ $3 ]; then
    protocol=$3
else
    protocol="udp"
fi
if [ $protocol == "tcp" ]; then
    sed -i "s/^*.*.*@.*/*.* @@$1:$port/g" /etc/rsyslog.conf
else
    sed -i "s/^*.*.*@.*/*.* @$1:$port/g" /etc/rsyslog.conf
fi
/etc/init.d/rsyslog restart > /dev/null
exit 0
