-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtancredi-migration-helper
executable file
·61 lines (57 loc) · 2.67 KB
/
tancredi-migration-helper
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
#!/bin/bash
#
# Copyright (C) 2020 Nethesis S.r.l.
# http://www.nethesis.it - nethserver@nethesis.it
#
# This script is part of NethServer.
#
# NethServer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License,
# or any later version.
#
# NethServer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NethServer. If not, see COPYING.
#
function migrate {
LK=$(/sbin/e-smith/config getprop subscription SystemId)
SECRET=$(/usr/bin/sudo /sbin/e-smith/config getprop subscription Secret)
runuser -s /bin/bash -c "/usr/bin/scl enable rh-php73 -- php /usr/share/tancredi/scripts/migration.php $LK $SECRET" - apache
/usr/bin/scl enable rh-php73 -- /usr/sbin/fwconsole r
}
ENGINE=$(/sbin/e-smith/config getprop nethvoice ProvisioningEngine)
if [[ $1 == '-h' ]] ; then
echo "Usage: $0 [-h|-f|-d]"
echo "Import known devices in the Tancredi database, "
echo "then disable the TFTP service for FreePBX provisoning"
echo "With no option, the procedure runs once. Accepted options"
echo -e " -h\t This help"
echo -e " -f\t Drop the Tancredi DB and import known devices from FreePBX again"
echo -e " -d\t Restore TFTP configuration for FreePBX provisioning"
elif [[ $ENGINE != 'tancredi' ]] ; then
/sbin/e-smith/config setprop nethvoice ProvisioningEngine tancredi
migrate
/sbin/e-smith/signal-event nethserver-dnsmasq-save
echo "[NOTICE] Migration completed. The provisioning service is now Tancredi."
elif [[ $1 == '-f' ]] ; then
echo "[NOTICE] Discarding any existing data in Tancredi database"
find /var/lib/tancredi/data/{scopes,first_access_tokens,tokens} -type f -delete
/sbin/e-smith/signal-event nethserver-tancredi-update
migrate
/sbin/e-smith/signal-event nethserver-dnsmasq-save
echo "[NOTICE] Migration completed in force (-f) mode. The provisioning service is still Tancredi."
elif [[ $1 == '-d' ]] ; then
find /var/lib/tancredi/data/{scopes,first_access_tokens,tokens} -type f -delete
/sbin/e-smith/config setprop nethvoice ProvisioningEngine freepbx
/sbin/e-smith/signal-event nethserver-tancredi-update
/sbin/e-smith/signal-event nethserver-dnsmasq-save
echo "[NOTICE] The provisioning engine is now FreePBX End Point Manager."
else
echo "[NOTICE] Provisionong engine is already Tancredi. Nothing to do."
exit 0
fi