#!/bin/mksh # The FreeWRT Webinterface – Initialisation script # Based in part on /etc/rc from MirOS BSD #- # Copyright © 2006, 2007 # Thorsten Glaser # # Provided that these terms and disclaimer and all copyright notices # are retained or reproduced in an accompanying document, permission # is granted to deal in this work without restriction, including un- # limited rights to use, publicly perform, distribute, sell, modify, # merge, give away, or sublicence. # # Advertising materials mentioning features or use of this work must # display the following acknowledgement: # This product includes material provided by Thorsten Glaser. # # This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to # the utmost extent permitted by applicable law, neither express nor # implied; without malicious intent or gross negligence. In no event # may a licensor, author or contributor be held liable for indirect, # direct, other damage, loss, or other issues arising in any way out # of dealing in the work, even if advised of the possibility of such # damage or existence of a defect, except proven that it results out # of said person's immediate fault when using the work as intended. #- #FWINIT 89 . /etc/rc.conf case $1 in autostart) test x"$fwwif" = x"NO" && exit 0 exec mksh $0 start ;; start) mkdir -p /var/run (cd /etc/fwwif; if test ! -e https.cer || test ! -e https.key; then echo >&2 fwwif: generating SSL key/cert pair... rm -f https.* umask 077 if ! openssl genrsa -out https.key 1024; then echo >&2 fwwif: key generation failed rm -f https.key exit 1 fi chown 0:0 https.key; chmod 0400 https.key umask 022 if ! openssl req -batch -new -subj "/CN=192.168.1.1/" \ -key https.key -x509 -out https.cer; then echo >&2 fwwif: cert generation failed rm -f https.cer exit 1 fi echo >&2 done fi || :) /usr/bin/tntnet -c /etc/fwwif/fwwif.conf ;; autostop|stop) trap '' HUP TERM KILL killall tntnet sleep 3 killall tntnet sleep 3 ;; restart) mksh $0 stop mksh $0 start ;; version) /usr/ucb/what /usr/lib/fwwif/*.so exit 0 ;; *) echo "Usage: $0 {start | stop | restart | version}" exit 1 ;; esac exit $?