summaryrefslogtreecommitdiffstats
path: root/net/imspector/files/imspector.init
blob: 8c0b991632a9f501e167245a897297a810df44f4 (plain)
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
#!/bin/sh /etc/rc.common
# Copyright (C) 2008-2011 OpenWrt.org

START=50

CFGFILE=/var/etc/imspector.conf

atom() {
	local section="$1"
	local option="$2"

	config_get _value "$section" "$option"
	[ -n "$_value" ] && echo "$option=${_value}"
}

start_instance() {
	local section="$1"

	config_get_bool enabled "$section" enabled '0'
	[ $enabled -gt 0 ] || return 1

	echo '### AUTOGENERATED CONFIGURATION' > $CFGFILE
	echo '### DO NOT EDIT' >> $CFGFILE
	echo '### SEE /etc/config/imspector INSTEAD' >> $CFGFILE
	echo '' >> $CFGFILE

	options='listenaddr port http_port pidfilename plugin_dir
		user group ssl ssl_key ssl_cert ssl_ca_key ssl_ca_cert
		ssl_cert_dir ssl_verify_dir ssl_verify response_prefix
		response_postfix responder_filename notice_days notice_response
		filtered_mins filtered_response icq_protocol irc_protocol
		msn_protocol yahoo_protocol gg_protocol jabber_protocol
		https_protocol log_typing_events file_logging_dir mysql_server
		mysql_database mysql_username mysql_password sqlite_file
		pgsql_connect badwords_filename badwords_replace_character
		badwords_block_count acl_filename db_filter_filename
		block_files block_webcams censord'
	
	for option in $options; do
		atom "$section" "$option" '"' >> $CFGFILE
	done

	service_start /usr/sbin/imspector -c "$CFGFILE"
}

start() {
	mkdir -m 0755 -p /var/etc
	mkdir -m 0755 -p /var/log/imspector

	config_load 'imspector'
	config_foreach start_instance 'imspector'
}

stop() {
	service_stop /usr/sbin/imspector
}