f9d069e3b42244b266da70f64eb3f7c3615730e5
[openwrt/svn-archive/archive.git] / net / imspector / files / imspector.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2008 OpenWrt.org
3 START=50
4
5 DAEMON=/usr/sbin/imspector
6 CFGFILE=/var/etc/imspector.conf
7
8 start() {
9 config_load imspector
10 config_foreach start_imspector imspector
11 }
12
13 stop() {
14 start-stop-daemon -q -x "$DAEMON" -K
15 rm -f $CFGFILE
16 }
17
18 restart() {
19 stop
20 sleep 2
21 start
22 }
23
24 start_imspector() {
25 config_get_bool enable "$1" enable
26 [ "$enable" -eq "1" ] || return 0
27
28 echo '### AUTOGENERATED CONFIGURATION' > $CFGFILE
29 echo '### DO NOT EDIT' >> $CFGFILE
30 echo '### SEE /etc/config/imspector INSTEAD' >> $CFGFILE
31 echo '' >> $CFGFILE
32
33 imspector_options='listenaddr port http_port pidfilename plugin_dir
34 user group ssl ssl_key ssl_cert icq_protocol irc_protocol
35 msn_protocol yahoo_protocol gg_protocol jabber_protocol
36 https_protocol log_typing_events file_logging_dir
37 badwords_filename badwords_replace_character badwords_block_count
38 acl_filename db_filter_filename block_unlisted block_files block_webcams
39 mysql_server mysql_database mysql_username mysql_password
40 sqlite_file pgsql_connect censord'
41
42
43 for option in $imspector_options; do
44 imspector_atom "$1" "$option" '"' >> $CFGFILE
45 done
46
47
48 start-stop-daemon -S -q -x "$DAEMON" -- -c "$CFGFILE"
49 }
50
51 imspector_atom() {
52 local SECTION=$1
53 local OPTION=$2
54
55 config_get _value "$SECTION" "$OPTION"
56 [ -n "$_value" -o "$EMPTY_DISABLED" -eq "1" ] && {
57 echo "$OPTION=${_value}"
58 }
59 }