hbbs

[archived] bbs.hlirc.net
git clone https://hhvn.uk/hbbs
git clone git://hhvn.uk/hbbs
Log | Files | Refs | README | LICENSE

hbbs.sh (1501B)


      1 #!/bin/sh
      2 
      3 
      4 trap 'die "SIGINT received"' 2
      5 
      6 # xinetd
      7 trap 'die "connection lost"' 1 #SIGHUP
      8 
      9 export cwd=$(dirname $0)
     10 [ ! -f $cwd/config.sh ] && cp $cwd/config.def.sh $cwd/config.sh
     11 . $cwd/include/common.sh
     12 . $cwd/include/log.sh
     13 . $cwd/config.sh
     14 
     15 mkdir $datadir -p    || die "cannot write to data dir"
     16 touch $datadir/.test || die "cannot write to data dir"
     17 mkdir -p \
     18 	$datadir/profile \
     19 	$datadir/boards \
     20 	$datadir/users \
     21 	$(for b in $(echo "$boards" | tr '[:upper:]' '[:lower:]'); do echo $datadir/boards/$b; done) \
     22 	$datadir/log
     23 touch $datadir/log/log
     24 
     25 add_log "connection" "${REMOTE_HOST:-localhost}"
     26 [ $(get_log_time "connection" | grep "^$(date +%H:%M)" | awk '{print $2}' | \
     27 	grep -v localhost | grep "${REMOTE_HOST:-localhost}" | wc -l) -eq $connection_limit ] && \
     28 	error "$connection_limit+ connection attempts in one minute - throttling for an hour" && \
     29 	add_log "throttled" "${REMOTE_HOST:-localhost}" && die "throttled"
     30 [ "$(get_log_time "throttled" | grep "$(date +%H:)" | awk '{print $2}' | \
     31 	grep -v localhost | grep "${REMOTE_HOST:-localhost}")" != "" ] && \
     32 	die "throttled"
     33 
     34 [ "$1" = "-f" ] && bin finger && exit 1
     35 
     36 info "Setting terminal to $term"
     37 export TERM="$term"
     38 info "Your terminal must be $term_height tall"
     39 info "Your terminal must be $term_width wide"
     40 info "Welcome to hbbs version $(cat $cwd/.version)"
     41 anykey
     42 sleep 0.1
     43 
     44 count=0
     45 while ! bin login
     46 do
     47 	anykey
     48 	count=$(($count+1))
     49 	[ $count -eq 5 ] && die "five failed login attempts"
     50 done
     51 
     52 echo
     53 anykey
     54 bin interface