File: fbb.in

package info (click to toggle)
fbb 7.07-3
  • links: PTS
  • area: main
  • in suites: buster
  • size: 5,244 kB
  • ctags: 8,123
  • sloc: ansic: 87,810; sh: 2,324; makefile: 297
file content (567 lines) | stat: -rw-r--r-- 10,405 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
#!/bin/bash
FBBCONF=@sysconfdir@/ax25/fbb
CONFDIR=@sysconfdir@/ax25/fbb
DATADIR=@localstatedir@/ax25/fbb
FBBDIR=@localstatedir@/ax25/fbb
LIBDIR=@libdir@/fbb
SBINDIR=@sbindir@
DOCDIR=@docdir@

DOSDIR=$DATADIR/fbbdos
MAILIN=$FBBDIR/mail/mail.in
FBB=$SBINDIR/xfbbd

FBBLOG=/dev/null

#
# Do not change following lines
#

export CONFDIR DATADIR FBBDIR LIBDIR SBINDIR DOSDIR FBB MAILIN FBBLOG

# declare -a gives sometime problems...
# declare -a PORT_NAME NB_CH PORT_FREQ

VERSION=@package_version@

# run batches from the housekeeping directory
housekeeping()
{
	echo "Running $1"
	if [ -d $LIBDIR/script/$1 ] ; then
		for i in $LIBDIR/script/$1/*; do
    		test -x "$i" || continue
			echo "  script = $i"
			$i
		done
	fi
}

# send a mail to sysop
segv()
{
	MAIL_IN=`fbbgetconf import`
	SYSOP=`fbbgetconf sysop`
	cat << EOF >> $MAIL_IN
SP $SYSOP
Segmentation error
FBB gave a segmentation violation on `date`
/EX
EOF
}
		
replace()
{
	if [ ! -f $1 ] ; then
		return 0
	else
		echo -n "file `basename $1` already exists. Replace (Y/N) ? "
		read REP
		if [ "$REP" = "N" -o "$REP" = "n" ] ; then
	   		return 1
		else
			return 0
		fi
	fi
}

make_fbb_conf()
{
	echo "#"
	echo "# FBB Set-up file"
	echo "#"
	echo "# default is @sysconfdir@/ax25/fbb/fbb.conf"
	echo "#"
	echo "# may be changed using the $FBBCONF environment variable"
	echo "#"
	echo "##############################################################"
	echo "#"
	echo "# The following lines are mandatory"
	echo "#"
	echo "version = FBB$VERSION"
	echo "# Callsign of BBS"
	echo "callsign = $CALL.$ROUTE"
	echo "# SSID of BBS"
	echo "ssid = $SSID"
	echo "# Qra Locator of BBS"
	echo "qraloc = $QRALOC"
	echo "# Qth of BBS"
	echo "city = $CITY"
	echo "# First name of SYSOP"
	echo "name = $SYSOP_NAME"
	echo "# Callsign of SYSOP"
	echo "sysop = $SYSOP_CALL"
	echo "# Local time"
	echo "loca = $LOCALTIME"
}

make_epurmess_ini()
{
    cat <<EOF
#
# Parameters for messages processing
#
# This file is in $CONFDIR
#
# Messages directory
$DATADIR/mail/
#
# Compressed messages directory
$DATADIR/binmail/
#
# Archive messages directory
$DATADIR/oldmail/
#
# DIRMES.SYS file
$DATADIR/dirmes.sys
#
# DIRMES.OLD file name
$DATADIR/dirmes.old
#
# DIRMES.NEW file name
$DATADIR/dirmes.new
#
# Report file name
$DATADIR/epurmess.res
#
# Priv Bull (0=erased 1=archived)"
  1        0
#
# Cleaning parameters for private mail (in days)
#
# PN -> PX
60
#
# PY -> PX
5
#
# PF -> PK
1
#
# PX -> PK
2
#
# PK -> PA
2
#
# Cleaning parameters for bulletins (in days)
#
# BN -> BX
7
#
# B$ -> BX
7
#
# BY -> BX
7
#
# BX -> BK
4
#
# BF -> BX
7
#
# BK -> BA
1
#
# Automatic messages for not-forwarded messages. Days = 0 disables the message.
# 255 characters maximum for the line.
#
# Private messages returned : Timeout link default. (Days + text, $W=new line).
30 Sorry, the following message could not be routed due to link default.$WSuite a un probleme de reseau, le message suivant n'a pas pu etre achemine.$W
#
# Private messages returned : Unknown route. (Days + text, $W=new line).
2 No defined route for the following message. Please check the h-address.$WPas de route connue pour le messsage suivant. Verifiez l'adresse hierarchique.$W
#
# Nb of lines max in a returned message
10
#
------
#
# Special tests :
#
# Type To  Number_of_days
  @  ALL    1
  >  ALL    1
#
# End of file
#
EOF
}

get_fbb_conf()
{
	echo ""
	echo -n "Configuration files does not exist. Create them (Y/N) ?"
	read REP
	if [ "$REP" = "N" -o "$REP" = "n" ] ; then
		echo "Cannot run FBB without conf files"
	   	exit 0
	fi
	
	while true ; do
		echo
		echo -n "Callsign of the BBS without ssid   (Ex: F6FBB)        : "
		read CALL
		echo -n "SSID of the BBS                    (Ex : 1)           : "
		read SSID
		echo -n "Hierarchical address               (Ex : FMLR.FRA.EU) : "
		read ROUTE
		echo -n "QRA-Locator of the BBS             (Ex : JN03QL)      : "
		read QRALOC
		echo -n "City of the BBS                    (Ex : Toulouse)    : "
		read CITY
		echo -n "Name of the SysOp                  (Ex : Jean-Paul)   : "
		read SYSOP_NAME
		echo -n "Callsign of the SysOp without SSID (Ex : F6FBB)       : "
		read SYSOP_CALL
		echo -n "Difference with GMT time           (Ex : +1)          : "
		read LOCALTIME

		echo
		echo "BBS     : $CALL.$ROUTE"
		echo "SSID    : $SSID"
		echo "LOCATOR : $QRALOC ($CITY)"
		echo "SYSOP   : $SYSOP_CALL ($SYSOP_NAME)"
		echo "TIME    : GMT $LOCALTIME"
		while true ; do
			echo
			echo -n "Correct (Y/N) ? "
			read REP

			if [ "$REP" = "Y" -o "$REP" = "y" ] ; then
				break 2
			elif [ "$REP" = "N" -o "$REP" = "n" ] ; then
		    	break 1
			fi
		done
	done
	
	# Create fbb.conf file
	# mandatory part
	make_fbb_conf > $FBBCONF/fbb.conf
	# append optional part
	cat $FBBCONF/fbbopt.conf >> $FBBCONF/fbb.conf
}

make_port_fbb()
{
	NB=1

	echo "# FBB$VERSION"
	echo "#"
	echo "#Ports TNCs"
	echo " 1     $(( $NUMPORT - 1 ))"
	echo "#"
	echo "#Com Interface Adress (Hex) Baud"
	echo " 1   9         0            9600"
	echo "#"
	echo "#TNC NbCh Com MultCh Pacln Maxfr NbFwd MxBloc M/P-Fwd Mode  Freq"
	echo " 0   0    0   0      0     0     0     0      00/01   ----  File-fwd."
	while [ $NB -lt $NUMPORT ] ; do
		printf " %-2s  %-2s   1   %-6s 250   2     1     10     00/15   XUWYL %s\n"\
			$NB ${NB_CH[$NB]} ${PORT_NAME[$NB]} ${PORT_FREQ[$NB]}
		NB=$(( $NB + 1 ))
	done
	echo "#"
	echo "# End of file."
	echo "#"
}

get_fbb_port()
{
	if replace $CONFDIR/port.sys ; then

		NUMPORT=1

		while true ; do
			while true ; do
				echo
				echo -n "Name of the port #$NUMPORT as named in @sysconfdir@/ax25/axports (<CR> to end) : "
				read REP
				if [ -z "$REP" ] ; then
					break;
				fi
				PORT_NAME[$NUMPORT]=$REP
				echo -n "Number of channels [ex. 4]                           : "
				read REP
				NB_CH[$NUMPORT]=$REP
				echo -n "Frequency [ex. 145]                                  : "
				read REP
				PORT_FREQ[$NUMPORT]=$REP
				NUMPORT=$(( $NUMPORT + 1 ))
			done

			NB=1

			echo
			while [ $NB -lt $NUMPORT ] ; do
				echo "Port $NB on axports ${PORT_NAME[$NB]} (${NB_CH[$NB]} channels) Freq=${PORT_FREQ[$NB]}"
				NB=$(( $NB + 1 ))
			done

			while true ; do
				echo
				echo -n "Correct (Y/N) ? "
				read REP

				if [ "$REP" = "Y" -o "$REP" = "y" ] ; then
					break 2
				elif [ "$REP" = "N" -o "$REP" = "n" ] ; then
		    		break 1
				fi
			done
		done

		# Create port.sys file
		echo "Creating port.sys ... Ok"
		make_port_fbb > $CONFDIR/port.sys

		# Create beaconN.sys files
		NB=1
		while [ $NB -lt $NUMPORT ] ; do
			FILE=$CONFDIR/beacon$NB.sys
			if replace $FILE ; then
				echo "Creating beacon$NB.sys ... Ok"
				echo "% 15"   > $FILE
				echo "! MAIL" >> $FILE
				echo "\$d \$Tz Mailbox \$O-\$o (LINUX version)" >> $FILE
			fi
			NB=$(( $NB + 1 ))
		done

	fi
}

check_dir()
{
	if [ ! -d $1 ] ; then
		echo
		echo "Error : directory $1 does not exist."
		echo "FBB software was not correctly installed or configured"
		echo "Giving up !"
		exit 1;
	fi
}

fbb_tree()
{
	echo -n "Checking fbb tree."

	check_dir $CONFDIR
	check_dir $CONFDIR/lang
	echo -n "."

	check_dir $DATADIR
	check_dir $DATADIR/mail
	for n in 0 1 2 3 4 5 6 7 8 9 ; do
		check_dir $DATADIR/mail/mail$n
	done
	echo -n "."

	check_dir $DATADIR/binmail
	for n in 0 1 2 3 4 5 6 7 8 9 ; do
		check_dir $DATADIR/binmail/mail$n
	done
	echo -n "."

	check_dir $DATADIR/oldmail
	check_dir $DOCDIR
	check_dir $DATADIR/log
	check_dir $DATADIR/sat
	check_dir $DATADIR/wp
	check_dir $DOSDIR
	check_dir $DOSDIR/yapp
	check_dir $LIBDIR/pg
	check_dir $LIBDIR/filter
	check_dir $LIBDIR/server
	check_dir $LIBDIR/script
	check_dir $LIBDIR/tool
	
	echo " Ok"
}

fbb_conf()
{
	echo "Checking fbb configuration :"
	if [ -x $FBB ] ; then
		cd $FBBDIR
		$FBB -i
		if [ $? -ne 2 ] ; then
			echo "Configuration error ! Giving up."
			echo "Please read file @localstatedir@/ax25/fbb/ERROR.SYS"
			exit 1
		fi
	else
		echo "Program $FBB is not found or not executable ! Giving up."
		exit 1
	fi
}

fbb_end()
{
	echo "Received TERM signal"
	echo "killproc -TERM $FBB"
	killproc -TERM $FBB
	exit 1
}

fbb_return()
{
	echo
	
	case $1 in
	1)	# SIGTERM received
		housekeeping end_session
		exit 0
		;;
	2)	# /L and /M sysop commands
		housekeeping rerun
		;;
	3)	# /K sysop command and normal housekeeping
		housekeeping maintenance
		;;
	4)	# /A sysop command
		housekeeping stop_system
		exit 0
		;;
	5)	# "Segmentation violation" or "bus error"
		segv
		housekeeping sig_segv
		;;
	6)	# /R sysop command
		housekeeping reset
		exit 0
		;;
	*)	echo "Unknown return value $1"
		housekeeping error_return $ret
		;;
	esac
}

fbb_loop()
{
	PATH=$LIBDIR/tool:$SBINDIR:$PATH
	export PATH
	trap fbb_end TERM

	while true ; do

		cd $FBBDIR

		$FBB $FBB_PARAM &
		wait $!

		fbb_return $?

	done
}

fbb_run()
{
	echo
	echo -n "FBB options :"
	if [ -n "$FBB_PARAM" ] ; then
		echo "$FBB_PARAM"
	else
		echo " (none)"
	fi
	
	if [ $FBB_FG -eq 1 ] ; then
		echo "Running XFBB in foreground mode ^C to abort"
		sleep 5
		echo "Starting XFBB (pwd = `pwd`)..."
		fbb_loop > $FBBLOG 2>&1
	else
		echo "Running XFBB in background mode ^C to abort"
		sleep 5
		FBB_BACKGROUND=1
		export FBB_BACKGROUND
		echo "Starting XFBB (pwd = `pwd`)..."
		(cd $LOCALDIR ; $MY_SHELL $FBB_PARAM > $FBBLOG 2>&1 & )
		exit 0
	fi
}

fbb_help()
{
	echo "format : fbb [-f] [-h] [-s] [-l log_file]"
	echo "-f : run fbb in foreground"
	echo "-h : this help information"
	echo "-l : log debug info to log_file"
	echo "-q : run fbb silently"
	
	exit 0
}

fbb_opt()
{
	MY_SHELL=$0
	FBB_FG=0
	RUN_BG=0
	FBB_SILENT=0

	while [ $# -gt 0 ]; do
		case "$1" in
		-h)
			fbb_help
			;;
		-f) 
			FBB_FG=1 
			;;
		-q) 
			FBB_SILENT=1 
			;;
		-l) 
			FBBLOG=$2
			shift
			;;
		*)
			FBB_PARAM="$FBB_PARAM $1"
			;;
		esac
		shift
	done

	if [ -n "$FBB_BACKGROUND" ] ; then
		fbb_loop
		exit 0
	fi
}

LOCALDIR=`pwd`

# Looking for 7.06 & 7.05 fbb.conf locations
if [ ! -f $FBBCONF/fbb.conf ] ; then
	cd $FBBCONF
	cd ../
	if [ -f fbb.conf ] ; then
	cp fbb.conf $FBBCONF
	else
	get_fbb_conf
	fi
fi

# Check if exists epurmess.ini file. If not create it
if [ ! -f $FBBCONF/epurmess.ini ] ; then
	if replace $CONFDIR/epurmess.ini ; then
		make_epurmess_ini > $CONFDIR/epurmess.ini
	fi
fi

if [ ! -f $FBBCONF/port.sys ] ; then
	get_fbb_port
fi

fbb_opt $*
if [ $FBB_SILENT -eq 1 ] ; then
	fbb_tree > /dev/null 2>&1
	fbb_conf > /dev/null 2>&1
	fbb_run  > /dev/null 2>&1
else
	fbb_tree
	fbb_conf
	fbb_run
fi

exit 0