]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/dialog/samples/copismall
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / dialog / samples / copismall
1 #!/bin/bash
2 # $Id: copismall,v 1.8 2010/01/13 10:26:52 tom Exp $
3 #
4 #  ComeOn Point Installer! v0.9a.small (small version for cdialog v0.9a)
5 #  - installa il point in modo visuale e auto-detecting. Versione light.
6 #
7 #  AUTHOR: Beppe (beppe.dem@nsm.it)
8 #
9 #  This program is free software; you can redistribute it and/or
10 #  modify it under the terms of the GNU General Public License
11 #  as published by the Free Software Foundation; either version 2
12 #  of the License, or (at your option) any later version.
13 #
14 #  This program is distributed in the hope that it will be useful,
15 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 #  GNU General Public License for more details.
18 #
19 #  You should have received a copy of the GNU General Public License
20 #  along with this program; if not, write to the Free Software
21 #  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #
23
24 # THIS IS NOT THE ORIGINAL VERSION!!!! This files was adequate to be
25 # a demo for cdialog v0.9a+. However it doesn't include all its features.
26 # Look for one of the free ComeOn Linux! tools to have a complete
27 # demo of cdialog. ComeOn Linux! follows the GNU philosophy.
28 # Send peacefully a mail to demarco_p@abramo.it for more info.
29
30 . ./setup-vars
31
32 #COMEONDIR=/usr/lib/ComeOn
33 #POINTDIR=$COMEONDIR/point
34 POINTDIR=`pwd`
35
36 AKASETUP=$POINTDIR/.akasetup
37 PNTSETUP=$POINTDIR/.pntsetup
38 EMSIFILE=$POINTDIR/.emsi
39 COPIUSER=$POINTDIR/.copi.user
40 COPIVER=v0.9a.small
41 TITLE="ComeOn Point Installer! $COPIVER  -+-  (c) 1996 ComeOn Linux!"
42
43 #FUNCSVER=v0.9.2
44 #FUNCSDIR=$POINTDIR/funcs-$FUNCSVER
45 FUNCSDIR=$POINTDIR/copifuncs
46
47 #COPIDIR=$POINTDIR/copi-$COPIVER
48 #. $COPIDIR/copishellvars
49
50 #POINTVER="v1.1"                # ComeOn Point version
51
52 if [ $LOGNAME != root ]
53 then
54   $DIALOG --backtitle "$TITLE" --title "Error!" --beep --msgbox "Questo programma per funzionare correttamente deve essere avviato dall'amministratore di sistema (root)." 0 0
55   exit
56 fi
57
58
59 $DIALOG --backtitle "$TITLE" --title "Are you sure?" --cr-wrap --msgbox "Questo installer procedera' in modalita'
60 auto-detect all'installazione del point.
61 Premi <Enter> per iniziare o <Esc> per uscire. " 0 0
62
63 if [ $? = $DIALOG_CANCEL -o $? = $DIALOG_ESC ]; then
64  exit
65 fi
66
67
68 pushd $FUNCSDIR >/dev/null
69 . ./copi.funcs
70 . ./common.funcs
71 . ./admin.funcs
72
73 ###############################################################################
74 find_incompatible_packages
75
76 if [ "$PKG_TO_REMOVE" ]
77 then
78   $DIALOG --backtitle "$TITLE" --beep --title "Problem detected" --msgbox "Attenzione, prima di poter continuare bisogna avviare pkgtool e rimuovere i seguenti packages: $PKG_TO_REMOVE." 0 0
79   exit
80 fi
81
82 ###############################################################################
83 mkstemp dialog
84
85 find_necessary_packages
86
87 if [ "$PKG_TO_INSTALL" ]
88 then
89   echo -n "Attenzione, prima di poter continuare bisogna avviare setup ed installare i seguenti packages dai disk sets N (quelli del Networking): $PKG_TO_INSTALL." >$tmp_dialog
90
91   if [ "`echo $PKG_TO_INSTALL | grep tcpip`" ]
92   then
93     echo -n " Ricordarsi poi di effettuare lo shutdown per rendere effettive le modifiche." >>$tmp_dialog
94   fi
95
96   $DIALOG --backtitle "$TITLE" --beep --title "Problem detected" --msgbox "`cat $tmp_dialog`" 0 0
97
98   rm $tmp_dialog
99   exit
100 fi
101
102 ###############################################################################
103 mkstemp smailp
104
105 SMAILTGZ=""
106 if [ ! -d /usr/lib/smail ]
107 then
108   $DIALOG --backtitle "$TITLE" --title "Smail not found" --inputbox "Bisogna installare Smail, per cui inserire il percorso completo di dove trovarne i binari compressi" 0 0 "/cdrom/sunsite/system/Mail/delivery/smail-linuxbin-3.1.29.1.tar.gz" 2>$tmp_smailp
109   SMAILTGZ="`cat $tmp_smailp`"
110   rm $tmp_smailp
111   while [ ! -f "$SMAILTGZ" ]
112   do
113     $DIALOG --backtitle "$TITLE" --beep --title "Archive not found" --inputbox "Percorso di file \"$SMAILTGZ\" non valido, controllarne la correttezza." 0 0 "/cdrom/sunsite/system/Mail/delivery/smail-linuxbin-3.1.29.1.tar.gz" 2>$tmp_smailp
114     SMAILTGZ="`cat $tmp_smailp`"
115     rm $tmp_smailp
116   done
117 fi
118
119 ###############################################################################
120 mkstemp target
121 mkstemp asetup
122 mkstemp psetup
123
124 AKA=""
125 while [ ! "$AKA" ]
126 do
127   $DIALOG --backtitle "$TITLE" --title "Primary address" --inputbox "Inserire il proprio address principale, completo di point e di domain. Il poll sara' effettuato per default dal boss corrispondente." 0 0 "2:335/722.7@fidonet" 2>$tmp_target
128   AKAFTN="`cat $tmp_target`"
129   rm $tmp_target
130   fidonetpoint2int $AKAFTN
131   AKA="$_RETVAL"
132 done
133 echo -n "`echo $AKA | cut -f2- -d.`:" >$tmp_asetup
134 echo -n "`echo $AKA | cut -f1 -d. | cut -c2-`:" >$tmp_psetup
135 AKASFTN="$AKAFTN"
136 AKAS="$AKA"
137 while [ "$AKAFTN" ]
138 do
139   $DIALOG --backtitle "$TITLE" --title "AKAs" --inputbox "Inserire un eventuale address secondario, oppure lasciare la riga vuota per proseguire. Attenzione: nel caso si abbiano piu' indirizzi sulla stessa rete, bisognera' configurare solo uno di questi.  Gli indirizzi correntemente definiti sono: $AKASFTN" 0 0 2>$tmp_target
140   AKAFTN="`cat $tmp_target`"
141   rm $tmp_target
142   if [ "$AKAFTN" ]
143   then
144     fidonetpoint2int $AKAFTN
145     AKA="$_RETVAL"
146     if [ "`echo $AKAS | grep \".\`echo $AKA | cut -f5 -d.\`.\"`" ]
147     then
148       $DIALOG --backtitle "$TITLE" --beep --title "Invalid address" --msgbox "Non si possono avere piu' indirizzi sullo stesso dominio (net)." 0 0
149     else
150       AKASFTN="$AKASFTN $AKAFTN"
151       AKAS="$AKAS $AKA"
152       echo -n "`echo $AKA | cut -f2- -d.`:" >>$tmp_asetup
153       echo -n "`echo $AKA | cut -f1 -d. | cut -c2-`:" >>$tmp_psetup
154     fi
155   fi
156 done
157 echo ":" >>$tmp_asetup
158 echo ":" >>$tmp_psetup
159 save $AKASETUP
160 save $PNTSETUP
161 mv $tmp_asetup $AKASETUP
162 mv $tmp_psetup $PNTSETUP
163
164 ###############################################################################
165 mkstemp hostnm
166
167 $DIALOG --backtitle "$TITLE" --title "Hostname" --inputbox "Inserire l'hostname di questo computer qualora si abbia una rete gia' configurata, altrimenti inventarne uno fittizio da assegnare e questa macchina verra' configurata per il loopback." 0 0 "quark.comeon.org" 2>$tmp_hostnm
168 NEW_HOSTNAME="`cat $tmp_hostnm`"
169 rm $tmp_hostnm
170
171 ###############################################################################
172 mkstemp master
173
174 $DIALOG --backtitle "$TITLE" --title "Point admin" --inputbox "Scegliere l'user principale per la gestione e l'uso del point. Se l'user non esiste, verra' creato. Se esiste, ne verranno adattate le informazioni quali nome, gruppi, etc." 0 0 "beppe" --and-widget --title "Insert SysOp's name" --inputbox "Inserire nome e cognome del gestore ed utilizzatore principale del point (il proprio nome)." 0 0 "Giuseppe De Marco" --and-widget --title "Choose editor" --inputbox "Scegliere l'editor da usare per scrivere i messaggi" 0 0 "vim" 2>$tmp_master
175 POST_USER="`cut $tmp_master -f1`"
176 POST_NAME="`cut $tmp_master -f2`"
177 POST_EDIT="`cut $tmp_master -f3`"
178 rm $tmp_master
179 save $COPIUSER
180 echo $POST_USER >$COPIUSER
181
182 ###############################################################################
183 mkstemp expire
184 mkstemp origin
185
186 $DIALOG --backtitle "$TITLE" --title "Origin" --inputbox "Scegliere l'Origin del sistema" 9 60 "$POST_USER's linux box" 2>$tmp_origin
187 NEW_ORIGIN="`cat $tmp_origin`"
188 rm $tmp_origin
189
190 $DIALOG --backtitle "$TITLE" --title "News expiring" --inputbox "Decidere per quanti giorni i messaggi echomail (le news) dovranno transitare sul sistema prima di venire cancellati automaticamente da news.daily. Inserire never se si vuole che non vengano mai cancellati. Sono ammesse cifre decimali (i.e. 25.5).  Notare comunque che il valore qui inserito e' quello di default, ma per ogni singola area (newsgroup) sara' possibile specificare poi un valore appropriato." 0 0 "30" 2>$tmp_expire
191 KEEPDAYS="`cat $tmp_expire`"
192 rm $tmp_expire
193
194 ###############################################################################
195 mkstemp dialer
196 mkstemp ifmail
197 mkstemp mailvr
198 mkstemp passwd
199
200 IFMAILTGZ=""
201 IFMAILVERS=""
202 if [ ! -d /usr/lib/ifmail -o ! -d /etc/ifmail -o ! -d /var/log/ifmail -o ! -f /usr/lib/ifmail/ifcico ]
203 then
204   $DIALOG --backtitle "$TITLE" --title "ifmail not found" --inputbox "Inserire il percorso COMPLETO dei sorgenti compressi di ifmail che verranno decompressi in /usr/src e compilati." 0 0 "/cdrom/sunsite/system/Mail/transport/ifmail-2.8b.tar.gz" 2>$tmp_ifmail
205   IFMAILTGZ="`cat $tmp_ifmail`"
206   rm $tmp_ifmail
207   while [ ! -f "$IFMAILTGZ" ]
208   do
209     $DIALOG --backtitle "$TITLE" --beep --title "invalid filename" --inputbox "Percorso di file \"$IFMAILTGZ\" non valido, controllarne la correttezza." 0 0 "/cdrom/sunsite/system/Mail/transport/ifmail-2.8b.tar.gz" 2>$tmp_ifmail
210     IFMAILTGZ="`cat $tmp_ifmail`"
211     rm $tmp_ifmail
212   done
213
214   $DIALOG --backtitle "$TITLE" --title "ifmail version" --inputbox "Specificare la versione di ifmail" 0 0 "2.8b" 2>$tmp_mailvr
215   IFMAILVERS="`cat $tmp_mailvr` + ComeOn Point $POINTVER"
216   rm $tmp_mailvr
217 fi
218
219 IAKA=1
220 PASSW=""
221 AKA="`cut $AKASETUP -f$IAKA -d:`"
222 while [ "$AKA" ]
223 do
224   int2fido $AKA
225   AKAFTN="$_RETVAL"
226   $DIALOG --backtitle "$TITLE" --title "Password" --inputbox "Specificare la password di sessione e per i pacchetti per il nodo $AKAFTN -- attenzione che alcuni mailers accettano solo passwords da 8 caratteri in maiuscolo!!" 0 0 "MYPASSWD" 2>$tmp_passwd
227   PASSW="$PASSW`cat $tmp_passwd`:"
228   rm $tmp_passwd
229   IAKA=$[$IAKA+1]
230   AKA="`cut $AKASETUP -f$IAKA -d:`"
231 done
232 PASSW="$PASSW:"
233
234 $DIALOG --backtitle "$TITLE" \
235 --title "Modem speed" --inputbox "Specificare la velocita' del proprio modem (che sta su /dev/modem)" 0 0 "16800" --and-widget \
236 --title "System name" --inputbox "Specificare il nome del sistema per il pacchetto EMSI" 0 0 "`cat $COPIUSER`'s linux point" --and-widget \
237 --title "Location" --inputbox "Inserire la localita' fisica in cui risiede il sistema" 0 0 "Catanzaro, Italy - Europe" --and-widget \
238 --title "Phone number" --inputbox "Inserire il proprio numero di telefono in formato internazionale, cioe' completo di doppio prefisso (xx-yyy-zzzzzz)" 0 0 "39-961-31997" --and-widget \
239 --title "International call prefix" --inputbox "Specificare il prefisso da comporre per poter effettuare una chiamata internazionale (se ci si trova in Italia ad es. bisogna inserire 00)" 0 0 "00" --and-widget \
240 --title "Long-distance call prefix" --inputbox "Specificare il prefisso da comporre per poter effettuare una chiamata interurbana in ambito nazionale, che verra' sostituito al prefisso della propria nazione quando incontrato in nodelist (per l'Italia ad es. bisogna inserire 0, che sostituira' il 39)" 0 0 "0" --and-widget \
241 --title "Pointlist flags" --inputbox "Inserire eventuali flags stile pointlist per il pacchetto EMSI" 0 0 "MO,V32B,V42B,ZYX" --and-widget \
242 --title "Modem dialing" --inputbox "Inserire la stringa da inviare al modem per comporre un numero telefonico" 0 0 "ATDT" 2>$tmp_dialer
243
244 echo -en "\t$POST_NAME\t\t" >>$tmp_dialer
245 save $EMSIFILE
246 mv $tmp_dialer $EMSIFILE
247
248 ###############################################################################
249
250 if [ -d /etc/smail ]
251 then
252   SMAILCFGDIR=/etc/smail
253 else
254   SMAILCFGDIR=/usr/lib/smail
255 fi
256
257 ###############################################################################
258
259 $DIALOG --backtitle "$TITLE" --title "First step completed!" --msgbox "OK, ora ho tutte le informazioni necessarie per poter installare il point. Da qui in poi faro' tutto da solo, quindi ci si puo' tranquillamente andare a prendere un caffe'. :-)" 0 0
260
261 ###############################################################################
262
263 killall sendmail 2>/dev/null
264 if [ $SMAILTGZ ]; then tar zxvf $SMAILTGZ -C / >/dev/null; fi
265 /usr/sbin/sendmail -bd -q15m
266
267 if [ ! "`ping -c1 $NEW_HOSTNAME | grep \"1 packets received\"`" ]; then
268   configure_loopback $NEW_HOSTNAME
269 fi
270
271 add_postmaster "$POST_USER" "$POST_NAME"
272 add_alias "$POST_NAME" "$POST_USER"
273 configure_trn "$POST_USER" "$POST_EDIT"
274 configure_elm "$POST_USER" "$POST_EDIT"
275
276 comment_nntp_in_inetdconf
277 set_organization "$NEW_ORIGIN"
278 create_innconf_newsfeeds_distrib
279 create_expirectl $KEEPDAYS
280 create_nnrpaccess
281 create_hostsnntp
282 create_dirs_and_files
283 install_rcnews
284 install_crontab_news
285 if [ $IFMAILTGZ ]; then
286   install_ifmail "$IFMAILTGZ" /usr/lib/ifmail /etc/ifmail /var/log/ifmail "$IFMAILVERS" /usr/src
287 fi
288 configure_ifmail /usr/lib/ifmail /etc/ifmail /var/log/ifmail "$PASSW"
289 configure_smail $SMAILCFGDIR
290
291 ###############################################################################
292 $DIALOG --backtitle "$TITLE" \
293 --title "-=[ Enjoy! ]=-" --msgbox "Il point e' stato installato con successo!" 0 0 --and-widget \
294 --msgbox "trn (il newsreader, per leggere/scrivere gli echomail) ed elm (il mailreader, per leggere/scrivere i netmail) sono gia' stati configurati per l'user $POST_USER." 0 0
295
296 popd >/dev/null