Magellan Linux

Diff of /alx-src/trunk/tinyalxconfig-ng/functions/mysqlfunctions

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 449 by niro, Wed Jun 4 21:06:16 2008 UTC revision 450 by niro, Thu Jun 5 18:01:41 2008 UTC
# Line 6  Line 6 
6  #  #
7  # Niels Rogalla <niro@magellan-linux.de>  # Niels Rogalla <niro@magellan-linux.de>
8  #  #
9  # $Header: /home/cvsd/alx-cvs/alx-src/tinyalxconfig-ng/functions/mysqlfunctions,v 1.2 2008-06-04 21:06:16 niro Exp $  # $Header: /home/cvsd/alx-cvs/alx-src/tinyalxconfig-ng/functions/mysqlfunctions,v 1.3 2008-06-05 18:01:41 niro Exp $
10    
11  mysql_command()  mysql_command()
12  {  {
# Line 148  mysqldo() Line 148  mysqldo()
148   "$@" \   "$@" \
149   && return 0 || return 1   && return 0 || return 1
150  }  }
151    
152    # read tables and evaluate all variables
153    # cmd:    evaluate_tables cfg_network
154    # result: cfg_network_hostname=DUMMY_HOSTNAME
155    evaluate_tables()
156    {
157     local all_vars
158     local all_items
159     local i
160     local COUNT
161     local serial
162    
163     local table="$1"
164    
165     if [[ -z $2 ]]
166     then
167     serial="${ALX_SERIAL}"
168     else
169     serial="$2"
170     fi
171    
172     # setup arrays
173     all_vars=( $(mysql_enum_colums ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} ${table} show) )
174     all_items=( $(mysqldo "select * from ${table}") )
175    
176     # sanity check
177     if [[ ${#all_vars[*]} = ${#all_items[*]} ]]
178     then
179     echo "error: arrays does not match!"
180     fi
181    
182     COUNT=${#all_vars[*]}
183     for ((i=0;i < COUNT; i++))
184     do
185     eval $(echo ${table}_${all_vars[${i}]}=\${all_items[${i}]})
186     export ${table}_${all_vars[${i}]}
187     done
188    }

Legend:
Removed from v.449  
changed lines
  Added in v.450