slitaz-tools rev 377

netbox: add pxe forwarder
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Aug 13 22:29:59 2009 +0200 (2009-08-13)
parents afcfdf317aa1
children 241f529c2c63
files tinyutils/netbox
line diff
     1.1 --- a/tinyutils/netbox	Thu Aug 13 14:17:09 2009 +0200
     1.2 +++ b/tinyutils/netbox	Thu Aug 13 22:29:59 2009 +0200
     1.3 @@ -549,10 +549,7 @@
     1.4  			<default>/usr/share/udhcpc/default.script</default>
     1.5  			<variable>UDHCPC_SCRIPT</variable>
     1.6  		</entry>
     1.7 -		<button>
     1.8 -			<input file icon="accessories-text-editor"></input>
     1.9 -			<action type="lauch">leafpad \$UDHCPC_SCRIPT</action>
    1.10 -		</button>
    1.11 +$(editbutton \$UDHCPC_SCRIPT)
    1.12  	</hbox>
    1.13  	<hbox>
    1.14  		<button>
    1.15 @@ -805,10 +802,7 @@
    1.16            <default>/etc/hosts</default>
    1.17            <variable>HOSTS</variable>
    1.18          </entry>
    1.19 -        <button>
    1.20 -          <input file icon="accessories-text-editor"></input>
    1.21 -          <action type="lauch">leafpad \$HOSTS</action>
    1.22 -        </button>
    1.23 +$(editbutton \$HOSTS)
    1.24        </hbox>
    1.25        <hbox>
    1.26          <text use-markup="true">
    1.27 @@ -818,10 +812,7 @@
    1.28            <default>/etc/hostname</default>
    1.29            <variable>HOSTNAME</variable>
    1.30          </entry>
    1.31 -        <button>
    1.32 -          <input file icon="accessories-text-editor"></input>
    1.33 -          <action type="lauch">leafpad \$HOSTNAME</action>
    1.34 -        </button>
    1.35 +$(editbutton \$HOSTNAME)
    1.36        </hbox>
    1.37        <hbox>
    1.38          <text use-markup="true">
    1.39 @@ -831,10 +822,7 @@
    1.40            <default>/etc/network.conf</default>
    1.41            <variable>CONFIG_FILE</variable>
    1.42          </entry>
    1.43 -        <button>
    1.44 -          <input file icon="accessories-text-editor"></input>
    1.45 -          <action type="lauch">leafpad \$CONFIG_FILE</action>
    1.46 -        </button>
    1.47 +$(editbutton \$CONFIG_FILE)
    1.48        </hbox>
    1.49        <hbox>
    1.50          <button>
    1.51 @@ -954,10 +942,7 @@
    1.52  cat <<EOT
    1.53            <item>SERVER</item>
    1.54          </combobox>
    1.55 -	<button>
    1.56 -	  <input file icon="accessories-text-editor"></input>
    1.57 -	  <action type="lauch">leafpad /etc/ppp/pptp-servers</action>
    1.58 -	</button>
    1.59 +$(editbutton /etc/ppp/pptp-servers)
    1.60        </hbox>
    1.61        <hbox>
    1.62          <text use-markup="true">
    1.63 @@ -971,10 +956,7 @@
    1.64  cat <<EOT
    1.65            <item>DOMAIN\USERNAME</item>
    1.66          </combobox>
    1.67 -	<button>
    1.68 -	  <input file icon="accessories-text-editor"></input>
    1.69 -	  <action type="lauch">leafpad /etc/ppp/chap-secrets</action>
    1.70 -	</button>
    1.71 +$(editbutton /etc/ppp/chap-secrets)
    1.72        </hbox>
    1.73        <hbox>
    1.74          <text use-markup="true">
    1.75 @@ -1277,12 +1259,57 @@
    1.76  }
    1.77  
    1.78  #
    1.79 -# PXE
    1.80 +# PXE forwarder
    1.81  #
    1.82 -tab_pxe()
    1.83 +tab_gpxe()
    1.84  {
    1.85  cat <<EOT
    1.86 -<frame Pxelinux>
    1.87 +<frame PXE forwarder>
    1.88 +      <hbox>
    1.89 +        <text use-markup="true">
    1.90 +          <label>"<b>WEB boot URL(s) :</b>"</label>
    1.91 +        </text>
    1.92 +      </hbox>
    1.93 +      <hbox>
    1.94 +        <entry editable="true">
    1.95 +          <default>
    1.96 +"$(dd bs=1 skip=5 count=255 if=/usr/share/boot/gpxe.pxe 2> /dev/null | strings)"
    1.97 +          </default>
    1.98 +          <variable>WEB_PXE</variable>
    1.99 +        </entry>
   1.100 +      </hbox>
   1.101 +      <hbox>
   1.102 +$(wikibutton http://wiki.slitaz.org/doku.php?id=quickstart:pxe)
   1.103 +        <button>
   1.104 +          <input file icon="go-jump"></input>
   1.105 +	  <label>Install</label>
   1.106 +	  <action>
   1.107 +	echo -n "\$WEB_PXE" | cat - /dev/zero | \
   1.108 +	dd conv=notrunc bs=1 seek=5 count=255 of=/usr/share/boot/gpxe.pxe
   1.109 +	  </action>
   1.110 +	  <action>
   1.111 +	sed -i "s|tftpd -r .*\$|tftpd -r /usr/share/boot|" /etc/inetd.conf
   1.112 +	  </action>
   1.113 +	  <action> sed -i "/^boot_file/d" \$UDHCPD_CONF </action>
   1.114 +	  <action> echo "boot_file gpxe.pxe" >> \$UDHCPD_CONF </action>
   1.115 +	  <action> /etc/init.d/inetd restart </action>
   1.116 +	  <action> /etc/init.d/udhcpd restart </action>
   1.117 +	<action>sed -i "s/RUN_DAEMONS=\\"\\(.*\\)inetd \?\\(.*\\)\\"/RUN_DAEMONS=\\"\1\2\\"/" /etc/rcS.conf</action>
   1.118 +	<action>sed -i "s/RUN_DAEMONS=\\"\\(.*\\)udhcpd \?\\(.*\\)\\"/RUN_DAEMONS=\\"\1\2\\"/" /etc/rcS.conf</action>
   1.119 +	<action>sed -i "s/RUN_DAEMONS=\\"\\(.*\\)\\"/RUN_DAEMONS=\\"udhcpd inetd \1\\"/" /etc/rcS.conf</action>
   1.120 +        </button>
   1.121 +      </hbox>
   1.122 +</frame>
   1.123 +EOT
   1.124 +}
   1.125 +
   1.126 +#
   1.127 +# PXE server
   1.128 +#
   1.129 +tab_pxelinux()
   1.130 +{
   1.131 +cat <<EOT
   1.132 +<frame PXElinux>
   1.133        <hbox>
   1.134          <text wrap="true">
   1.135            <label>
   1.136 @@ -1304,7 +1331,8 @@
   1.137            <input file icon="accessories-text-editor"></input>
   1.138  	  <action>dir=\$(dirname \$PXE_CONF); [ -d \$dir ] || mkdir -p \$dir</action>
   1.139  	  <action>lzma d /usr/share/boot/pxelinux.0.lzma \$(dirname \$PXE_CONF)/../pxelinux.0</action>
   1.140 -	  <action>grep -q "^boot_file" \$UDHCPD_CONF || echo "boot_file pxelinux.0" >> \$UDHCPD_CONF</action>
   1.141 +	  <action>sed -i "/^boot_file/d" \$UDHCPD_CONF</action>
   1.142 +	  <action>echo "boot_file pxelinux.0" >> \$UDHCPD_CONF</action>
   1.143  	  <action>grep -q "^siaddr" \$UDHCPD_CONF || echo "siaddr \$(ifconfig \$INTERFACE | grep inet.ad | cut -d: -f2 | cut -d\  -f1)" >> \$UDHCPD_CONF</action>
   1.144  	  <action>[ -f \$PXE_CONF ] || echo -e "label linux\n\tkernel bzImage\n\tappend initrd=rootfs.gz rw root=/dev/null vga=normal" > \$PXE_CONF</action>
   1.145            <action type="lauch">leafpad \$PXE_CONF</action>
   1.146 @@ -1322,6 +1350,24 @@
   1.147  EOT
   1.148  }
   1.149  
   1.150 +data_pxe()
   1.151 +{
   1.152 +[ -f /usr/share/boot/pxelinux.0.lzma ] && cat <<EOT
   1.153 +true        PXElinux          tab_pxelinux
   1.154 +EOT
   1.155 +[ -f /usr/share/boot/gpxe.pxe ] && cat <<EOT
   1.156 +true        PXE\ forwarder    tab_gpxe
   1.157 +EOT
   1.158 +}
   1.159 +
   1.160 +#
   1.161 +# PXE
   1.162 +#
   1.163 +tab_pxe()
   1.164 +{
   1.165 +use_tab data_pxe
   1.166 +}
   1.167 +
   1.168  #
   1.169  # Busybox dnsd
   1.170  #
   1.171 @@ -1533,7 +1579,7 @@
   1.172  pxe="#"
   1.173  [ -x /usr/bin/tftpd -a -x /usr/sbin/udhcpd ] && pxe="inetd"
   1.174  [ -x /usr/sbin/dnsmasq ] && pxe="true"
   1.175 -[ -f /usr/share/boot/pxelinux.0.lzma ] || pxe="#"
   1.176 +[ -f /usr/share/boot/pxelinux.0.lzma -o /usr/share/boot/gpxe.pxe ] || pxe="#"
   1.177  cat <<EOT
   1.178  $([ -x /usr/sbin/dropbear -o -x /usr/sbin/sshd ] && echo "true" ||
   1.179  echo "#")   SSH           tab_sshd
   1.180 @@ -1553,6 +1599,9 @@
   1.181  smbd        WINS          tab_wins
   1.182  x11vnc      VNC           tab_vnc 
   1.183  knockd      Knock         tab_knockd
   1.184 +#TODO+callback pppd        Pppd          tab_pppd
   1.185 +#TODO pptpd       PoPToP        tab_poptop
   1.186 +#TODO squid *sql openldap 
   1.187  EOT
   1.188  }
   1.189