CCCPaste

syslog config update

# Define IPs
OLD_IP="172.16.1.227"
NEW_IP="172.16.1.229"
CONF_FILE="/etc/rsyslog.d/99-remotelog.conf"

if [ -f "$CONF_FILE" ]; then
echo "[+] Updating config from $OLD_IP to $NEW_IP..."

# 1. Update the IP address
sudo sed -i "s/$OLD_IP/$NEW_IP/g" "$CONF_FILE"

# 2. Restart the service
echo "[+] Restarting rsyslog..."
sudo systemctl restart rsyslog

# 3. Validation
if grep -q "$NEW_IP" "$CONF_FILE"; then
echo "[SUCCESS] Config updated."
# Send a test log to the new server
logger "MIGRATION_TEST: Hello 172.16.1.229 from $(hostname)"
echo "[+] Test log sent. Check /var/log/syslog on the new server."
else
echo "[FAIL] Update failed. Check file permissions."
fi
else
echo "[-] Config file $CONF_FILE not found. Run the setup script first!"
fi