Check-in [1fc00656bd]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview

SHA1 Hash:1fc00656bdcfaa34b2e6937f7f36c3f44277880a
Date: 2012-02-27 01:48:22
User: BarryK
Comment:QuickSetup now has hostname entry box, but only if auto ethernet internet connection on first boot

Tags And Properties
Changes

Changes to woof-code/rootfs-skeleton/usr/sbin/hostname-set

@@ -5,10 +5,11 @@
 #111028 fully internationalised.
 #111103 gcmartin: accept '-' char in hostname.
 #111103 gcmartin: current hostname is $HOSTNAME, but if rerun this script before restarting X, need to get from /etc/hostname.
 #111106 fix passed hostname from connectwizard.
 #111117 shinobar: fix.
+#120227 can also be called from quicksetup. now have exit #
 
 export TEXTDOMAIN=hostname-set
 export OUTPUT_CHARSET=UTF-8
 
 #111103 current hostname is $HOSTNAME, but if rerun this script before restarting X, need to get from here...
@@ -50,28 +51,27 @@
 
  NEW_HOSTNAME="`echo -n "$ENTRY_HOSTNAME" | sed -e 's%[^0-9a-zA-Z-]%%g'`" #111103 gcmartin: accept '-' char.
 fi
 
 if [ "$NEW_HOSTNAME" != "$HOSTNAME" ];then
-
  hostname $NEW_HOSTNAME
  echo -n $NEW_HOSTNAME > /etc/hostname
  echo "127.0.0.1 localhost $NEW_HOSTNAME" > /tmp/hostname-set-hosts
  grep -vw 'localhost'  /etc/hosts >> /tmp/hostname-set-hosts
  [ -s /tmp/hostname-set-hosts ] && mv -f /tmp/hostname-set-hosts /etc/hosts
-
  M_h1=$(gettext 'Set Hostname: done')
  M_h2a=$(gettext 'New hostname')
  M_h2b=$(gettext 'has been set.')
  M_h3=$(gettext 'However, it will not take full effect until after X (the desktop) has been restarted.')
  pupdialog --title "${M_h1}" --msgbox "${M_h2a} '${NEW_HOSTNAME}' ${M_h2b}
 ${M_h3}" 0 0
-
+ exit 0
 else #111028
  M_h4=$(gettext 'Set Hostname')
  M_h5a=$(gettext 'The hostname is:')
  M_h5b=$(gettext 'You have not changed it.')
  pupdialog --title "${M_h4}" --msgbox "${M_h5a} '${NEW_HOSTNAME}'
 ${M_h5b}" 0 0
+ exit 1
 fi
 
 ###END###

Changes to woof-code/rootfs-skeleton/usr/sbin/quicksetup

@@ -26,10 +26,11 @@
 #120215 rc.country calls 'chooselocale cli quiet', to run localedef without asking any questions or popups.
 #120216 insert /PUPPYKEYMAP into initrd. moved SET_KEYBOARD before SET_LOCALE processing.
 #120216 call 'lang2initrd'
 #120224 load console font. (code based on that in 'init')
 #120226 redraw desktop drive icons when resolution changes (or may change, in the case of running xorgwizard).
+#120227 set hostname, but only if ethernet auto-connected at 1st boot.
 
 [ "`whoami`" != "root" ] && exec sudo -A ${0} ${@}
 
 export TEXTDOMAIN=quicksetup
 export OUTPUT_CHARSET=UTF-8
@@ -51,21 +52,21 @@
 [ "$PARAM1" = "composeonly" ] && unset DISPLAY
 [ "$PARAM1" = "cli" ] && unset DISPLAY
 
 MYBASE=$(basename $0)
 WINICON="gtk-preferences"; HELPICON="gtk-index" #gtk-info
-SET_LOCALE=""; SET_TIMEZONE=""; SET_KEYBOARD=""; SET_X=""; SET_COUNTRY=""; SET_XRES=""; SET_XWIZARD=""
+SET_LOCALE=""; SET_TIMEZONE=""; SET_KEYBOARD=""; SET_X=""; SET_COUNTRY=""; SET_XRES=""; SET_XWIZARD=""; SET_NETWORK=""
 SET_WINTITLE="1"; SET_COUNTRYFRAMETITLE="1"; SET_XFRAMETITLE="1"; SET_BACKTITLE="1"
 #[ "$DISTRO_XORG_AUTO" = "yes" ] && SET_XRES="yes"
 #specific-purpose utilities...
 case $MYBASE in
  chooselocale) SET_WINTITLE="2"; SET_COUNTRYFRAMETITLE="2"; SET_LOCALE="yes"; SET_BACKTITLE="2" ;;
  timezone-set) SET_WINTITLE="3"; SET_COUNTRYFRAMETITLE="3"; SET_TIMEZONE="yes"; SET_BACKTITLE="3" ;;
  quickcountry) SET_WINTITLE="4"; SET_LOCALE="yes"; SET_TIMEZONE="yes"; SET_KEYBOARD="yes"; SET_BACKTITLE="4" ;;
  countrywizard) SET_WINTITLE="5"; SET_LOCALE="yes"; SET_TIMEZONE="yes"; SET_KEYBOARD="yes"; SET_BACKTITLE="5" ;;
  xrandrshell) SET_WINTITLE="6"; SET_XRES="yes"; SET_BACKTITLE="6"; SET_XFRAMETITLE="6" ;;
- *) SET_LOCALE="yes"; SET_TIMEZONE="yes"; SET_KEYBOARD="yes"; SET_XRES="yes"; SET_XWIZARD="yes" ;;
+ *) SET_LOCALE="yes"; SET_TIMEZONE="yes"; SET_KEYBOARD="yes"; SET_XRES="yes"; SET_XWIZARD="yes"; SET_NETWORK="yes" ;;
 esac
 [ "$SET_LOCALE" -o "$SET_TIMEZONE" -o "$SET_KEYBOARD" ] && SET_COUNTRY="yes"
 [ "$SET_XRES" -o "$SET_XWIZARD" ] && SET_X="yes"
 case $SET_WINTITLE in
  1) WINTITLE=$(gettext "Quick Setup") ;;
@@ -101,10 +102,44 @@
   XPID=$!
  fi
 fi
 
 M_close="`gettext 'Close'`"
+
+###Network###
+#120227 hostname set but only if network connection already available on 1st boot...
+NETWORK_XML=""
+if [ "$SET_NETWORK" ];then
+ SET_NETWORK=""
+ if [ ! -f /var/local/quicksetup-network-check-flag ];then
+  if [ $PUPMODE -eq 5 -o $PUPMODE -eq 2 ];then
+   touch /var/local/quicksetup-network-check-flag
+   if check_internet ;then #case of auto connect to internet via ethernet at 1st boot.
+    SET_NETWORK="yes"
+    HOSTNAME="`cat /etc/hostname`" #do not use $HOSTNAME, as hostname-set may have just been run.
+    H_net=$(gettext "Your computer has been assigned a unique name, known as the 'hostname', by which it identifies itself on a network. However, you might wish to change that to a name that is more meaningful to yourself, such as 'johnsmithpc'. The hostname can have letters and numbers, no spaces.")
+    export DLG_HELP_NET="<window resizable=\"false\" title=\"$(gettext 'Help: Network')\" icon-name=\"${HELPICON}\" window_position=\"1\"><vbox><text use-markup=\"true\"><label>\"${H_net}\"</label><variable>VAR_HELP_NET</variable></text><hbox><button><label>${M_close}</label><action type=\"closewindow\">VAR_HELP_NET</action></button></hbox></vbox></window>"
+    NETWORK_XML="<frame $(gettext 'Network settings')>
+     <hbox>
+      <text><label>\"                                            \"</label></text>
+      <text><label>$(gettext 'Change hostname:')</label></text>
+      <entry tooltip-text=\"$(gettext 'Type your computer name to identify in the network. Alpha-numeric without spaces. Then click button to apply the change.')\" width-chars=\"15\">
+      <input>echo -n \"$HOSTNAME\"</input><variable>ENTRY_HOSTNAME</variable></entry>
+      <button tooltip-text=\"$(gettext 'Click button to apply hostname')\">
+       <input file>/usr/local/lib/X11/mini-icons/mini-hostname.xpm</input>
+       <action>/usr/sbin/hostname-set \$ENTRY_HOSTNAME ; echo \$? > /tmp/quicksetup-hostname-change-flag</action>
+      </button>
+      <button>
+       <input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input>
+       <action type=\"launch\">DLG_HELP_NET</action>
+      </button>
+     </hbox>
+    </frame>"
+   fi
+  fi
+ fi
+fi
 
 ###Country localization###
 if [ "$SET_COUNTRY" ];then
 
  ###Choose locale###
@@ -685,10 +720,11 @@
   </hbox>
   <hbox>
     ${COUNTRYXML}
     ${XXML}
   </hbox>
+  ${NETWORK_XML}
   <hbox>
     <text><label>${M_exit}</label></text>
     <button><label>${B_ok}</label><input file>/usr/local/lib/X11/mini-icons/mini-tick.xpm</input><action>EXIT:OK</action></button>
   </hbox>
 </vbox>
@@ -1038,10 +1074,17 @@
   echo "ICONWIPE" > /var/local/pup_event_icon_change_flag #120226 .xinitrc -> clean_desk_icons will read this, and redraw drive icons. ...actually, redundant, as xorgwizard does this.
  fi
 
 fi #end SET_XWIZARD
 
+if [ "$SET_NETWORK" ];then #120227
+ if [ -s /tmp/quicksetup-hostname-change-flag ];then
+  HOSTNAMEFLAG="`cat /tmp/quicksetup-hostname-change-flag`" #0 if hostname was changed.
+  [ "$HOSTNAMEFLAG" = "0" ] && FLAG_CHANGED="${FLAG_CHANGED}$(gettext 'Hostname'):restart|"
+  rm -f /tmp/quicksetup-hostname-change-flag
+ fi
+fi
 
 [ ! $DISPLAY ] && exit
 
 if [ "`echo -n "$FLAG_CHANGED" | grep "restart"`" != "" ];then