#!/bin/bash
WAIT_TIME=15

while true; do
    /usr/hmcrbin/lshmc -V 2>&1 > /dev/null
    if [ $? -ne 0 ]; then
        sleep $WAIT_TIME
    else
        break
    fi
done

if [ -x /usr/sbin/nft ]; then
    nftables=/usr/sbin/nft
else
    actzTrace "XSETNETF: enableRemoteAccess: No nft executable found."
    exit 0
fi
if [ -f /tmp/mfginstallnetw.properties ]; then
    . /tmp/mfginstallnetw.properties
fi
/usr/hmcrbin/chhmc -c network -i $NETWINTF -s modify -a $NETWIPADDR -nm $NETWNETMASK
if [ $? -eq 0 ]; then
    /usr/hmcrbin/chhmc -c network -i $NETWINTF -s modify -g $NETWGATEWAY
    if [ $? -eq 0 ]; then
        $nftables add rule ip filter INPUT tcp dport 22 counter accept
        if [ $? -eq 0 ]; then
            echo "ssh.name|0.0.0.0|0.0.0.0" >> /opt/ccfw/data/FirewallSettings.$NETWINTF-NETAPP-INPUT
            echo "ssh.name|::|::" >> /opt/ccfw/data/FirewallSettings.$NETWINTF-NETAPP-INPUT
	fi
    fi
fi
