--- alx-src/branches/alxconf-060/init.d/alxsetstate 2011/05/16 20:49:07 2140 +++ alx-src/branches/alxconf-060/init.d/alxsetstate 2011/05/17 10:51:57 2141 @@ -15,8 +15,10 @@ # mysql settings source /etc/alxconfig-ng/config.rc +# helper functions source /usr/lib/alxconfig-ng/functions/mysqlfunctions source /usr/lib/alxconfig-ng/functions/serial_functions +source /usr/lib/alxconfig-ng/functions/common # unset vars which may kill us unset ALX_SERIAL ALX_STATE ALX_IFACE @@ -42,7 +44,7 @@ { local CUR_IP CUR_MAC ID - echo -e ${COLMAGENTA}"Register system to database"${COLDEFAULT} + rc_mecho "Register system to database" CUR_IP=$(/sbin/ifconfig ${ALX_IFACE} | sed -n '/addr:/s/ [^r]*..//gp') CUR_MAC=$(/sbin/ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11) @@ -69,7 +71,7 @@ # nice status $CURS_UP $SET_WCOL - echo "[ SN: ${ALX_SERIAL}, U, ${ALX_STATE} ]" + rc_echo "[ SN: ${ALX_SERIAL}, U, ${ALX_STATE} ]" mysqldo "update state_connected set hostname='${HOSTNAME}', @@ -84,7 +86,7 @@ # nice status $CURS_UP $SET_WCOL - echo "[ SN: ${ALX_SERIAL}, N, ${ALX_STATE} ]" + rc_echo "[ SN: ${ALX_SERIAL}, N, ${ALX_STATE} ]" mysqldo "insert into state_connected( serial, @@ -116,13 +118,13 @@ CUR_MAC=$(/sbin/ifconfig ${ALX_IFACE} | grep HWaddr | cut -d ' ' -f11) - echo -e ${COLMAGENTA}"Unregister system from database"${COLDEFAULT} + rc_mecho "Unregister system from database" # nice status $CURS_UP $SET_WCOL - echo "[ SN: ${ALX_SERIAL} ]" - + rc_echo "[ SN: ${ALX_SERIAL} ]" + mysqldo "delete from state_connected where serial='${ALX_SERIAL}' and mac='${CUR_MAC}';" evaluate_retval }