# IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # websm720 src/sysmgt/cfgassist/com/ibm/cfgassist/apps/wsmconfig/setup_dhcp.sh 1.1 # # Licensed Materials - Property of IBM # # Restricted Materials of IBM # # COPYRIGHT International Business Machines Corp. 2011 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG RC=0 STATE="NONE" OUTPUT="" LCURLY="{" RCURLY="}" for i in $* do case "$STATE" in "NONE") if [ "$i" = "interface" ] then STATE="interface" elif [ "$i" = "when" ] then STATE="when" elif [ "$i" = ":option" ] then STATE="option" fi ;; "when") WHEN=$i STATE="NONE" ;; "interface") INTERFACE=$i if [ "$OUTPUT" = "" ] then OUTPUT="interface $i\n$LCURLY" else OUTPUT=$OUTPUT"\ninterface $i\n$LCURLY" fi STATE="NONE" ;; "option") NUM=$i STRING="" STATE="optionnum" ;; "optionnum") if [ "$i" = ":option" ] then STATE="option" if [ "$NUM" = "12" ] || [ "$NUM" = "14" ] || [ "$NUM" = "15" ] || [ "$NUM" = "17" ] || [ "$NUM" = "18" ] || [ "$NUM" = "40" ] || [ "$NUM" = "43" ] || [ "$NUM" = "47" ] || [ "$NUM" = "53" ] || [ "$NUM" = "56" ] then if [ "$OUTPUT" = "" ] then OUTPUT=" option $NUM \"$STRING\"" else OUTPUT=$OUTPUT"\n option $NUM \"$STRING\"" fi else if [ "$OUTPUT" = "" ] then OUTPUT=" option $NUM $STRING" else OUTPUT=$OUTPUT"\n option $NUM $STRING" fi fi else if [ "$STRING" = "" ] then STRING=$i else STRING=$STRING" "$i fi fi ;; esac done if [ "$STATE" = "optionnum" ] then if [ "$NUM" = "12" ] || [ "$NUM" = "14" ] || [ "$NUM" = "15" ] || [ "$NUM" = "17" ] || [ "$NUM" = "18" ] || [ "$NUM" = "40" ] || [ "$NUM" = "43" ] || [ "$NUM" = "47" ] || [ "$NUM" = "53" ] || [ "$NUM" = "56" ] then if [ "$OUTPUT" = "" ] then OUTPUT=" option $NUM \"$STRING\"" else OUTPUT=$OUTPUT"\n option $NUM \"$STRING\"" fi else if [ "$OUTPUT" = "" ] then OUTPUT=" option $NUM $STRING" else OUTPUT=$OUTPUT"\n option $NUM $STRING" fi fi fi if [ "$OUTPUT" = "" ] then continue else OUTPUT=$OUTPUT"\n$RCURLY\n" fi # Remove interface EAT="0" rm -rf /tmp/dhcpcd.ini.$$ exec 3< /etc/dhcpcd.ini while read -u3 -r line do if [ "$EAT" = "0" ] && [ "${line#interface }" != "$line" ] then HERE=${line#*interface } WORKINGIF=${HERE%%( )+([a-zA-Z0-9 \t])*} fi if [ "$EAT" != 0 ] || ([ "$WORKINGIF" != "" ] && ([ "$INTERFACE" = "$WORKINGIF" ] || [ "$INTERFACE" = "any" ] || ([ "$INTERFACE" != "any" ] && [ "$WORKINGIF" = "any" ]))) then if [ "$EAT" = "0" ] then EAT="1" elif [ "$EAT" = "1" ] then if [ "$line" = "{" ] then EAT="2" else EAT="0" WORKINGIF="" echo $line >> /tmp/dhcpcd.ini.$$ fi elif [ "$EAT" = "2" ] then if [ "$line" = "}" ] then EAT="0" WORKINGIF="" fi fi else echo $line >> /tmp/dhcpcd.ini.$$ fi done exec 3<&- mv /etc/dhcpcd.ini /etc/dhcpcd.ini.bak mv /tmp/dhcpcd.ini.$$ /etc/dhcpcd.ini # Add interface back echo $OUTPUT >> /etc/dhcpcd.ini if [ "$WHEN" = "1" ] then echo $WHEN > /dev/null elif [ "$WHEN" = "2" ] then startsrc -s dhcpcd RC=$? else if [ "$WHEN" = "3" ] then /usr/sbin/chrctcp -a dhcpcd RC=$? else /usr/sbin/chrctcp -S -a dhcpcd RC=$? fi # Change USE_DHCP=0 to USE_DHCP=1 in /etc/rc.net cp /etc/rc.net /tmp/rc.net.$$ sed "s/USE_DHCP=\"0\"/USE_DHCP=\"1\"/" /tmp/rc.net.$$ > /etc/rc.net chmod 550 /etc/rc.net rm -f /tmp/rc.net.$$ # Change USE_DHCP=0 to USE_DHCP=1 in /etc/rc.bsdnet cp /etc/rc.bsdnet /tmp/rc.bsdnet.$$ sed "s/USE_DHCP=\"0\"/USE_DHCP=\"1\"/" /tmp/rc.bsdnet.$$ > /etc/rc.bsdnet chmod 550 /etc/rc.bsdnet rm -f /tmp/rc.bsdnet.$$ fi return $RC