flavors rev 158

Add Proxy (squid + sqduidclamav + SquidGuard + sarg)
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Thu Mar 15 00:56:34 2012 +0100 (2012-03-15)
parents 8c447807f5ed
children b595cbc6ef1b
files proxy/distro.sh proxy/packages.list proxy/receipt proxy/rootcd/README proxy/rootcd/index.html proxy/rootcd/style.css proxy/rootfs/usr/bin/tazctl
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/proxy/distro.sh	Thu Mar 15 00:56:34 2012 +0100
     1.3 @@ -0,0 +1,93 @@
     1.4 +#!/bin/sh
     1.5 +# distro.sh, changet set for slitaz-dolibarr
     1.6 +#
     1.7 +# Eric Joseph-Alexandre <erjo@slitaz.org>
     1.8 +
     1.9 +ROOTFS=$PWD/rootfs
    1.10 +HOSTNAME="proxy"
    1.11 +AUTOSTART="dropbear squid c-icapd lighttpd"
    1.12 +DONTSTART="httpd"
    1.13 +ALLOW_ROOT_LOGIN="1"
    1.14 +BLOCKED_PACKAGES=""
    1.15 +
    1.16 +# Disable auto-install dependencies
    1.17 +sed -i s/AUTO_INSTALL.*/AUTO_INSTALL_DEPS=\"no\"/ $ROOTFS/etc/slitaz/tazpkg.conf
    1.18 +
    1.19 +##
    1.20 +##
    1.21 +if [ ! -z "$BLOCKED_PACKAGES" ]; then
    1.22 +	touch $ROOTFS/var/lib/tazpkg/blocked-packages.list
    1.23 +	for i in $BLOCKED_PACKAGES
    1.24 +	do 
    1.25 +		echo $i >> $ROOTFS/var/lib/tazpkg/blocked-packages.list
    1.26 +	done
    1.27 +fi
    1.28 +
    1.29 +
    1.30 +# Set static IP config: IP=92.168.1.6/24. Gateway=192.168.1.1 DNS: 192.168.1.1 
    1.31 +
    1.32 +if [ ! -z  $IP_STATIC ]; then
    1.33 +	sed -i -e 's/DHCP=.*/DHCP=\"no\"/' \
    1.34 +		-e 's/STATIC=.*/STATIC=\"yes\"/' \
    1.35 +		-e 's/IP=.*/IP=\"192.168.1.6\"/' \
    1.36 +		-e 's/GATEWAY=.*/GATEWAY=\"192.168.1.1\"/' \
    1.37 +		-e 's/DNS_SERVER=.*/DNS_SERVER=\"192.168.1.1\"/' $ROOTFS/etc/network.conf
    1.38 +fi
    1.39 +
    1.40 +# Change default hostname
    1.41 +if [ ! -z "$HOSTNAME" ]; then
    1.42 +	echo "* Setting hostname to $HOSTNAME"
    1.43 +	echo "$HOSTNAME" > $ROOTFS/etc/hostname
    1.44 +	# Change hosts
    1.45 +	sed -i -e "s/slitaz/$HOSTNAME/" $ROOTFS/etc/hosts
    1.46 +fi
    1.47 +
    1.48 +# Start daemons at boot time
    1.49 +if [ ! -z "$AUTOSTART" ]; then 
    1.50 +	echo "* Enabling daemons at boot" 
    1.51 +	sed -i -e "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"\1 $AUTOSTART\"/"  \
    1.52 +		$ROOTFS/etc/rcS.conf
    1.53 +fi
    1.54 +
    1.55 +# Dont start daemons at boot time
    1.56 +if [ ! -z "$DONTSTART" ]; then 
    1.57 +	echo "* Disabling daemons at boot" 
    1.58 +	sed -i -e "s/$DONTSTART//"  \
    1.59 +		$ROOTFS/etc/rcS.conf
    1.60 +fi
    1.61 +
    1.62 +##
    1.63 +## Custom config
    1.64 +##
    1.65 +
    1.66 +# Allow SSH root login from remote computer.
    1.67 +if [ $ALLOW_ROOT_LOGIN = "1" ]; then
    1.68 +	echo "Allow root login using SSH"
    1.69 +	sed -i 's!DROPBEAR_OPTIONS=.*!DROPBEAR_OPTIONS="-b  /etc/dropbear/banner"!' \
    1.70 +	$ROOTFS/etc/daemons.conf
    1.71 +fi
    1.72 +
    1.73 +# Fix Apache config
    1.74 +sed -i  '/#ServerName/ {
    1.75 +	a\ServerName localhost
    1.76 +}' $ROOTFS/etc/apache/httpd.conf
    1.77 +
    1.78 +#
    1.79 +#sed -i 's/DirectoryMatch/Directory/' $ROOTFS/etc/apache/conf.d/phpmyadmin
    1.80 +
    1.81 +# Remove extra files
    1.82 +rm -rf $ROOTFS/etc/apache/phpinfo
    1.83 +rm -rf $ROOTFS/usr/share/applications/lua.*
    1.84 +rm -rf $ROOTFS/usr/share/applications/sqlite.*
    1.85 +rm -rf $ROOTFS/usr/share/applications/gtkdialog.*
    1.86 +rm -rf $ROOTFS/usr/share/applications/php.*
    1.87 +rm -rf $ROOTFS/usr/share/applications/dialog.*
    1.88 +
    1.89 +# Default config
    1.90 +sed -i 's/tazweb/midori/' $ROOTFS/etc/slitaz/applications.conf
    1.91 +sed -i 's/tazweb/midori/' $ROOTFS/usr/share/lxpanel/profile/default/panels/panel 
    1.92 +sed -i 's/tazweb/midori/' $ROOTFS/etc/lxpanel/default/panels/panel  
    1.93 +sed -i 's/tazweb/midori/' $ROOTFS/etc/lxpanel/original/panels/panel 
    1.94 +
    1.95 +# Add shorcut on the Desktop
    1.96 +#cp $ROOTFS/usr/share/applications/dolibarr.desktop $ROOTFS/etc/skel/Desktop
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/proxy/packages.list	Thu Mar 15 00:56:34 2012 +0100
     2.3 @@ -0,0 +1,214 @@
     2.4 +915resolution
     2.5 +acl
     2.6 +alsa-lib
     2.7 +alsaplayer
     2.8 +alsa-utils
     2.9 +asunder
    2.10 +atk
    2.11 +atkmm
    2.12 +attr
    2.13 +busybox
    2.14 +bzlib
    2.15 +cairo
    2.16 +cairomm
    2.17 +cdparanoia-III
    2.18 +cdrkit
    2.19 +clearlooks
    2.20 +cookutils
    2.21 +dbus
    2.22 +dbus-glib
    2.23 +depmod
    2.24 +desktop-file-utils
    2.25 +dialog
    2.26 +dropbear
    2.27 +e2fsprogs
    2.28 +enchant
    2.29 +epdfview
    2.30 +expat
    2.31 +firmware-rt2x00
    2.32 +fontconfig
    2.33 +freetype
    2.34 +fuse
    2.35 +galculator
    2.36 +gamin
    2.37 +gcc-lib-base
    2.38 +gcolor2
    2.39 +gdk-pixbuf
    2.40 +gettext-base
    2.41 +glib
    2.42 +glibc-base
    2.43 +glibmm
    2.44 +gparted
    2.45 +gpxe
    2.46 +grub4dos-linux
    2.47 +gtk+
    2.48 +gtkdialog
    2.49 +gtkmm
    2.50 +hal
    2.51 +hardinfo
    2.52 +hicolor-icon-theme
    2.53 +isapnptools
    2.54 +isomaster
    2.55 +jpeg
    2.56 +kbd-base
    2.57 +lcms
    2.58 +leafpad
    2.59 +libcap
    2.60 +libcddb
    2.61 +libcomerr
    2.62 +libcrypto
    2.63 +libgcrypt
    2.64 +libgio
    2.65 +libgiomm
    2.66 +libglade
    2.67 +libgnutls
    2.68 +libgpg-error
    2.69 +libjpeg
    2.70 +libmad
    2.71 +libnotify
    2.72 +libogg
    2.73 +libpng
    2.74 +libsexy
    2.75 +libsigc++
    2.76 +libsoup
    2.77 +libsqlite
    2.78 +libssl
    2.79 +libtasn1
    2.80 +libtaz
    2.81 +libunique
    2.82 +libusb
    2.83 +libusb-compat
    2.84 +libvorbis
    2.85 +libwebkit
    2.86 +libxcb
    2.87 +libxml2
    2.88 +libxslt
    2.89 +linux
    2.90 +linux-crypto
    2.91 +linux-firmware
    2.92 +linux-sound
    2.93 +linux-wireless
    2.94 +locale-de
    2.95 +locale-es
    2.96 +locale-fr
    2.97 +locale-it
    2.98 +locale-pt_BR
    2.99 +lxappearance
   2.100 +lxpanel
   2.101 +lxrandr
   2.102 +lxtask
   2.103 +lzlib
   2.104 +lzma
   2.105 +menu-cache
   2.106 +midori
   2.107 +mtpaint
   2.108 +nano
   2.109 +ncurses
   2.110 +ncurses-common
   2.111 +ncursesw
   2.112 +ntfs-3g
   2.113 +ntfsprogs
   2.114 +obconf
   2.115 +openbox
   2.116 +pango
   2.117 +pangomm
   2.118 +parcellite
   2.119 +parted
   2.120 +pciutils
   2.121 +pcmanfm
   2.122 +pcmciautils
   2.123 +pcre
   2.124 +pixman
   2.125 +poppler
   2.126 +popt
   2.127 +readline
   2.128 +retawq
   2.129 +shared-mime-info
   2.130 +slim
   2.131 +slitaz-base-files
   2.132 +slitaz-boot-scripts
   2.133 +slitaz-configs
   2.134 +slitaz-configs-base
   2.135 +slitaz-doc
   2.136 +slitaz-icon
   2.137 +slitaz-menus
   2.138 +slitaz-polar-cursors
   2.139 +slitaz-tools
   2.140 +slitaz-tools-boxes
   2.141 +sqlite
   2.142 +startup-notification
   2.143 +sysfsutils
   2.144 +syslinux
   2.145 +syslinux-extra
   2.146 +tazlito
   2.147 +tazpanel
   2.148 +tazpkg
   2.149 +tazusb
   2.150 +tazwikiss
   2.151 +tazweb
   2.152 +tiff
   2.153 +transset-df
   2.154 +ttf-dejavu
   2.155 +udev
   2.156 +util-linux-ng-blkid
   2.157 +util-linux-ng-getopt
   2.158 +util-linux-ng-uuid
   2.159 +viewnior
   2.160 +wireless_tools
   2.161 +wpa_supplicant
   2.162 +xcb-util
   2.163 +xorg
   2.164 +xorg-base-fonts
   2.165 +xorg-libfontenc
   2.166 +xorg-libICE
   2.167 +xorg-libpciaccess
   2.168 +xorg-libSM
   2.169 +xorg-libX11
   2.170 +xorg-libXau
   2.171 +xorg-libXaw
   2.172 +xorg-libXcomposite
   2.173 +xorg-libXcursor
   2.174 +xorg-libXdamage
   2.175 +xorg-libXdmcp
   2.176 +xorg-libXext
   2.177 +xorg-libXfixes
   2.178 +xorg-libXfont
   2.179 +xorg-libXft
   2.180 +xorg-libXi
   2.181 +xorg-libXinerama
   2.182 +xorg-libxkbfile
   2.183 +xorg-libXmu
   2.184 +xorg-libXpm
   2.185 +xorg-libXrandr
   2.186 +xorg-libXrender
   2.187 +xorg-libXss
   2.188 +xorg-libXt
   2.189 +xorg-libXtst
   2.190 +xorg-libXxf86vm
   2.191 +xorg-rgb
   2.192 +xorg-server
   2.193 +xorg-setxkbmap
   2.194 +xorg-xauth
   2.195 +xorg-xcompmgr
   2.196 +xorg-xf86-input-evdev
   2.197 +xorg-xf86-input-synaptics
   2.198 +xorg-xf86-video-geode
   2.199 +xorg-xf86-video-intel
   2.200 +xorg-xf86-video-nv
   2.201 +xorg-xf86-video-vesa
   2.202 +xorg-xkbcomp
   2.203 +xorg-xkeyboard-config
   2.204 +xterm
   2.205 +yad
   2.206 +zlib
   2.207 +logrotate
   2.208 +sudo
   2.209 +squid
   2.210 +squid-auth-helpers
   2.211 +squid-langpack
   2.212 +squidguard
   2.213 +squidclamav
   2.214 +sarg
   2.215 +tor
   2.216 +lighttpd
   2.217 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/proxy/receipt	Thu Mar 15 00:56:34 2012 +0100
     3.3 @@ -0,0 +1,7 @@
     3.4 +# SliTaz flavor receipt.
     3.5 +
     3.6 +FLAVOR="proxy"
     3.7 +SHORT_DESC="Content Web filtering server"
     3.8 +VERSION="1.0"
     3.9 +MAINTAINER="erjo@slitaz.org"
    3.10 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/proxy/rootcd/README	Thu Mar 15 00:56:34 2012 +0100
     4.3 @@ -0,0 +1,26 @@
     4.4 +README SliTaz GNU/Linux CD
     4.5 +===============================================================================
     4.6 +
     4.7 +
     4.8 +Check the index.html page for more information
     4.9 +
    4.10 +
    4.11 +LICENSE
    4.12 +-------
    4.13 +
    4.14 +Copyright (c)  2006-2012  SliTaz GNU/Linux
    4.15 +
    4.16 +SliTaz is free software; you can redistribute it and/or modify
    4.17 +it under the terms of the GNU General Public License as published by
    4.18 +the Free Software Foundation; either version 3 of the License, or
    4.19 +(at your option) any later version.
    4.20 +
    4.21 +SliTaz is distributed in the hope that it will be useful,
    4.22 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.23 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    4.24 +GNU General Public License for more details.
    4.25 +
    4.26 +You should have received a copy of the GNU General Public License
    4.27 +along with SliTaz; if not, write to the Free Software
    4.28 +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
    4.29 +USA
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/proxy/rootcd/index.html	Thu Mar 15 00:56:34 2012 +0100
     5.3 @@ -0,0 +1,84 @@
     5.4 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     5.5 +    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     5.6 +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
     5.7 +<head>
     5.8 +	<title>SliTaz GNU/Linux - CD</title>
     5.9 +	<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
    5.10 +	<meta name="author" content="Christophe Lincoln"/>
    5.11 +	<link rel="stylesheet" type="text/css" href="style.css" />
    5.12 +</head>
    5.13 +<body>
    5.14 +
    5.15 +<!-- Header -->
    5.16 +<div id="header">
    5.17 +	<div id="logo"></div>
    5.18 +	<div id="network">
    5.19 +		<a href="http://www.slitaz.org/">Website</a>
    5.20 +		<a href="http://scn.slitaz.org/">Community</a>
    5.21 +		<a href="http://doc.slitaz.org/">Doc</a>
    5.22 +		<a href="http://forum.slitaz.org/">Forum</a>
    5.23 +		<a href="http://labs.slitaz.org/issues">Bugs</a>
    5.24 +		<a href="http://hg.slitaz.org/">Hg</a>
    5.25 +	</div>
    5.26 +	<h1>SliTaz Live</h1>
    5.27 +</div>
    5.28 +
    5.29 +<!-- Block -->
    5.30 +<div id="block"></div>
    5.31 +
    5.32 +<!-- Content -->
    5.33 +<div id="content">
    5.34 +<h2>LiveCD information</h2>
    5.35 +
    5.36 +<h3>English</h3>
    5.37 +<p>
    5.38 +	Welcome to the SliTaz GNU/Linux cdrom. To boot SliTaz from a cdrom
    5.39 +	just burn the ISO image onto a blank disc. Then reboot your computer
    5.40 +	with the disc in your cdrom drive.
    5.41 +</p>
    5.42 +<p>
    5.43 +	SliTaz is a micro GNU/Linux distro using BusyBox, a Linux kernel,
    5.44 +	and GNU free software. SliTaz also uses goodies from the Debian
    5.45 +	project. The goal of SliTaz is to have a GNU/Linux distro working
    5.46 +	entirely in memory (RAM) and fully installable to a HD for desktop or
    5.47 +	server usage.
    5.48 +</p>
    5.49 +<p>
    5.50 +	On the system you will find documentation in /usr/share/doc and the
    5.51 +	full <a href="README">GPL license</a> in /usr/share/licenses.
    5.52 +</p>
    5.53 +
    5.54 +<h3>Français</h3>
    5.55 +<p>
    5.56 +	Bienvenue sur la page d'index d'un cdrom de SliTaz GNU/Linux. 
    5.57 +	Vous devez démarrez votre ordinateur avec le cdrom dans le lecteur
    5.58 +	CD ou DVD, pour lancer SliTaz en RAM et sans risques pour la
    5.59 +	machine hôte.
    5.60 +</p>
    5.61 +<p>
    5.62 +	SliTaz peut fonctionner des mois entiers sans redémarrer, le système
    5.63 +	peut fonctionner dans 144 Mb de mémoire vive et sur des machines 
    5.64 +	sans disque dur. Mais SliTaz est aussi pleinement installable sur
    5.65 +	un disque dur et largement extensible via le gestionnaire de 
    5.66 +	paquets et la compilation de nouvelles applications depuis les
    5.67 +	sources.
    5.68 +</p>
    5.69 +
    5.70 +<!-- End content -->
    5.71 +</div>
    5.72 +
    5.73 +<!-- Footer -->
    5.74 +<div id="footer">
    5.75 +    Copyright &copy; 2012 <a href="http://www.slitaz.org/">SliTaz</a>
    5.76 +    <p>
    5.77 +    SliTaz @
    5.78 +		<a href="http://twitter.com/slitaz">Twitter</a>
    5.79 +		<a href="http://www.facebook.com/slitaz">Facebook</a>
    5.80 +		<a href="http://distrowatch.com/slitaz">Distrowatch</a>
    5.81 +		<a href="http://en.wikipedia.org/wiki/SliTaz">Wikipedia</a>
    5.82 +		<a href="http://flattr.com/profile/slitaz">Flattr</a>
    5.83 +	    </p>
    5.84 +</div>
    5.85 +
    5.86 +</body>
    5.87 +</html>
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/proxy/rootcd/style.css	Thu Mar 15 00:56:34 2012 +0100
     6.3 @@ -0,0 +1,77 @@
     6.4 +/* CSS style for SliTaz GNU/Linux generic xHTML files. */
     6.5 +
     6.6 +html { min-height: 102%; }
     6.7 +
     6.8 +body {
     6.9 +	background: #ffffff;
    6.10 +	color: black;
    6.11 +	font: 13px sans-serif, vernada, arial;
    6.12 +	margin: 0;
    6.13 +	min-width: 640px;
    6.14 +}
    6.15 +
    6.16 +a { text-decoration: underline; color: #215090; }
    6.17 +a:hover { text-decoration: none; color: blue; }
    6.18 +img { border: 0pt none; vertical-align: middle; }
    6.19 +h2 { color: #444; }
    6.20 +h3 { color: #666; font-size: 140%; }
    6.21 +
    6.22 +#header { 
    6.23 +	height: 40px; 
    6.24 +	background: #351a0a;
    6.25 +}
    6.26 +
    6.27 +#header h1 {
    6.28 +	margin: 0;
    6.29 +	padding: 8px 0 0 8px;
    6.30 +	width: 250px;
    6.31 +	color: white;
    6.32 +	font-size: 20px;
    6.33 +	font-style: italic;
    6.34 +}
    6.35 +
    6.36 +#header h1 a { 
    6.37 +	color: white; 
    6.38 +	text-decoration: none;
    6.39 +	font-size: 20px;
    6.40 +	font-style: italic;
    6.41 +}
    6.42 +
    6.43 +#header h1 a:hover, #network a:hover { 
    6.44 +	color: #d66018;
    6.45 +}
    6.46 +
    6.47 +#network { 
    6.48 +	float: right; 
    6.49 +	padding: 12px 5px 0; 
    6.50 +	font-size: 12px;
    6.51 +}
    6.52 +
    6.53 +#network a { padding: 0 6px; }
    6.54 +
    6.55 +#network a { 
    6.56 +	color: #fff; 
    6.57 +	font-weight: bold;
    6.58 +	text-decoration: none;
    6.59 +}
    6.60 +
    6.61 +#block { 
    6.62 +	min-height: 8px; 
    6.63 +	background: #d66018; 
    6.64 +	padding: 0;
    6.65 +	border-bottom: 1px solid #f5f5f5;
    6.66 +}
    6.67 +
    6.68 +#content {
    6.69 +	padding: 30px 80px;
    6.70 +	text-align: justify;
    6.71 +}
    6.72 +
    6.73 +#footer {
    6.74 +	text-align: center;
    6.75 +	border-top: 1px solid #ddd;
    6.76 +	padding: 40px;
    6.77 +	color: #666;
    6.78 +}
    6.79 +
    6.80 +#footer a { color: #666; padding: 0 2px; }
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/proxy/rootfs/usr/bin/tazctl	Thu Mar 15 00:56:34 2012 +0100
     7.3 @@ -0,0 +1,227 @@
     7.4 +#!/bin/sh
     7.5 +# Tazadmin - SliTaz System Configuration
     7.6 +#
     7.7 +#
     7.8 +# Author : Eric Joseph-Alexandre (Erjo) <erjo@slitaz.org>
     7.9 +#           
    7.10 +
    7.11 +#export DIALOGRC=$PWD/rc/slackware.rc
    7.12 +
    7.13 +VERSION=1.0
    7.14 +
    7.15 +: ${DIALOG=dialog}
    7.16 +
    7.17 +BACKTITLE="SliTaz Configuration Tools v.${VERSION}"
    7.18 +COMMAND=$1
    7.19 +LOG=/tmp/$(basename $0).log
    7.20 +OUT=/tmp/_retval_
    7.21 +DATADIR=/usr/share/slitaz-tools/tazadmin/
    7.22 +#DATADIR=./
    7.23 +
    7.24 +BS="15 50"
    7.25 +
    7.26 +# Messages language setting
    7.27 +# Switch to default English if $LANG.msg doesn't exist.
    7.28 +set_locale()
    7.29 +{
    7.30 +	if [ -f ${LANG%%_*}.msg ]; then
    7.31 +		. ${DATADIR}${LANG%%_*}.msg
    7.32 +	fi
    7.33 +}
    7.34 +
    7.35 +# use  --msgbox.
    7.36 +# syntax: msg ["Title"] "Message text"
    7.37 +msg()
    7.38 +{
    7.39 +	if [ $# -gt 1 ]; then
    7.40 +		TITLE=$1
    7.41 +		shift
    7.42 +		MSG="$@"
    7.43 +	else
    7.44 +		MSG="$@"
    7.45 +	fi
    7.46 +	$DIALOG --title " ${TITLE:-Message} " \
    7.47 +		--colors --backtitle "$BACKLIST" \
    7.48 +		--clear --msgbox "\n$MSG" 0 0
    7.49 +}
    7.50 +
    7.51 +# Exit install if user is not root.
    7.52 +check_root()
    7.53 +{
    7.54 +	if test $(id -u) != 0 ; then
    7.55 +		error_message "$ERR_CHK_ROOT"
    7.56 +		exit 0
    7.57 +	fi
    7.58 +}
    7.59 +
    7.60 +# functions
    7.61 +#
    7.62 +trim(){
    7.63 +	read LINE
    7.64 +	echo $LINE
    7.65 +}
    7.66 +
    7.67 +get_argc()
    7.68 +{
    7.69 +	echo $#
    7.70 +}
    7.71 +
    7.72 +
    7.73 +
    7.74 +
    7.75 +get_hostname()
    7.76 +{
    7.77 +	# Set hostname
    7.78 +	HOSTNAME=$(cat /etc/hostname)
    7.79 +	exec 3>&1
    7.80 +	HOSTNAME=`$DIALOG --backtitle "$BACKTITLE"  --title "Hostname" --clear  \
    7.81 +        --inputbox "Enter your computer hostname" $BS "${HOSTNAME}" 2>&1 1>&3`
    7.82 +	ret=$?
    7.83 +	exec 3>&-
    7.84 +	# if $HOSTNAME is set we update /etc/hostname
    7.85 +	# and change current hostname.
    7.86 +	if [ ! -z ${HOSTNAME} ]; then
    7.87 +		echo ${HOSTNAME} > /etc/hostname
    7.88 +		hostname $(cat /etc/hostname)
    7.89 +	fi
    7.90 +}	
    7.91 +
    7.92 +set_ip_adress()
    7.93 +{
    7.94 +	# Set static configuration for Network.
    7.95 +	. /etc/network.conf	
    7.96 +	exec 3>&1
    7.97 +	IPCONFIG=`$DIALOG --ok-label "Submit" \
    7.98 +     	 --backtitle "$backtitle" --extra-button --extra-label "${BTN_DHCP:-Use DHCP server}"\
    7.99 +      	--form "Here is a possible piece of a configuration program." \
   7.100 +		15 55 0 \
   7.101 +    	"IP Adress:" 1 1 "$IP" 1 20 20 0 \
   7.102 +    	"Network mask:"      2 1 "$NETMASK"  2 20  20 0 \
   7.103 +    	"Default gateway:"      3 1 "$GATEWAY"  3 20  20 0 \
   7.104 +    	"DNS server(s):"     4 1 "$DNS_SERVER" 4 20 20 0 \
   7.105 +    	2>&1 1>&3`
   7.106 +		ret=$?
   7.107 +		exec 3>&-
   7.108 +		
   7.109 +	case "$ret" in
   7.110 +		0)
   7.111 +			if  [[ "`get_argc $IPCONFIG`" -gt "1" ]]; then
   7.112 +				set_static_ip $IPCONFIG
   7.113 +			else
   7.114 +				msg "${ERR_BED_IP:-Invalid values.}"
   7.115 +			fi
   7.116 +			;;
   7.117 +		3)
   7.118 +			get_dhcp_lease ;;
   7.119 +	esac	
   7.120 +}
   7.121 +
   7.122 +get_dhcp_lease()
   7.123 +{
   7.124 +	sed -i 's/DHCP=.*/DHCP="yes"/' /etc/network.conf
   7.125 +	sed -i 's/STATIC=.*/STATIC="no"/' /etc/network.conf
   7.126 +	/sbin/udhcpc -b -i $INTERFACE -p /var/run/udhcpc.$INTERFACE.pid &
   7.127 +}
   7.128 +
   7.129 +set_static_ip()
   7.130 +{
   7.131 +	sed -i 's/DHCP=.*/DHCP="no"/' /etc/network.conf
   7.132 +	sed -i 's/STATIC=.*/STATIC="yes"/' /etc/network.conf
   7.133 +	sed -i -e "s/IP=".*"/IP=\"$1\"/" /etc/network.conf
   7.134 +	sed -i -e "s/NETMASK=".*"/NETMASK=\"$2\"/" /etc/network.conf
   7.135 +	sed -i -e "s/GATEWAY=".*"/GATEWAY=\"$3\"/" /etc/network.conf
   7.136 +	sed -i -e "s/DNS_SERVER=".*"/DNS_SERVER=\"$4\"/" /etc/network.conf
   7.137 +}
   7.138 +	
   7.139 +network_menu()
   7.140 +{
   7.141 +	ret=0
   7.142 + 	until [ $ret -eq 1 ];do
   7.143 +    	$DIALOG --title "$MENU_TITLE" \
   7.144 +        	--backtitle "$BACKTITLE" --clear \
   7.145 +        	--cancel-label "Quitter" \
   7.146 +        	--colors \
   7.147 +        	--menu "$TAZ_CMD_MSG" 15 50 40\
   7.148 +        	"adress"  	"  Network settings" \
   7.149 +        	"hostname"  	"  Set your hostname" \
   7.150 +        	2> $OUT
   7.151 +    	ret=$?
   7.152 +    	case `cat $OUT` in
   7.153 +       	hostname)
   7.154 +			get_hostname ;;
   7.155 +       	adress)
   7.156 +       		set_ip_adress ;;
   7.157 +    	esac
   7.158 +	done
   7.159 +}
   7.160 +
   7.161 +set_password()
   7.162 +{
   7.163 +	SEP='
   7.164 +'
   7.165 +	exec 3>&1
   7.166 +	PASSWORD=`$DIALOG --backtitle "$BACKTITLE" --title "Set password" --clear \
   7.167 + 		--separate-widget "$SEP" \
   7.168 + 		--insecure --passwordbox "Enter new password for user below: \n\n" 10 50 \
   7.169 +		--title "Confirme password" \
   7.170 +        --insecure --passwordbox "Confirme new password for user below: \n\n"	10 50 2>&1 1>&3`
   7.171 +	ret=$?
   7.172 +	exec 3>&-
   7.173 +	if [ -z "${PASSWORD}" ]; then
   7.174 +		msg "Password not set"
   7.175 +	else
   7.176 +		PASS1="$(echo $PASSWORD | cut -d ' ' -f1)"
   7.177 +		PASS2="$(echo $PASSWORD | cut -d ' ' -f2)"
   7.178 +		if [ "$PASS1" != "$PASS2" ]; then
   7.179 +			msg "Passwords don't match.\nNothing change."
   7.180 +		else
   7.181 +			echo  "root:$PASS1" | chpasswd
   7.182 +		fi
   7.183 +	fi
   7.184 +}
   7.185 +
   7.186 +##
   7.187 +# Program sequence
   7.188 +#
   7.189 +set_locale
   7.190 +check_root
   7.191 +
   7.192 +until [ $retval -eq 1 ];do
   7.193 +	$DIALOG --title "$MENU_TITLE" \
   7.194 +		--backtitle "$BACKTITLE" --clear \
   7.195 +		--cancel-label "Quitter" \
   7.196 +		--colors \
   7.197 +		--menu "$TAZ_CMD_MSG" 15 50 40\
   7.198 +		"keymap"  		"  Keyboard mapping" \
   7.199 +		"locale"      	"  Language setting" \
   7.200 +		"network"   	"  Netwok configuration" \
   7.201 +		"password" 		"  Change root password" \
   7.202 +		2> $OUT
   7.203 +	
   7.204 +	retval=$?
   7.205 +	
   7.206 +	# Execute commands
   7.207 +	#
   7.208 +	case `cat $OUT` in
   7.209 +		keymap)
   7.210 +			if [ -x /sbin/tazkeymap ]; then
   7.211 +				tazkeymap
   7.212 +			else
   7.213 +				msg "Unable to find tazkeymap !"
   7.214 +			fi
   7.215 +			;;
   7.216 +		locale)
   7.217 +			if [ -x /sbin/tazlocale ]; then
   7.218 +				tazlocale
   7.219 +			else
   7.220 +				msg "Unable to find tazlocale !"
   7.221 +			fi
   7.222 +			;;
   7.223 +		network)
   7.224 +			network_menu;;
   7.225 +		password)
   7.226 +			set_password ;;
   7.227 +	esac
   7.228 +done
   7.229 +
   7.230 +exit 0