root/modules/branches/2.10/fw_fop/uninstall.php

Revision 14083, 2.0 kB (checked in by p_lindheimer, 1 year ago)

fixes #5818 stop fop if it is running and remove the amportal hook so subsequent start's don't start it

Line 
1 <?php
2 /*
3  * Mimic the amportal code that stops FOP server. If we don't do it here, then once
4  * uninstalled amportal will no longer stop FOP since it is invoked with a hook which
5  * will be gone.
6  *
7     if [ "$pid_length" != "0" -a "$pid_length" != "" ]
8     then
9          ps -ef | grep safe_opserver | grep -v grep | awk '{print $2}' | xargs kill
10         killall op_server.pl
11         echo "FOP Server Stopped"
12     fi
13  */
14 global $amp_conf;
15
16 $pidof = fpbx_which("pidof");
17 if ($pidof === false) {
18     $pidof = "/sbin/pidof";
19 }
20 $awk = fpbx_which("awk");
21 $ps = fpbx_which("ps");
22 $grep = fpbx_which("grep");
23 $xargs = fpbx_which("xargs");
24 $echo = fpbx_which("echo");
25 $kill = fpbx_which("kill");
26 $killall = fpbx_which("killall");
27
28 outn("Checking FOP servers status..");
29 $pid_length = trim(`$pidof -x op_server.pl | $awk '{print length($0)}'`);
30 if ($pid_length) {
31     out("running got $pid_length");
32     outn("Trying to stop safe_opserver..");
33     $kill_args = trim(`$ps -ef | $grep safe_opserver | $grep -v grep | $awk '{print $2}' | $xargs $echo`);
34     outn("processes $kill_args..");
35     exec("$kill $kill_args", $kill_arr, $ret);
36     if (!$ret) {
37         out("stopped");
38         outn("trying to stop op_server.pl..");
39         exec("$killall op_server.pl", $killall_arr, $ret);
40         if (!$ret) {
41             out("stopped");
42         } else {
43             out("failed");
44             out("you may need to reboot the server to stop the FOP services");
45         }
46     } else {
47         out("failed");
48         out("you may need to reboot the server to stop the FOP services");
49     }
50 } else {
51     out("not running");
52 }
53
54 // TODO: remove the symlink created by retrieve_conf. Probably need to look at
55 //       modifying module_admin so this is done automatically when a module is
56 //       uninstalled and probably even disabled.
57 //
58 //$hook = $amp_conf['ASTVARLIBDIR'] . "/freepbx_engine_hook_fw_fop";
59 $hook = $amp_conf['AMPBIN'] . "/freepbx_engine_hook_fw_fop";
60 if (is_link($hook) || is_file($hook)) {
61     outn("removing freepbx_engine_hook_fw_fop..");
62     if (unlink($hook)) {
63         out("removed");
64     } else {
65         out("failed to remove");
66         out("ERROR: The following symlink/file must be removed: $hook");
67     }
68 } else {
69     out("$hook is not there");
70 }
71
Note: See TracBrowser for help on using the browser.