Magellan Linux

Diff of /alx-src/branches/alxconf-060/init.d/alxsettings

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

revision 282 by niro, Wed Aug 17 21:19:52 2005 UTC revision 314 by niro, Wed Aug 31 23:55:22 2005 UTC
# Line 11  Line 11 
11  #%before:  #%before:
12  #%after:  #%after:
13    
14  # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.15 2005-08-17 21:19:52 niro Exp $  # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/init.d/alxsettings,v 1.20 2005-08-31 23:55:22 niro Exp $
15    
16  # checks first if the client was already configured and if it has an valid serial  # checks first if the client was already configured and if it has an valid serial
17  # if not it runs the autoconfiguration script  # if not it runs the autoconfiguration script
# Line 88  get_system_serial(){ Line 88  get_system_serial(){
88   then   then
89   source /etc/alxconfig-ng/serial   source /etc/alxconfig-ng/serial
90    
  # doing this now before this function gets called  
91   # start preliminary networking (dhcp)   # start preliminary networking (dhcp)
92   # preliminary_network start   preliminary_network start
93    
94     # check if mysql server is reachable
95     # if not abort this script
96     if ! reach_mysql_server
97     then
98     preliminary_network stop
99     exit 1
100     fi
101    
102   CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp')   CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp')
103   CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11)   CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11)
# Line 107  get_system_serial(){ Line 114  get_system_serial(){
114   then   then
115   ALX_STATE="ok"   ALX_STATE="ok"
116   else   else
117     # abort on non valid serial
118   ALX_STATE="invalid serial"   ALX_STATE="invalid serial"
119     echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state
120     show_invalid_serial_msg
121     exit 1
122   fi   fi
123    
124   else   else
# Line 115  get_system_serial(){ Line 126  get_system_serial(){
126   echo   echo
127   if [ -f /hardware-auto-detection ]   if [ -f /hardware-auto-detection ]
128   then   then
129   echo -e ${COLMAGENTA}"Hardware-Auto-Detection forced by system-administrator"${COLDEFAULT}   echo -e ${COLMAGENTA}"Hardware autodetection forced by system-administrator"${COLDEFAULT}
130   else   else
131   echo -e ${COLMAGENTA}"Preparing system for first boot"${COLDEFAULT}   echo -e ${COLMAGENTA}"Preparing system for first boot"${COLDEFAULT}
132   fi   fi
# Line 134  get_system_serial(){ Line 145  get_system_serial(){
145   # start preliminary networking (dhcp)   # start preliminary networking (dhcp)
146   preliminary_network start   preliminary_network start
147    
148     # check if mysql server is reachable
149     # if not abort this script
150     if ! reach_mysql_server
151     then
152     preliminary_network stop
153     exit 1
154     fi
155    
156   CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp')   CUR_IP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp')
157   CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11)   CUR_MAC=$(/sbin/ifconfig eth0 | grep HWaddr | cut -d ' ' -f11)
158   CUR_MTIME=$(date +%s)   CUR_MTIME=$(date +%s)
# Line 155  get_system_serial(){ Line 174  get_system_serial(){
174   then   then
175   ALX_STATE="ok"   ALX_STATE="ok"
176   else   else
177     # abort on non valid serial
178   ALX_STATE="invalid serial"   ALX_STATE="invalid serial"
179     echo "ALX_STATE=${ALX_STATE}" > /etc/alxconfig-ng/state/state
180     show_invalid_serial_msg
181     exit 1
182   fi   fi
183    
184   # write current state to temp file   # write current state to temp file
# Line 173  get_system_serial(){ Line 196  get_system_serial(){
196   # request new serial   # request new serial
197   # ALX_REG_DATE="$(date +%F)"   # ALX_REG_DATE="$(date +%F)"
198    
199   # we're using the mtime now (better for vaildating the serial)   # we're using the mtime now (better for validating the serial)
200   mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  # mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
201   "insert into client_serials(  # "insert into client_serials(
202   mtime,  # mtime,
203   mac  # mac
204   )  # )
205   values(  # values(
206   '${CUR_MTIME}',  # '${CUR_MTIME}',
207   '${CUR_MAC}'  # '${CUR_MAC}'
208   );"  # );"
209    #
210   # then validate and retrieve serial  # # then validate and retrieve serial
211    #
212   ### warning must be changed that only the LAST ID will be fetched,  ###  # ### warning must be changed that only the LAST ID will be fetched,  ###
213   ### or you get error if the computer name and date are the same     ###  # ### or you get error if the computer name and date are the same     ###
214   ### you have more than one serial number then                       ###  # ### you have more than one serial number then                       ###
215    #
216    # # select highest id only (added max)
217    # ALX_SERIAL=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
218    # "select max(serial) from client_serials where mtime='${CUR_MTIME}' and mac='${CUR_MAC}'")
219    
220   # select highest id only (added max)   # request a new serial; one command now (cause must be done in the same session)
221   ALX_SERIAL=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   ALX_SERIAL=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \
222   "select max(serial) from client_serials where mtime='${CUR_MTIME}' and mac='${CUR_MAC}'")   "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}');
223     select last_insert_id();")
224    
225   if [ "${ALX_SERIAL}" != NULL ]   if [ "${ALX_SERIAL}" != NULL ]
226   then   then
# Line 421  import_settings_local(){ Line 449  import_settings_local(){
449   # set system state to 'already configured'   # set system state to 'already configured'
450   touch /etc/alxconfig-ng/state/configured   touch /etc/alxconfig-ng/state/configured
451    
452     # if only an recheck was forced than abort now
453     [[ ${ALX_FORCED_RECHECK} = true ]] && return 0
454    
455   # create a fresh fluxbox directory   # create a fresh fluxbox directory
456   [ -d ${ALX_UNPRIV_HOME}/.fluxbox ] && rm -rf ${ALX_UNPRIV_HOME}/.fluxbox   [ -d ${ALX_UNPRIV_HOME}/.fluxbox ] && rm -rf ${ALX_UNPRIV_HOME}/.fluxbox
457   install -d ${ALX_UNPRIV_HOME}/.fluxbox   install -d ${ALX_UNPRIV_HOME}/.fluxbox
# Line 435  import_settings_local(){ Line 466  import_settings_local(){
466   cat ${ALX_SKELETONS}/fluxbox/menu.header \   cat ${ALX_SKELETONS}/fluxbox/menu.header \
467   > ${ALX_UNPRIV_HOME}/.fluxbox/menu   > ${ALX_UNPRIV_HOME}/.fluxbox/menu
468    
469     # now fix it with proper messages :P
470     local ver="$(< /etc/mageversion)"
471     sed -i "s:@CHANGEME@:alx-${ver}  #${ALX_SERIAL}:g" \
472     ${ALX_UNPRIV_HOME}/.fluxbox/menu
473    
474   # add a newline (maybe there is no crlf in the header)   # add a newline (maybe there is no crlf in the header)
475   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
476    
# Line 445  import_settings_local(){ Line 481  import_settings_local(){
481   # add a newline (maybe there is no crlf in the footer)   # add a newline (maybe there is no crlf in the footer)
482   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   echo >> ${ALX_UNPRIV_HOME}/.fluxbox/menu
483    
484    
485     # setup some standart icons (sysinfo.lnk)
486     # basic config
487     cat ${ALX_SKELETONS}/xtdesktop/xtdeskrc > ${ALX_UNPRIV_HOME}/.xtdeskrc
488    
489     # clean desktop icon location
490     [ -d ${ALX_UNPRIV_HOME}/.xtdesktop ] && rm -rf ${ALX_UNPRIV_HOME}/.xtdesktop
491     install -d ${ALX_UNPRIV_HOME}/.xtdesktop
492    
493     # last but not least gen a icon with some sys informations
494     local sysinfo
495     local osversion
496     local xres
497     local yres
498    
499     osversion="$(< /etc/mageversion)"
500     sysinfo="Hostname: ${ALX_DEFAULT_HOSTNAME} Serial: #${ALX_SERIAL} OS: alx-${osversion} Kernel: $(uname -r)"
501    
502     # at first boot we got always a resolution of 1024x768-16@60
503     # middle of the screen
504     # (no txt - length required, xtdesk manage that itself)
505     xres="$((1024 / 2))"
506     # default y pos (full yres -22 !)
507     yres="$((768 - 22 ))"
508    
509     generate_icon \
510     --name "${sysinfo}" \
511     --command "exit 0" \
512     --icon "${ALX_SESSIONS_ICONS}/sysinfo.png" \
513     --dest "${ALX_UNPRIV_HOME}/.xtdesktop/sysinfo.lnk" \
514     --xres "${xres}" \
515     --yres "${yres}" \
516     --icon-width "1" \
517     --icon-height "1"
518    
519   # set correct permissions   # set correct permissions
520   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}
521   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox   chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}/.fluxbox
522   chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox   chmod 0755 ${ALX_UNPRIV_HOME}/.fluxbox
523   chmod 0755 ${ALX_UNPRIV_HOME}/.idesktop   chmod 0755 ${ALX_UNPRIV_HOME}/.xtdesktop
524   chmod 0644 ${ALX_UNPRIV_HOME}/.ideskrc   chmod 0644 ${ALX_UNPRIV_HOME}/.xtdeskrc
525    
526   # default passwords are bad   # default passwords are bad
527   #usermod -p $(perl -e "printf(crypt('foobar','AD'))") root   #usermod -p $(perl -e "printf(crypt('foobar','AD'))") root
# Line 523  preliminary_network(){ Line 594  preliminary_network(){
594    
595  case $1 in  case $1 in
596   start)   start)
  # start preliminary networking (dhcp)  
  preliminary_network start  
   
  # check if mysql server is reachable  
  # if not abort this script  
  if ! reach_mysql_server  
  then  
  preliminary_network stop  
  exit 1  
  fi  
   
597   # retrieve or validate current serial   # retrieve or validate current serial
598   get_system_serial   get_system_serial
599   if [[ ${ALX_HW_DETECT} = true ]]   if [[ ${ALX_HW_DETECT} = true ]]

Legend:
Removed from v.282  
changed lines
  Added in v.314