modules/admin-full: fix wifi join
[project/luci.git] / contrib / package / asterisk-xip / files / uci / moduleconf
1 #!/bin/sh
2
3 # Module.conf
4
5 init_moduleconf() {
6         ast_add_reload module
7         ast_enable_type module
8
9         for i in ${module_list} ; do
10                 eval module_${i}=no
11         done
12
13         enable_module app_dial
14         enable_module app_read
15
16         enable_module app_verbose
17         enable_module pbx_config
18         enable_module pbx_functions
19
20         enable_module app_transfer
21         module_chan_local=auto
22         # Sound files are all gsm
23         enable_format gsm
24
25         enable_module app_func_strings
26 }
27
28 # List of modules in sensible load order.
29 module_list="res_agi res_adsi res_config_mysql res_crypto res_smdi res_features \
30  res_indications res_convert res_jabber res_monitor res_musiconhold res_speech \
31  res_clioriginate pbx_ael pbx_config pbx_functions pbx_loopback pbx_realtime \
32  pbx_spool pbx_wilcalu func_base64 func_callerid func_cdr func_channel func_cut \
33  func_db func_enum func_env func_global func_groupcount func_language func_logic \
34  func_moh func_rand func_realtime func_sha1 func_strings func_timeout func_uri \
35  cdr_csv cdr_custom cdr_manager cdr_mysql cdr_pgsql cdr_sqlite chan_agent \
36  chan_alsa chan_gtalk chan_h323 chan_iax2 chan_local chan_sip format_au \
37  format_g723 format_g726 format_g729 format_gsm format_h263 format_h264 \
38  format_ilbc format_jpeg format_mp3 format_pcm format_pcm_alaw format_sln \
39  format_vox format_wav format_wav_gsm app_alarmreceiver app_amd app_authenticate \
40  app_cdr app_chanisavail app_channelredirect app_chanspy app_controlplayback \
41  app_cut app_db app_dial app_dictate app_directed_pickup app_directory app_disa \
42  app_dumpchan app_echo app_enumlookup app_eval app_exec app_externalivr \
43  app_followme app_forkcdr app_getcpeid app_groupcount app_hasnewvoicemail \
44  app_ices app_image app_lookupblacklist app_lookupcidname app_macro app_math \
45  app_md5 app_meetme app_milliwatt app_mixmonitor app_morsecode \
46  app_parkandannounce app_playback app_privacy app_queue app_random app_read \
47  app_readfile app_realtime app_record app_sayunixtime app_senddtmf app_sendtext \
48  app_setcallerid app_setcdruserfield app_setcidname app_setcidnum app_setrdnis \
49  app_settransfercapability app_sms app_softhangup app_speech_utils app_stack \
50  app_system app_talkdetect app_test app_transfer app_txtcidname app_url \
51  app_userevent app_verbose app_voicemail app_waitforring app_waitforsilence \
52  app_while codec_a_mu codec_adpcm codec_alaw codec_g726 codec_gsm codec_ilbc \
53  codec_lpc10 codec_speex codec_ulaw"
54
55 # Enable a module - for use by other scripts
56 enable_module() {
57         logdebug 3 "Enable ${1}"
58         eval module_${1}=yes
59 }
60
61 module_enabled() {
62         eval local is_enabled="\${module_${1}}"
63         if [ ${is_enabled} == "no" ] ; then
64                 return 1
65         else
66                 return 0
67         fi
68 }
69
70 # Enable a sound format - for use by other scripts
71 enable_format() {
72         while [ ! -z $1 ] ; do
73                 case $1 in
74                         gsm)
75                                 enable_module format_gsm
76                                 enable_module codec_gsm
77                                 [ "${module_format_wav}" = "yes" ] && enable_module format_wav_gsm ;;
78                         wav)
79                                 enable_module format_wav
80                                 [ "${module_format_gsm}" = "yes" ] && enable_module format_wav_gsm ;;
81                         alaw)
82                                 enable_module codec_adpcm
83                                 enable_module codec_alaw
84                                 [ "${module_format_pcm}" = "yes" ] && enable_module format_pcm_alaw ;;
85                         pcm)
86                                 enable_module format_pcm_alaw
87                                 [ "${module_format_alaw}" = "yes" ] && enable_module format_pcm_alaw ;;
88                         ulaw)
89                                 enable_module codec_ulaw ;;
90                         g729|g726|g723)
91                                 enable_module format_g726
92                                 enable_module codec_g726 ;;
93                         ilbc)
94                                 enable_module format_ilbc
95                                 enable_module codec_ilbc ;;
96                         sln)   enable_module format_sln ;;
97                         mp3)   enable_module format_mp3 ;;
98                         vox)   enable_module format_vox ;;
99                         speex) enable_module codec_speex ;;
100                 esac
101                 shift
102         done
103 }
104
105 create_moduleconf() {
106         local file=${DEST_DIR}/modules.conf
107
108         get_checksum module_conf $file
109
110         rm -f ${file}.orig
111         [ -f "${file}" ] && mv ${file} ${file}.orig
112
113         echo "${asteriskuci_gen}[modules]${N}autoload=yes" > $file
114         for i in ${module_list} ; do
115                 eval res=\${module_${i}}
116                 case $res in
117                         yes) echo "load   => $i.so" >> $file ;;
118                         no)  echo "noload => $i.so" >> $file ;;
119                 esac
120         done
121         echo "${N}[global]${N}chan_modem.so=no"  >> $file
122
123         check_checksum "$module_conf" "$file"  || ast_module_restart=1
124 }
125
126 reload_module() {
127         local file=${DEST_DIR}/modules.conf
128         local cmd=`diff ${file}.orig ${file} -u -U0 | grep '^+\(no\)\?load' | sed 's/+load[[:space:]]*=>[[:space:]]*\(.*\)$/\"module load \1\"/' | sed 's/+noload[[:space:]]*=>[[:space:]]*\(.*\)$/\"module unload \1\"/'| tr '\n' ' '`
129         [ "${testing_mode}" != "1" ] && rm -f ${file}.orig
130         logdebug 3 "Module reload: ${N}$cmd"
131         eval "astcmds $cmd"
132 }
133
134
135 valid_module() {
136         is_in_list $1 ${module_list}
137         return $?
138 }
139
140 handle_module() {
141         option_cb() {
142                 if valid_module $1 ; then
143                         eval module_$1="$2"
144                 else
145                         logerror "Invalid module: $1"
146                 fi
147         }
148 }
149
150
151 # vim: ts=2 sw=2 noet foldmethod=indent