#!/bin/bash # functions_mysql_update source /etc/alx-config/config.rc source /opt/alx-config/functions/mysqlfunctions source /etc/alx-config/serial #get all settings #network if [ -f $SETTINGS_TEMPLATE/system/network/networking ] then networking="$( < $SETTINGS_TEMPLATE/system/network/networking)" else networking="" fi if [ -f $SETTINGS_TEMPLATE/system/network/hostname ] then hostname="$( < $SETTINGS_TEMPLATE/system/network/hostname)" else hostname="" fi if [ -f $SETTINGS_TEMPLATE/system/network/domain ] then domain="$( < $SETTINGS_TEMPLATE/system/network/domain)" else domain="" fi if [ -f $SETTINGS_TEMPLATE/system/network/ip ] then ip="$( < $SETTINGS_TEMPLATE/system/network/ip)" else ip="" fi if [ -f $SETTINGS_TEMPLATE/system/network/netmask ] then netmask="$( < $SETTINGS_TEMPLATE/system/network/netmask)" else netmask="" fi if [ -f $SETTINGS_TEMPLATE/system/network/broadcast ] then broadcast="$( < $SETTINGS_TEMPLATE/system/network/broadcast)" else broadcast="" fi if [ -f $SETTINGS_TEMPLATE/system/network/gateway ] then gateway="$( < $SETTINGS_TEMPLATE/system/network/gateway)" else gateway="" fi if [ -f $SETTINGS_TEMPLATE/system/network/dns ] then dns="$( < $SETTINGS_TEMPLATE/system/network/dns)" else dns="" fi if [ -f $SETTINGS_TEMPLATE/system/modules/modules ] then modules="$( < $SETTINGS_TEMPLATE/system/modules/modules)" else modules="" fi #write the stuff to mysql db mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ "update cfg_network set module='${modules}', domain='${domain}', networking='${networking}', netmask='${netmask}', dns='${dns}', gateway='${gateway}', broadcast='${broadcast}', ip='${ip}' where serial=${ALX_SERIAL};" #update hostname mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ "update cfg_serial set hostname='${hostname}' where id=${ALX_SERIAL};" #vga if [ -f $SETTINGS_TEMPLATE/system/mouse/mouse ] then mouseprot="$( < $SETTINGS_TEMPLATE/system/mouse/mouse)" else mouseprot="" fi if [ -f $SETTINGS_TEMPLATE/system/vga/vga ] then vgadrv="$( < $SETTINGS_TEMPLATE/system/vga/vga)" else vgadrv="" fi if [ -f $SETTINGS_TEMPLATE/system/vga/vgadepth ] then vgadepth="$( < $SETTINGS_TEMPLATE/system/vga/vgadepth)" else vgadepth="" fi if [ -f $SETTINGS_TEMPLATE/system/vga/vgares ] then resolution="$( < $SETTINGS_TEMPLATE/system/vga/vgares)" else resolution="" fi mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ "update cfg_grafik set module='${vgadrv}', resolution='${resolution}', depth='${vgadepth}', mouse='${mouseprot}' where serial=${ALX_SERIAL};" #sessions if [ -f $SETTINGS_TEMPLATE/system/sessions/sessions ] then sessions="$( < $SETTINGS_TEMPLATE/system/sessions/sessions)" else sessions="" fi if [ -n "${sessions}" ] then #first delete all sessions with serial=${ALX_SERIAL} mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ "delete from cfg_session where serial='${ALX_SERIAL}';" #than add them for i in ${sessions} do mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ "insert into cfg_session( serial, session ) values( '${ALX_SERIAL}', '${i}' );" done fi #printers #monitors if [ -f $SETTINGS_TEMPLATE/system/monitor/monitor ] then source $SETTINGS_TEMPLATE/system/monitor/monitor else myvendor="" mymodel="" hsync="" vref="" fi mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ "update cfg_monitor set vendor='${myvendor}', model='${mymodel}', hsync='${hsync}', vrefresh='${vref}' where serial=${ALX_SERIAL};"