modules/admin-full: fix wifi join
[project/luci.git] / contrib / package / asterisk-xip / files / uci / asteriskconf
1 #!/bin/sh
2
3 # Asterisk.conf
4
5 init_asteriskconf() {
6
7         ast_add_reload dialplan
8         ast_enable_type asterisk
9         ast_enable_type setglobal
10         ast_enable_type include
11         # ast_enable_type hardware
12         ast_enable_type hardwarereboot
13
14
15         asterisk_zone="Australia/Perth"
16         asterisk_spooldir="${DEST}/var/spool/asterisk"
17         asterisk_logdir="${DEST}/var/log/asterisk"
18         asterisk_agidir="${DEST}/usr/lib/asterisk/agi-bin"
19         return 0
20 }
21
22 asterisk_option_list="verbose debug quiet dontwarn timestamp execincludes \
23 highpriority initcrypto nocolor dumpcore languageprefix internal_timing \
24 systemname maxcalls maxload cache_record_files record_cache_dir \
25 transmit_silence_during_record transcode_via_sln runuser rungroup"
26 asterisk_path_list="spooldir logdir agidir"
27
28 valid_asterisk_option() {
29         is_in_list $1 ${asterisk_option_list} ${asterisk_path_list} zone 
30         return $?
31 }
32
33 create_asteriskconf() {
34         # echo ${DEST_DIR}
35         file=${DEST_DIR}/asterisk.conf
36         get_checksum asterisk_conf $file
37
38         echo "${asteriskuci_gen}${N}[directories]
39 astetcdir => ${DEST_DIR}
40 astmoddir => ${DEST}/usr/lib/asterisk/modules
41 astvarlibdir => ${DEST}/usr/lib/asterisk
42 astdatadir => ${DEST}/usr/lib/asterisk
43 astrundir => /var/run" > $file
44         for i in ${asterisk_path_list} ; do
45                 eval "value=\"\${asterisk_$i}\""
46                 if [ ! -z $value ] ; then
47                         echo "ast$i => $value" >> $file
48                 fi
49         done
50         echo "${N}[options]" >> $file
51
52         for i in ${asterisk_option_list} ; do
53                 eval "value=\"\${asterisk_$i}\""
54                 if [ ! -z $value ] ; then
55                         echo "$i => $value" >> $file
56                 fi
57         done
58
59         echo "${N}; Changing the following lines may compromise your security.
60 [files]
61 astctlpermissions = 0660
62 astctlowner = root
63 astctlgroup = nogroup
64 astctl = asterisk.ctl " >> $file
65         check_checksum "$asterisk_conf" "$file"  || ast_restart=1
66
67 }
68
69 handle_asterisk() {
70         option_cb() {
71                 case $1 in
72                         zone)
73                                 asterisk_zone="$2";;
74                         *)
75                                 if valid_asterisk_option $1 $2 ; then
76                                         eval "asterisk_${1}=\"$2\""
77                                 else
78                                         logerror "Invalid Asterisk option: $1"
79                                 fi
80                 esac
81         }
82 }
83
84 handle_include(){
85         option_cb() {
86                 case $1 in
87                         dialplan|dialplan_ITEM*)
88                                 append dialplan_includes "#include <$2>" "${N}"
89                         ;;
90                         dialplan_COUNT) ;;
91                         *) logerror "Invalid option \"$1\" for include" ;;
92                 esac
93         }
94 }
95
96 handle_setglobal() {
97         option_cb() {
98                 case $1 in
99                         set_COUNT) ;;
100                         set|set_ITEM*)
101                                 if [ "${2%=*}" == "${2}" ] ; then
102                                         logerror "SetGlobal option \"$2\" not of the form VARIABLE=Value"
103                                 else
104                                         append dialplan_globals "" "${N}"
105                                 fi ;;
106                         *) logerror "Invalid option \"$1\" for setglobal" ;;
107                 esac
108         }
109 }
110
111 handle_hardwarereboot() handle_hardware reboot
112
113 # Handle hardware options (reboot) for Softphones
114 handle_hardware() {
115         case $1 in
116                 reboot)
117                         hardware_method=
118                         hardware_param=
119                         option_cb() {
120                                 case $1 in
121                                         method)
122                                                 hardware_method="$2";;
123                                         param)
124                                                 case ${hardware_method} in
125                                                         web) append hardware_reboots "wget -q $2 -O - >&- 2>&-" "${N}" ;;
126                                                         system) append hardware_reboots "$2 >&- 2>&-" "${N}" ;; 
127                                                         *) logerror "Invalid Hardware reboot method: ${hardware_method}"
128                                                 esac
129                                 esac
130
131                         }
132                 ;;
133                 *) logerror "Invalid Hardware option: $1"
134         esac
135 }
136
137 reboot_hardware() {
138         cd /tmp
139         eval ${hardware_reboots}
140 }
141
142
143
144 # vim: ts=2 sw=2 noet foldmethod=indent