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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
|
#!/bin/sh
version=$(psql -qAt -U postgres -c "select value from provisioning_params where name='databaseversion'" provisioning)
if [ -z "$version" ]; then
version="0"
fi
echo "Version $version"
if [ "$version" -lt "1" ]; then
echo "Upgrading to database version 1"
# if current is older than 0.0.7-r1 we update.
#if [ "$(apk version -t $old 0.0.7-r1)" = "<" ]; then
psql -U postgres -c "INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='device'), 'Unsupported Phone', '999')"\
provisioning
psql -U postgres -c "INSERT INTO provisioning_groups VALUES(default, 'reg1', 'Registration 1 Unsupported', '10')"\
provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Unsupported Phone'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 1 Unsupported'))"\
provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 Unsupported'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)"\
provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 Unsupported'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, true)"\
provisioning
#fi
# if current is older than 0.0.8 we update.
#if [ "$(apk version -t $old 0.0.8)" = "<" ]; then
psql -U postgres -c "ALTER TABLE provisioning_params ADD COLUMN validate text" provisioning
psql -U postgres -c "UPDATE provisioning_params SET descr='Phone dial pattern based on section 2.1.5 of RFC 3435, plus a comma to turn dialtone back on', regexp='^[*#0-9xT|,.%[%]-]*\$' WHERE name='digitmap'" provisioning
psql -U postgres -c "UPDATE provisioning_params SET descr='Timeout in seconds for each segment of digit map (separated by ''|'')', regexp='^[0-9|]*\$' WHERE name='digitmaptimeout'" provisioning
psql -U postgres -c "UPDATE provisioning_params SET regexp='^%x%x%x%x%x%x%x%x%x%x%x%x\$', validate='local value, functions, params = ...\nvalue = string.upper(value)\nlocal others = functions.getselectresponse(\"SELECT count(*) FROM provisioning_values WHERE param_id=\\'\"..params.value.device.value.mac.param_id..\"\\' AND device_id!=\\'\"..params.value.device_id.value..\"\\' AND value=\\'\"..value..\"\\'\")\nif tonumber(others[1].count) > 0 then\n\treturn value, \"MAC Address must be unique\"\nend\nreturn value' WHERE name='mac'" provisioning
psql -U postgres -c "INSERT INTO provisioning_params VALUES(default, 'callwaitingenable', 'boolean', 'Call Waiting Enable', '', 'true', '205', '', null)" provisioning
psql -U postgres -c "INSERT INTO provisioning_params VALUES(default, 'speeddialenable', 'boolean', 'Speed Dial Enable', '', 'true', '206', '', null)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Standard Phone'), (SELECT param_id FROM provisioning_params WHERE name='callwaitingenable'), 'true', false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Standard Phone'), (SELECT param_id FROM provisioning_params WHERE name='speeddialenable'), 'true', false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Public Phone'), (SELECT param_id FROM provisioning_params WHERE name='callwaitingenable'), 'true', false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Public Phone'), (SELECT param_id FROM provisioning_params WHERE name='speeddialenable'), 'false', false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Hotline'), (SELECT param_id FROM provisioning_params WHERE name='callwaitingenable'), 'true', false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Hotline'), (SELECT param_id FROM provisioning_params WHERE name='speeddialenable'), 'false', false)" provisioning
#fi
# if current is older than 0.0.9 we update.
#if [ "$(apk version -t $old 0.0.9)" = "<" ]; then
psql -U postgres -c "INSERT INTO provisioning_params VALUES(default, 'mailbox', 'text', 'Voice Mailbox', 'Mailbox extension or URL', '', '207', '', null)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Standard Phone'), (SELECT param_id FROM provisioning_params WHERE name='mailbox'), '', true)" provisioning
#fi
# if current is older than 0.0.11 we update.
#if [ "$(apk version -t $old 0.0.11)" = "<" ]; then
psql -U postgres -c "INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='device'), 'Polycom SoundPoint IP 450 SIP', '2')" provisioning
psql -U postgres -c "INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='device'), 'Polycom SoundPoint IP 550/560 SIP', '3')" provisioning
psql -U postgres -c "INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='device'), 'Polycom VVX 1500', '6')" provisioning
psql -U postgres -c "UPDATE provisioning_classes SET label='Polycom SoundStation IP 5000/6000/7000 SIP', seq='5' WHERE label='Polycom SoundStation IP 6000 SIP'" provisioning
psql -U postgres -c "UPDATE provisioning_classes SET label='Polycom SoundPoint IP 320/321/330/331/335 SIP', seq='1' WHERE label='Polycom SoundPoint IP 321/331/335 SIP'" provisioning
psql -U postgres -c "UPDATE provisioning_classes SET label='Polycom SoundPoint IP 650/670 SIP', seq='4' WHERE label='Polycom SoundPoint IP 650 SIP'" provisioning
psql -U postgres -c "UPDATE provisioning_classes SET seq='7' WHERE label='Linksys Internet Phone Adapter PAP2T'" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 450 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 1'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 450 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 2'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 450 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 3'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 450 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 550/560 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 1'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 550/560 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 2'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 550/560 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 3'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 550/560 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 4'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom SoundPoint IP 550/560 SIP'), (SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom VVX 1500'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 1'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom VVX 1500'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 2'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom VVX 1500'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 3'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom VVX 1500'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 4'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom VVX 1500'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 5'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom VVX 1500'), (SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'))" provisioning
psql -U postgres -c "UPDATE param_groups_to_params SET value=null WHERE group_id=(SELECT group_id FROM provisioning_groups WHERE label='Standard Phone') AND param_id=(SELECT param_id FROM provisioning_params WHERE name='mailbox')" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Standard Phone'), (SELECT param_id FROM provisioning_params WHERE name='mailcallback'), null, true)" provisioning
psql -U postgres -c "INSERT INTO provisioning_params VALUES(default, 'mailcallback', 'text', 'Voice Mailbox Callback', 'Extension or URL for mailbox message retrieval', '', '208', '', null)" provisioning
#fi
# if current is older than 0.1.1 we update.
#if [ "$(apk version -t $old 0.1.1)" = "<" ]; then
psql -U postgres -c "INSERT INTO provisioning_groups VALUES(default, 'device', 'Snom Device', '1')" provisioning
psql -U postgres -c "INSERT INTO provisioning_groups VALUES(default, 'reg1', 'Registration 1 No Forwarding', '10')" provisioning
psql -U postgres -c "INSERT INTO provisioning_groups VALUES(default, 'reg2', 'Registration 2 No Forwarding', '10')" provisioning
psql -U postgres -c "INSERT INTO provisioning_groups VALUES(default, 'reg3', 'Registration 3 No Forwarding', '10')" provisioning
psql -U postgres -c "INSERT INTO provisioning_groups VALUES(default, 'reg4', 'Registration 4 No Forwarding', '10')" provisioning
psql -U postgres -c "INSERT INTO provisioning_groups VALUES(default, 'reg5', 'Registration 5 No Forwarding', '10')" provisioning
psql -U postgres -c "INSERT INTO provisioning_groups VALUES(default, 'reg6', 'Registration 6 No Forwarding', '10')" provisioning
psql -U postgres -c "INSERT INTO provisioning_groups VALUES(default, 'reg7', 'Registration 7 No Forwarding', '10')" provisioning
psql -U postgres -c "INSERT INTO provisioning_groups VALUES(default, 'reg8', 'Registration 8 No Forwarding', '10')" provisioning
psql -U postgres -c "INSERT INTO provisioning_groups VALUES(default, 'reg9', 'Registration 9 No Forwarding', '10')" provisioning
psql -U postgres -c "INSERT INTO provisioning_groups VALUES(default, 'reg10', 'Registration 10 No Forwarding', '11')" provisioning
psql -U postgres -c "INSERT INTO provisioning_groups VALUES(default, 'reg11', 'Registration 11 No Forwarding', '11')" provisioning
psql -U postgres -c "INSERT INTO provisioning_groups VALUES(default, 'reg12', 'Registration 12 No Forwarding', '11')" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='template'), '/etc/provisioning/templates/snom-template.lua', false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='mac'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='registrar'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='digitmap'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='digitmaptimeout'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='sntpserver'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='timezone'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='musiconhold'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='adminpassword'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='pcportenable'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='urldialingenable'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Snom Device'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 1 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 2 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 3 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 3 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 3 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 4 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 4 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 4 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 5 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 5 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 5 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 6 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 6 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 6 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 7 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 7 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 7 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 8 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 8 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 8 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 9 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 9 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 9 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 10 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 10 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 10 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 11 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 11 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 11 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 12 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 12 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration 12 No Forwarding'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='template'), 'Snom', '/etc/provisioning/templates/snom-template.lua', '3')" provisioning
psql -U postgres -c "INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='device'), 'Snom 300', '10')" provisioning
psql -U postgres -c "INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='device'), 'Snom 320/360/370', '11')" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 300'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 1 No Forwarding'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 300'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 2 No Forwarding'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 300'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 3 No Forwarding'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 300'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 4 No Forwarding'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 300'), (SELECT group_id FROM provisioning_groups WHERE label='Snom Device'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 1 No Forwarding'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 2 No Forwarding'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 3 No Forwarding'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 4 No Forwarding'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 5 No Forwarding'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 6 No Forwarding'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 7 No Forwarding'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 8 No Forwarding'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 9 No Forwarding'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 10 No Forwarding'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 11 No Forwarding'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 12 No Forwarding'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Snom 320/360/370'), (SELECT group_id FROM provisioning_groups WHERE label='Snom Device'))" provisioning
psql -U postgres -c "UPDATE provisioning_params SET value='UTC0' WHERE name='timezone' and value=''" provisioning
#fi
# if current is older than 0.1.2 we update.
#if [ "$(apk version -t $old 0.1.2)" = "<" ]; then
for a in $(seq 1 34); do
psql -U postgres -c "UPDATE provisioning_groups SET label='Registration $a (Polycom)' WHERE label='Registration $a'" provisioning
psql -U postgres -c "DELETE FROM param_groups_to_params WHERE group_id=(SELECT group_id FROM provisioning_groups WHERE label='Registration $a')" provisioning
psql -U postgres -c "DELETE FROM classes_to_param_groups WHERE group_id=(SELECT group_id FROM provisioning_groups WHERE label='Registration $a')" provisioning
psql -U postgres -c "DELETE FROM provisioning_groups WHERE label='Registration $a'" provisioning
done
for a in $(seq 1 12); do
psql -U postgres -c "UPDATE provisioning_groups SET label='Registration $a (Snom)' WHERE label='Registration $a No Forwarding'" provisioning
psql -U postgres -c "DELETE FROM param_groups_to_params WHERE group_id=(SELECT group_id FROM provisioning_groups WHERE label='Registration $a No Forwarding')" provisioning
psql -U postgres -c "DELETE FROM classes_to_param_groups WHERE group_id=(SELECT group_id FROM provisioning_groups WHERE label='Registration $a No Forwarding')" provisioning
psql -U postgres -c "DELETE FROM provisioning_groups WHERE label='Registration $a No Forwarding'" provisioning
done
psql -U postgres -c "UPDATE provisioning_groups SET label='Registration 1 (Unsupported)' WHERE label='Registration 1 Unsupported'" provisioning
psql -U postgres -c "DELETE FROM param_groups_to_params WHERE group_id=(SELECT group_id FROM provisioning_groups WHERE label='Registration 1 Unsupported')" provisioning
psql -U postgres -c "DELETE FROM classes_to_param_groups WHERE group_id=(SELECT group_id FROM provisioning_groups WHERE label='Registration 1 Unsupported')" provisioning
psql -U postgres -c "DELETE FROM provisioning_groups WHERE label='Registration 1 Unsupported'" provisioning
for a in $(seq 1 2); do
psql -U postgres -c "INSERT INTO provisioning_groups VALUES(default, 'reg$a', 'Registration $a (Linksys)', '10')" provisioning
psql -U postgres -c "UPDATE classes_to_param_groups SET group_id=(SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Linksys)') WHERE class_id=(SELECT class_id FROM provisioning_classes WHERE label='Linksys Internet Phone Adapter PAP2T') AND group_id=(SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Polycom)')" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Linksys)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)" provisioning
done
psql -U postgres -c "INSERT INTO provisioning_params VALUES(default, 'polycomringtone', 'select', 'Ring Tone (Polycom)', '', '2', '110', '', null)" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Silent Ring', '1', '1')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Low Trill', '2', '2')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Low Double Trill', '3', '3')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Medium Trill', '4', '4')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Medium Double Trill', '5', '5')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'High Trill', '6', '6')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'High Double Trill', '7', '7')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Highest Trill', '8', '8')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Highest Double Trill', '9', '9')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Beeble', '10', '10')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Triplet', '11', '11')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Ringback-style', '12', '12')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Low Trill Precedence', '13', '13')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), 'Ring Splash', '14', '14')" provisioning
for a in $(seq 1 34); do
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='polycomringtone'), null, true)" provisioning
done
#fi
psql -U postgres -c "INSERT INTO provisioning_params VALUES(default, 'databaseversion', 'text', 'Provisioning Database Version', 'Do not edit or delete!', '1', '999', '', null)" provisioning
psql -U postgres -c "UPDATE provisioning_params SET value='1' WHERE name='databaseversion'" provisioning
fi
if [ "$version" -lt "2" ]; then
echo "Upgrading to database version 2"
psql -U postgres -c "INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='device'), 'Cisco 2 Port Phone Adapter SPA112', '8')" provisioning
psql -U postgres -c "INSERT INTO provisioning_groups VALUES(default, 'device', 'Cisco ATA Device', '1')" provisioning
psql -U postgres -c "INSERT INTO provisioning_groups VALUES(default, 'reg1', 'Registration 1 (Cisco)', '10')" provisioning
psql -U postgres -c "INSERT INTO provisioning_groups VALUES(default, 'reg2', 'Registration 2 (Cisco)', '10')" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Cisco 2 Port Phone Adapter SPA112'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 1 (Cisco)'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Cisco 2 Port Phone Adapter SPA112'), (SELECT group_id FROM provisioning_groups WHERE label='Registration 2 (Cisco)'))" provisioning
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Cisco 2 Port Phone Adapter SPA112'), (SELECT group_id FROM provisioning_groups WHERE label='Cisco ATA Device'))" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Cisco ATA Device'), (SELECT param_id FROM provisioning_params WHERE name='template'), '/etc/provisioning/templates/ciscoata-template.lua', false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Cisco ATA Device'), (SELECT param_id FROM provisioning_params WHERE name='mac'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Cisco ATA Device'), (SELECT param_id FROM provisioning_params WHERE name='registrar'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Cisco ATA Device'), (SELECT param_id FROM provisioning_params WHERE name='digitmap'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Cisco ATA Device'), (SELECT param_id FROM provisioning_params WHERE name='sntpserver'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Cisco ATA Device'), (SELECT param_id FROM provisioning_params WHERE name='timezone'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Cisco ATA Device'), (SELECT param_id FROM provisioning_params WHERE name='musiconhold'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Cisco ATA Device'), (SELECT param_id FROM provisioning_params WHERE name='adminpassword'), null, false)" provisioning
for a in $(seq 1 2); do
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Cisco)'), (SELECT param_id FROM provisioning_params WHERE name='extension'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Cisco)'), (SELECT param_id FROM provisioning_params WHERE name='password'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Cisco)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswer'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Cisco)'), (SELECT param_id FROM provisioning_params WHERE name='forwardnoanswerenable'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Cisco)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusy'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Cisco)'), (SELECT param_id FROM provisioning_params WHERE name='forwardbusyenable'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Cisco)'), (SELECT param_id FROM provisioning_params WHERE name='forwardall'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Cisco)'), (SELECT param_id FROM provisioning_params WHERE name='forwardallenable'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Cisco)'), (SELECT param_id FROM provisioning_params WHERE name='callerid'), null, true)" provisioning
done
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='template'), 'Cisco ATA', '/etc/provisioning/templates/ciscoata-template.lua', '4')" provisioning
psql -U postgres -c "UPDATE provisioning_params SET value='2' WHERE name='databaseversion'" provisioning
fi
if [ "$version" -lt "3" ]; then
echo "Upgrading to database version 3"
psql -U postgres -c "INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='device'), 'Polycom VVX 300/310', '7')" provisioning
psql -U postgres -c "INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='device'), 'Polycom VVX 400/410', '8')" provisioning
psql -U postgres -c "INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='device'), 'Polycom VVX 500', '9')" provisioning
psql -U postgres -c "INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='device'), 'Polycom VVX 600', '10')" provisioning
for polycom_model in "300/310" "400/410" "500" "600"; do
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom VVX $polycom_model'), (SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'))" provisioning
for a in $(seq 1 34); do
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Polycom VVX $polycom_model'), (SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Polycom)'))" provisioning
done
done
psql -U postgres -c "UPDATE provisioning_classes SET seq='100' WHERE label='Linksys Internet Phone Adapter PAP2T'" provisioning
psql -U postgres -c "UPDATE provisioning_classes SET seq='200' WHERE label='Cisco 2 Port Phone Adapter SPA112'" provisioning
psql -U postgres -c "UPDATE provisioning_classes SET seq='300' WHERE label='Snom 300'" provisioning
psql -U postgres -c "UPDATE provisioning_classes SET seq='301' WHERE label='Snom 320/360/370'" provisioning
# provisioning_classes
psql -U postgres -c "UPDATE provisioning_classes SET label='Office Phone' WHERE label='Standard Phone'" provisioning
psql -U postgres -c "INSERT INTO provisioning_classes VALUES(default, (SELECT class_group_id FROM provisioning_class_groups WHERE name='services'), 'Residential Phone', '11')" provisioning
psql -U postgres -c "UPDATE provisioning_classes SET seq='21' WHERE label='Public Phone'" provisioning
psql -U postgres -c "UPDATE provisioning_classes SET seq='31' WHERE label='Hotline'" provisioning
# provisioning_groups
psql -U postgres -c "UPDATE provisioning_groups SET label='Office Phone' WHERE label='Standard Phone'" provisioning
psql -U postgres -c "INSERT INTO provisioning_groups VALUES(default, 'services', 'Residential Phone', '31')" provisioning
psql -U postgres -c "UPDATE provisioning_groups SET seq='41' WHERE label='Public Phone'" provisioning
psql -U postgres -c "UPDATE provisioning_groups SET seq='51' WHERE label='Hotline'" provisioning
# classes_to_param_groups
psql -U postgres -c "INSERT INTO classes_to_param_groups VALUES((SELECT class_id FROM provisioning_classes WHERE label='Residential Phone'), (SELECT group_id FROM provisioning_groups WHERE label='Residential Phone'))" provisioning
# provisioning_params
psql -U postgres -c "INSERT INTO provisioning_params VALUES(default, 'provpollingtime', 'select', 'Provisioning polling start time', 'The provisioning server is automatically polled for upgrades at random between the start time and one hour later', '02:00', '13', '', null)" provisioning
# provisioning_options
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '01:00', '01:00', '1')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '02:00', '02:00', '2')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '03:00', '03:00', '3')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '04:00', '04:00', '4')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '05:00', '05:00', '5')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '06:00', '06:00', '6')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '07:00', '07:00', '7')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '08:00', '08:00', '8')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '09:00', '09:00', '9')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '10:00', '10:00', '10')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '11:00', '11:00', '11')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '12:00', '12:00', '12')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '13:00', '13:00', '13')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '14:00', '14:00', '14')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '15:00', '15:00', '15')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '16:00', '16:00', '16')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '17:00', '17:00', '17')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '18:00', '18:00', '18')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '19:00', '19:00', '19')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '20:00', '20:00', '20')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '21:00', '21:00', '21')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '22:00', '22:00', '22')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '23:00', '23:00', '23')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '00:00', '00:00', '24')" provisioning
# param_groups_to_params
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Office Phone'), (SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '02:00', true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Public Phone'), (SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '02:00', true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Hotline'), (SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '02:00', true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Residential Phone'), (SELECT param_id FROM provisioning_params WHERE name='forwarding'), 'true', false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Residential Phone'), (SELECT param_id FROM provisioning_params WHERE name='hotlineenable'), 'false', false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Residential Phone'), (SELECT param_id FROM provisioning_params WHERE name='callhistoryenable'), 'true', false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Residential Phone'), (SELECT param_id FROM provisioning_params WHERE name='callwaitingenable'), 'true', false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Residential Phone'), (SELECT param_id FROM provisioning_params WHERE name='speeddialenable'), 'true', false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Residential Phone'), (SELECT param_id FROM provisioning_params WHERE name='mailbox'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Residential Phone'), (SELECT param_id FROM provisioning_params WHERE name='mailcallback'), null, true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Residential Phone'), (SELECT param_id FROM provisioning_params WHERE name='provpollingtime'), '10:00', true)" provisioning
# database
psql -U postgres -c "UPDATE provisioning_params SET value='3' WHERE name='databaseversion'" provisioning
fi
if [ "$version" -lt "4" ]; then
echo "Upgrading to database version 4"
# provisioning_params
psql -U postgres -c "INSERT INTO provisioning_params VALUES(default, 'militarytimeenable', 'boolean', '24-hour Clock Mode Enable', '', 'false', '14', '', null)" provisioning
psql -U postgres -c "INSERT INTO provisioning_params VALUES(default, 'displaylang', 'select', 'Display screen language', 'Check if your phone supports the selected language', '', '15', '', null)" provisioning
psql -U postgres -c "INSERT INTO provisioning_params VALUES(default, 'scaenable', 'boolean', 'Shared Call Appearance Enable', '', 'false', '120', '', null)" provisioning
psql -U postgres -c "INSERT INTO provisioning_params VALUES(default, 'dndenable', 'boolean', 'Do Not Disturb Enable', '', 'true', '220', '', null)" provisioning
for a in $(seq 1 9); do
psql -U postgres -c "INSERT INTO provisioning_params VALUES(default, 'softkey$a', 'boolean', 'Soft Key $a Enable', '', 'false', '30$a', '', null)" provisioning
done
psql -U postgres -c "INSERT INTO provisioning_params VALUES(default, 'softkey10', 'boolean', 'Soft Key 10 Enable', '', 'false', '310', '', null)" provisioning
# provisioning_options
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='displaylang'), 'English (United States)', 'English_United_States', '1')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='displaylang'), 'English (Canada)', 'English_Canada', '2')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='displaylang'), 'English (United Kingdom)', 'English_United_Kingdom', '3')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='displaylang'), 'Chinese (China)', 'Chinese_China', '4')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='displaylang'), 'Chinese (Taiwan)', 'Chinese_Taiwan', '5')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='displaylang'), 'Danish', 'Danish_Denmark', '6')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='displaylang'), 'Dutch', 'Dutch_Netherlands', '7')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='displaylang'), 'French', 'French_France', '8')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='displaylang'), 'German', 'German_Germany', '9')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='displaylang'), 'Italian', 'Italian_Italy', '10')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='displaylang'), 'Japanese', 'Japanese_Japan', '11')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='displaylang'), 'Korean', 'Korean_Korea', '12')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='displaylang'), 'Norwegian', 'Norwegian_Norway', '13')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='displaylang'), 'Polish', 'Polish_Poland', '14')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='displaylang'), 'Portuguese', 'Portuguese_Portugal', '15')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='displaylang'), 'Russian', 'Russian_Russia', '16')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='displaylang'), 'Slovenian', 'Slovenian_Slovenia', '17')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='displaylang'), 'Spanish', 'Spanish_Spain', '18')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='displaylang'), 'Swedish', 'Swedish_Sweden', '19')" provisioning
psql -U postgres -c "INSERT INTO provisioning_options VALUES((SELECT param_id FROM provisioning_params WHERE name='displaylang'), 'Internal (US English)', '', '20')" provisioning
# param_groups_to_params
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'), (SELECT param_id FROM provisioning_params WHERE name='militarytimeenable'), null, false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Polycom Device'), (SELECT param_id FROM provisioning_params WHERE name='displaylang'), '', false)" provisioning
for a in $(seq 1 34); do
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='callwaitingenable'), 'true', true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Registration $a (Polycom)'), (SELECT param_id FROM provisioning_params WHERE name='scaenable'), null, true)" provisioning
done
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Office Phone'), (SELECT param_id FROM provisioning_params WHERE name='dndenable'), 'true', true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Residential Phone'), (SELECT param_id FROM provisioning_params WHERE name='dndenable'), 'true', true)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Public Phone'), (SELECT param_id FROM provisioning_params WHERE name='dndenable'), 'false', false)" provisioning
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='Hotline'), (SELECT param_id FROM provisioning_params WHERE name='dndenable'), 'false', false)" provisioning
for group in "Office Phone" "Residential Phone" "Public Phone" "Hotline"; do
for a in $(seq 1 10); do
psql -U postgres -c "INSERT INTO param_groups_to_params VALUES((SELECT group_id FROM provisioning_groups WHERE label='$group'), (SELECT param_id FROM provisioning_params WHERE name='softkey$a'), 'false', false)" provisioning
done
done
# database
psql -U postgres -c "UPDATE provisioning_params SET value='4' WHERE name='databaseversion'" provisioning
fi
exit 0
|