--- alx-src/trunk/alxconfig-ng/init.d/alxsetstate 2005/03/08 20:49:14 221 +++ alx-src/trunk/alxconfig-ng/init.d/alxsetstate 2005/08/28 19:30:25 306 @@ -1,7 +1,5 @@ #!/bin/bash -#startup seq: K01 Level {0,6} | S99 Level {3,4,5} - #%rlevels: 3:s 4:s 5:s 0:k 6:k #%start: 99 #%stop: 01 @@ -11,13 +9,15 @@ #%before: #%after: +# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsetstate,v 1.8 2005-08-28 19:30:25 niro Exp $ + source /etc/sysconfig/rc source $rc_functions #mysql settings -source /etc/alx-config/config.rc -source /opt/alx-config/functions/mysqlfunctions -source /opt/alx-config/functions/alx-mysql-functions +source /etc/alxconfig-ng/config.rc +source /usr/lib/alxconfig-ng/functions/mysqlfunctions +source /usr/lib/alxconfig-ng/functions/serial_functions #check if mysql is available [ -x /usr/bin/mysql ] && MYSQL_ALX=true @@ -29,9 +29,9 @@ unset ALX_SERIAL ALX_STATE #get current system state -if [ -f /etc/alx-config/state/state ] +if [ -f /etc/alxconfig-ng/state/state ] then - source /etc/alx-config/state/state + source /etc/alxconfig-ng/state/state else ALX_STATE=error fi @@ -51,7 +51,11 @@ # validate current serial if ! validate_serial "${ALX_SERIAL}" "${ALX_REG_DATE}" "${CUR_MAC}" then + # abort on non valid serial ALX_STATE="invalid serial" + echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state + show_invalid_serial_msg + exit 1 fi #first check if an entry exist with my serial @@ -76,8 +80,6 @@ state='${ALX_STATE}', mtime='${CUR_MTIME}' where serial=${ALX_SERIAL};" - - evaluate_retval else #run an insert @@ -103,7 +105,6 @@ '${ALX_STATE}', '${CUR_MTIME}' );" - evaluate_retval fi } @@ -113,6 +114,9 @@ # nice name is alx_connected_state or sth like this unset_alx_connected(){ local SQL_OPTS + local CUR_MAC + + CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11) echo -e ${COLMAGENTA}"Unregister system from database"${COLDEFAULT} @@ -124,9 +128,9 @@ ########### starts here ################ #first of all get current system serial -if [ -f /etc/alx-config/serial ] +if [ -f /etc/alxconfig-ng/serial ] then - source /etc/alx-config/serial + source /etc/alxconfig-ng/serial else ALX_SERIAL=0 fi @@ -134,14 +138,24 @@ case $1 in start) - + # check if mysql server is reachable + # if not abort this script + reach_mysql_server || exit 1 + set_current_network_state + evaluate_retval ;; stop) + # check if mysql server is reachable + # if not abort this script + reach_mysql_server || exit 1 + unset_alx_connected + evaluate_retval ;; *) echo "Usage: $0 {start|stop} ..." ;; -esac \ No newline at end of file +esac +