summaryrefslogtreecommitdiffhomepage
path: root/contrib/asterisk-xip/files/uci/asteriskconf
blob: d90f9d9cd9381049822c675eff1880393f276197 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/sh

# Asterisk.conf

init_asteriskconf() {

	ast_add_reload dialplan
	ast_enable_type asterisk
	ast_enable_type setglobal
	ast_enable_type include
	# ast_enable_type hardware
	ast_enable_type hardwarereboot


	asterisk_zone="Australia/Perth"
	asterisk_spooldir="${DEST}/var/spool/asterisk"
	asterisk_logdir="${DEST}/var/log/asterisk"
	asterisk_agidir="${DEST}/usr/lib/asterisk/agi-bin"
	return 0
}

asterisk_option_list="verbose debug quiet dontwarn timestamp execincludes \
highpriority initcrypto nocolor dumpcore languageprefix internal_timing \
systemname maxcalls maxload cache_record_files record_cache_dir \
transmit_silence_during_record transcode_via_sln runuser rungroup"
asterisk_path_list="spooldir logdir agidir"

valid_asterisk_option() {
	is_in_list $1 ${asterisk_option_list} ${asterisk_path_list} zone 
	return $?
}

create_asteriskconf() {
	# echo ${DEST_DIR}
	file=${DEST_DIR}/asterisk.conf
	get_checksum asterisk_conf $file

	echo "${asteriskuci_gen}${N}[directories]
astetcdir => ${DEST_DIR}
astmoddir => ${DEST}/usr/lib/asterisk/modules
astvarlibdir => ${DEST}/usr/lib/asterisk
astdatadir => ${DEST}/usr/lib/asterisk
astrundir => /var/run" > $file
	for i in ${asterisk_path_list} ; do
		eval "value=\"\${asterisk_$i}\""
		if [ ! -z $value ] ; then
			echo "ast$i => $value" >> $file
		fi
	done
	echo "${N}[options]" >> $file

	for i in ${asterisk_option_list} ; do
		eval "value=\"\${asterisk_$i}\""
		if [ ! -z $value ] ; then
			echo "$i => $value" >> $file
		fi
	done

	echo "${N}; Changing the following lines may compromise your security.
[files]
astctlpermissions = 0660
astctlowner = root
astctlgroup = nogroup
astctl = asterisk.ctl " >> $file
	check_checksum "$asterisk_conf" "$file"  || ast_restart=1

}

handle_asterisk() {
	option_cb() {
		case $1 in
			zone)
				asterisk_zone="$2";;
			*)
				if valid_asterisk_option $1 $2 ; then
					eval "asterisk_${1}=\"$2\""
				else
					logerror "Invalid Asterisk option: $1"
				fi
		esac
	}
}

handle_include(){
	option_cb() {
		case $1 in
			dialplan|dialplan_ITEM*)
				append dialplan_includes "#include <$2>" "${N}"
			;;
			dialplan_COUNT) ;;
			*) logerror "Invalid option \"$1\" for include" ;;
		esac
	}
}

handle_setglobal() {
	option_cb() {
		case $1 in
			set_COUNT) ;;
			set|set_ITEM*)
				if [ "${2%=*}" == "${2}" ] ; then
					logerror "SetGlobal option \"$2\" not of the form VARIABLE=Value"
				else
					append dialplan_globals "" "${N}"
				fi ;;
			*) logerror "Invalid option \"$1\" for setglobal" ;;
		esac
	}
}

handle_hardwarereboot() handle_hardware reboot

# Handle hardware options (reboot) for Softphones
handle_hardware() {
	case $1 in
		reboot)
			hardware_method=
			hardware_param=
			option_cb() {
				case $1 in
					method)
						hardware_method="$2";;
					param)
						case ${hardware_method} in
							web) append hardware_reboots "wget -q $2 -O - >&- 2>&-" "${N}" ;;
							system) append hardware_reboots "$2 >&- 2>&-" "${N}" ;; 
							*) logerror "Invalid Hardware reboot method: ${hardware_method}"
						esac
				esac

			}
		;;
		*) logerror "Invalid Hardware option: $1"
	esac
}

reboot_hardware() {
	cd /tmp
	eval ${hardware_reboots}
}



# vim: ts=2 sw=2 noet foldmethod=indent