e4de45b61383a76713ee3e0363fd4b3776a5772e
[packages.git] / net / stunnel / files / stunnel.init
1 #!/bin/sh
2
3 case "$1" in
4     start|boot)
5         if [ -s "/etc/stunnel/stunnel.pem" ]; then
6                 chmod og-rwx /etc/stunnel/stunnel.pem
7                 stunnel
8         else
9                 [ -e /etc/stunnel/config ] && \
10                 . /etc/stunnel/config
11
12                 X509_CN=${X509_CN:-"router"}
13                 X509_O=${X509_O:-"openwrt.org"}
14                 X509_OU=${X509_OU:-"open-source firmware"}
15                 
16                 [ -x /sbin/keygen ] && {
17                 (keygen "$X509_CN" "$X509_O" "$X509_OU" > /etc/stunnel/stunnel.pem;
18                         chmod og-rwx /etc/stunnel/stunnel.pem;
19                         stunnel) &
20                 }
21         fi
22         ;;
23     stop)
24         killall stunnel
25         killall -9 stunnel
26         ;;
27 esac