--- alx-src/trunk/alxconfig-ng/init.d/alxsettings 2005/03/09 00:04:23 227 +++ alx-src/trunk/alxconfig-ng/init.d/alxsettings 2005/04/18 22:59:49 264 @@ -11,7 +11,7 @@ #%before: #%after: -# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.3 2005-03-09 00:04:23 niro Exp $ +# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.12 2005-04-18 22:59:49 niro Exp $ # checks first if the client was already configured and if it has an valid serial # if not it runs the autoconfiguration script @@ -28,9 +28,13 @@ source /etc/alxconfig-ng/config.rc source /usr/lib/alxconfig-ng/functions/mysqlfunctions source /usr/lib/alxconfig-ng/functions/serial_functions +source /usr/lib/alxconfig-ng/functions/config_modules source /usr/lib/alxconfig-ng/functions/config_network source /usr/lib/alxconfig-ng/functions/config_printers +source /usr/lib/alxconfig-ng/functions/config_sessions source /usr/lib/alxconfig-ng/functions/config_x11 +source /usr/lib/alxconfig-ng/functions/config_auth +source /usr/lib/alxconfig-ng/functions/config_ssh_auth #check if mysql is available [ -x /usr/bin/mysql ] && MYSQL_ALX=true @@ -46,86 +50,30 @@ [ ! -d /etc/alxconfig-ng/state ] && install -d /etc/alxconfig-ng/state -validate_sessions(){ - - local x i all LOCAL_SESSIONS DB_SESSIONS SETTINGSPATH count - - #all arrays: - # -> session1 session2 ... sessionN - - - #no LOCAL_SESSIONS here, needs bubblesort - - #get settings from database - all=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ - "select session from cfg_sessions where serial='${ALX_SERIAL}'") - - #split'em up and put in an array (only if $all not zero) - declare -i i=0 - if [ -n "${all}" ] - then - for x in ${all} - do - DB_SESSIONS[${i}]=${x} - ((i++)) - done - count=${i} - else - count=0 - fi - - ## no compare here, can only done with bubblesort or s.th like that - # shows only the new sessions - declare -i i=0 - #count=${#DB_SESSIONS[*]} #---> not working gets always 1, why ? - - echo "Number of new sessions: ${count}" - for ((i=0; i < count; i++)) - do - echo "${i} - ${DB_SESSIONS[${i}]}" - done - - #update local configs - SETTINGSPATH=${SETTINGS_TEMPLATE}/menu - declare -i i=0 - - #count=${#DB_SESSIONS[*]} - - if [ ${count} -gt 0 ] - then - #create directory if not exist - [ ! -d ${SETTINGSPATH}/sessions ] && install -d ${SETTINGSPATH}/sessions - - #delete old sessions - echo -n > ${SETTINGSPATH}/sessions/sessions - - for ((i=0; i < count; i++)) - do - echo "${DB_SESSIONS[${i}]}" >> ${SETTINGSPATH}/sessions/sessions - done - - #set update flag - ALX_SESSION_SETUP=true - fi -} - - update_system_settings(){ echo -e ${COLMAGENTA}"Checking system setup ..."${COLDEFAULT} + # get the modules settings + # ! is the first thing that must be configured ! + config_modules + # imports network settings from db config_networking # imports x11 settings from db config_x11 - #echo - #echo "sessions" - #validate_sessions - #echo + # imports session settings from db + config_sessions # imports printer settings from db config_printing + + # imports auth settings from db + config_auth + + # exchange ssh rsa keys + config_ssh_auth } get_system_serial(){ @@ -137,10 +85,6 @@ then source /etc/alxconfig-ng/serial - # if system is already configured, it *has* a hostname. - # so we take the hostname of this system here - source /etc/hostname - #start preliminary networking (dhcp) preliminary_network start @@ -174,7 +118,7 @@ HOSTNAME="${ALX_DEFAULT_HOSTNAME}" #update the hostname on the system for sure - echo "HOSTNAME=${HOSTNAME}" > /etc/hostname + echo "${HOSTNAME}" > /etc/hostname #start preliminary networking (dhcp) preliminary_network start @@ -257,23 +201,23 @@ import_settings_to_db() { #note: networking is always 'dhcp' if hw was autodetected #note: default_domain/hostname is set in config.rc - + #to be safe, we do some sanity checks [ -z "${ALX_DEFAULT_DOMAIN}" ] && ALX_DEFAULT_DOMAIN=localdomain [ -z "${ALX_DEFAULT_HOSTNAME}" ] && ALX_DEFAULT_HOSTNAME=magellan-alx - + #vars used by hwdetect local NETCARD_FULLNAME NETCARD_DRIVER MOUSE_FULLNAME MOUSE_DEVICE SOUND_FULLNAME local SOUND_DRIVER XSERVER XMODULE XDESC FLOPPY_FULLNAME FLOPPY_DEVICE FLOPPY_DRIVER local MOUSETYPE XMOUSETYPE FULLNAME DEVICE - + #get setting from hwdetect source /etc/sysconfig/hwsetup/knoppix source /etc/sysconfig/hwsetup/mouse - + echo echo -e ${COLMAGENTA}"Importing detected settings to database"${COLDEFAULT} - + #network echo -e " Network settings ..." mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ @@ -292,7 +236,7 @@ 'dhcp' );" evaluate_retval - + #xserver echo -e " Graphic settings ..." #xserver general @@ -301,34 +245,55 @@ serial, module, resolution, - depth + depth, + monitorid ) values( '${ALX_SERIAL}', '${XMODULE}', '1024x768', - '16' - );"; - #xserver monitor - mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ - "insert into cfg_monitor( + '16', + '0' + );"; ) + evaluate_retval + + # input + echo -e " Input settings ..." + mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ + "insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');" + evaluate_retval + + # auth + echo -e " Authentifcation settings ..." + mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ + "insert into client_auth( serial, - vendor, - model, - hsync, - vrefresh + username, + shell, + vnc, + samba, + station ) values( '${ALX_SERIAL}', - 'Aamazing', - 'CM-1528-FS', - '28-64', - '47-104' - );"; - + '${ALX_UNPRIV_USER}', + '', + '', + '', + '' + );" + evaluate_retval + + # exchange ssh rsa keys - the first boot needs this ! + # or no reboot will work via the webadmin + echo -e " SSH authentifcation settings ..." + HOME=/root config_ssh_auth + evaluate_retval + # input - mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ - "insert into cfg_input(serial,mouse) values('${ALX_SERIAL}','${XMOUSETYPE}');";) + echo -e " Autostart settings ..." + mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ + "insert into cfg_autostart(serial,session) values('${ALX_SERIAL}','');" evaluate_retval } @@ -359,6 +324,11 @@ #set system state to 'already configured' touch /etc/alxconfig-ng/state/configured + + # default passwords are bad + #usermod -p $(perl -e "printf(crypt('foobar','AD'))") root + #usermod -p $(perl -e "printf(crypt('foobar','AD'))") ${ALX_UNPRIV_USER} + #smbpasswd -a root foobar } #start|stop @@ -431,8 +401,13 @@ then import_settings_to_db import_settings_local + + # here we should also exchange the ssh keys + # or the system cannot be rebooted after + # the first start via the alx-webadmin + config_ssh_auth fi - + #now setup system configuration #alx_setup_or_whatever_it_will_be_called() [ "${ALX_HW_DETECT}" == "false" ] && update_system_settings @@ -451,3 +426,4 @@ echo "Usage: $0 {start|stop} ..." ;; esac +