Check-in [ce27ec3fbe]
Not logged in

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

Overview

SHA1 Hash:ce27ec3fbef58e1eefd8c8d04f360cb6f5b7a7a6
Date: 2012-06-25 11:07:22
User: BarryK
Comment:quicksetup network frame enhanced, added firewall and ntp checkboxes, modified hostname action

Tags And Properties
Changes

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

@@ -39,10 +39,11 @@
 #120328 have rewritten rc.country, try to make chooselocale compatible. 120330 bugfix.
 #120331 added Polish (pl) hardcoded translation.
 #120401 change logic to call lang2initrd.
 #120402 expand locale help window.
 #120524 Please wait... msg after click ok button.
+#120625 always display network frame, remove set-hostname button, added firewall and ntp checkboxes.
 
 [ "`whoami`" != "root" ] && exec sudo -A ${0} ${@}
 
 export TEXTDOMAIN=quicksetup
 export OUTPUT_CHARSET=UTF-8
@@ -134,33 +135,70 @@
     fi
    fi
   fi
  fi
 fi
+#      <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>
+#      <text><label>\"                                            \"</label></text>
 if [ "$MYBASE" = "quicksetup" ];then #120313 only allow in main quicksetup window.
- if [ -f /var/local/quicksetup-network-check-flag1 ];then
+ #120625 always display network frame...
+ #if [ -f /var/local/quicksetup-network-check-flag1 ];then
     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.")
+
+    #120625 firewall checkbox...
+    TT_CH_F="$(gettext "Tick checkbox to activate the firewall (recommended)")"
+    L_CH_F="$(gettext "Firewall enabled")"
+    DEFAULT_FIREWALL='false'
+    [ "`lsmod | grep '^iptable'`" != "" ] && DEFAULT_FIREWALL='true'
+
+    #120625 get time/date off internet...
+    CHKBOXNTP=""
+    if [ "`cat /root/.packages/woof-installed-packages /root/.packages/user-installed-packages | grep '^[Pp]sync'`" != "" ];then
+     TT_CH_NTP="$(gettext "Set this computer's time and date from an Internet NTP server")" #'geany
+     L_CH_NTP="$(gettext "Set time/date from the Internet")"
+     DEFAULT_NTP='false'
+     #[ -x /root/Startup/timesync.sh ] && DEFAULT_NTP='true' #created by psync package.
+     [ -f /tmp/settertime ] && DEFAULT_NTP='true' #created by psync package.
+     H_ntp="$(gettext "This will synchronise the local time and date to an NTP server on the Internet. You do not need to do this, as computers normally have their date and time set by a battery-backed hardware clock. However, some tiny computers, such as some ARM boards (for example the Raspberry Pi) do not have a hardware clock, so you either have to set the time/date manually at every bootup, or enable NTP. Note, if you enable NTP now, you can change the settings any time in the future -- see the 'Psync' entry in the 'Desktop' menu.")"
+    export DLG_HELP_NTP="<window resizable=\"false\" title=\"$(gettext 'Help: NTP')\" icon-name=\"${HELPICON}\" window_position=\"1\"><vbox><text use-markup=\"true\"><label>\"${H_ntp}\"</label><variable>VAR_HELP_NTP</variable></text><hbox><button><label>${M_close}</label><action type=\"closewindow\">VAR_HELP_NTP</action></button></hbox></vbox></window>"
+     CHKBOXNTP="<hbox>
+      <checkbox tooltip-text=\"${TT_CH_NTP}\"><label>${L_CH_NTP}</label><variable>CHECK_NTP</variable><default>${DEFAULT_NTP}</default></checkbox>
+      <button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type=\"launch\">DLG_HELP_NTP</action></button>
+     </hbox>"
+    fi
+
+    H_net="$(gettext "Your computer has been assigned a unique name, known as the 'hostname', by which it identifies itself on a network.") $(eval_gettext "It is currently named '\${HOSTNAME}', however you might wish to change that to a name that is more meaningful to yourself, such as 'johnsmithpc'.") $(gettext "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>"
+    H_fw="$(gettext "It is always recommended that the firewall be enabled when connected to a network, unless it is a local trusted network. Note that you can run the Firewall Wizard any time in the future if you want to change the settings -- see the 'Setup' menu.")"
+    export DLG_HELP_FW="<window resizable=\"false\" title=\"$(gettext 'Help: Firewall')\" icon-name=\"${HELPICON}\" window_position=\"1\"><vbox><text use-markup=\"true\"><label>\"${H_fw}\"</label><variable>VAR_HELP_FW</variable></text><hbox><button><label>${M_close}</label><action type=\"closewindow\">VAR_HELP_FW</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>
+
+      <vbox>
+       <hbox>
+        <checkbox tooltip-text=\"${TT_CH_F}\"><label>${L_CH_F}</label><variable>CHECK_FIREWALL</variable><default>${DEFAULT_FIREWALL}</default></checkbox>
+        <button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type=\"launch\">DLG_HELP_FW</action></button>
+       </hbox>
+       ${CHKBOXNTP}
+      </vbox>
+      <text><label>\"  \"</label></text>
+      <vbox>
+       <hbox>
+        <text><label>$(gettext 'Hostname:')</label></text>
+        <entry tooltip-text=\"$(gettext 'Type your computer name to identify in the network. Alpha-numeric without spaces.')\" width-chars=\"15\">
+        <input>echo -n \"$HOSTNAME\"</input><variable>ENTRY_HOSTNAME</variable></entry>
+        <button><input file>/usr/local/lib/X11/mini-icons/mini-question.xpm</input><action type=\"launch\">DLG_HELP_NET</action></button>
+       </hbox>
+      </vbox>
      </hbox>
     </frame>"
- fi
+ #fi
 fi
 
 ###Country localization###
 if [ "$SET_COUNTRY" ];then
 
@@ -1206,15 +1244,58 @@
  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.
+
+ #120625 set new hostname...
+ OLD_HOSTNAME="$HOSTNAME"
+ if [ "$OLD_HOSTNAME" != "$ENTRY_HOSTNAME" ];then
+  /usr/sbin/hostname-set $ENTRY_HOSTNAME
+  HOSTNAMEFLAG=$?
   [ "$HOSTNAMEFLAG" = "0" ] && FLAG_CHANGED="${FLAG_CHANGED}$(gettext 'Hostname'):restart|"
-  rm -f /tmp/quicksetup-hostname-change-flag
+ fi
+
+ #120625...
+ if [ "$CHECK_FIREWALL" != "$DEFAULT_FIREWALL" ];then
+  if [ "$CHECK_FIREWALL" = "false" ];then
+   /etc/rc.d/rc.firewall stop
+   chmod 664 /etc/rc.d/rc.firewall #so that /etc/rc.d/rc.local won't start it.
+   FLAG_CHANGED="${FLAG_CHANGED}$(gettext 'Firewall disabled'):yes|"
+  else
+   FLAG_CHANGED="${FLAG_CHANGED}$(gettext 'Firewall enabled'):yes|"
+   if [ -f /etc/rc.d/rc.firewall ];then
+    chmod 755 /etc/rc.d/rc.firewall #so that /etc/rc.d/rc.local will start firewall at bootup.
+    /etc/rc.d/rc.firewall start
+   else
+    rxvt -bg LightYellow -title "Firewall setup" -e firewallinstallshell
+   fi
+  fi
+ fi
+
+ #120625...
+ if [ "$CHECK_NTP" != "$DEFAULT_NTP" ];then
+  if [ "$CHECK_NTP" = "false" ];then
+   chmod 664 /root/Startup/timesync.sh #so it won't run next bootup.
+   FLAG_CHANGED="${FLAG_CHANGED}$(gettext 'NTP set-time disabled'):yes|"
+  else
+   [ -f /root/Startup/timesync.sh ] && chmod 755 /root/Startup/timesync.sh
+   if [ -x /root/Startup/timesync.sh ];then
+    /root/Startup/timesync.sh &
+    FLAG_CHANGED="${FLAG_CHANGED}$(gettext 'NTP set-time enabled'):yes|"
+   else
+    /usr/local/psync/psync
+    if [ -x /root/Startup/timesync.sh ];then
+     FLAG_CHANGED="${FLAG_CHANGED}$(gettext 'NTP set-time enabled'):yes|"
+    else
+     #/tmp/settertime created by /usr/local/psync/psyncfunc
+     [ -f /tmp/settertime ] && FLAG_CHANGED="${FLAG_CHANGED}$(gettext 'NTP set-time (this session only)'):yes|"
+    fi
+   fi
+  fi
  fi
+
 fi
 
 [ ! $DISPLAY ] && exit
 
 if [ "`echo -n "$FLAG_CHANGED" | grep "restart"`" != "" ];then