1 |
jpp |
1.1 |
diff -Nur --no-dereference smeserver-freepbx-13.old/createlinks smeserver-freepbx-13/createlinks |
2 |
|
|
--- smeserver-freepbx-13.old/createlinks 2022-03-24 23:13:37.415000000 -0400 |
3 |
jpp |
1.2 |
+++ smeserver-freepbx-13/createlinks 2022-03-25 00:46:35.252000000 -0400 |
4 |
jpp |
1.1 |
@@ -4,23 +4,23 @@ |
5 |
|
|
|
6 |
|
|
# Start and stop links |
7 |
|
|
|
8 |
|
|
-service_link_enhanced("freepbx", "S98", "7"); |
9 |
|
|
-service_link_enhanced("freepbx", "K10", "6"); |
10 |
|
|
-service_link_enhanced("freepbx", "K10", "0"); |
11 |
|
|
-service_link_enhanced("freepbx", "K10", "1"); |
12 |
|
|
- |
13 |
|
|
-service_link_enhanced("httpd-fpbx", "S86", "7"); |
14 |
|
|
-service_link_enhanced("httpd-fpbx", "K15", "6"); |
15 |
|
|
-service_link_enhanced("httpd-fpbx", "K15", "0"); |
16 |
|
|
-service_link_enhanced("httpd-fpbx", "K15", "1"); |
17 |
|
|
- |
18 |
|
|
-service_link_enhanced("dahdi", "S09", "7"); |
19 |
|
|
-service_link_enhanced("dahdi", "K16", "6"); |
20 |
|
|
-service_link_enhanced("dahdi", "K16", "0"); |
21 |
|
|
-service_link_enhanced("dahdi", "K16", "1"); |
22 |
|
|
+#service_link_enhanced("freepbx", "S98", "7"); |
23 |
|
|
+#service_link_enhanced("freepbx", "K10", "6"); |
24 |
|
|
+#service_link_enhanced("freepbx", "K10", "0"); |
25 |
|
|
+#service_link_enhanced("freepbx", "K10", "1"); |
26 |
|
|
+ |
27 |
|
|
+#service_link_enhanced("httpd-fpbx", "S86", "7"); |
28 |
|
|
+#service_link_enhanced("httpd-fpbx", "K15", "6"); |
29 |
|
|
+#service_link_enhanced("httpd-fpbx", "K15", "0"); |
30 |
|
|
+#service_link_enhanced("httpd-fpbx", "K15", "1"); |
31 |
|
|
+ |
32 |
|
|
+#service_link_enhanced("dahdi", "S09", "7"); |
33 |
|
|
+#service_link_enhanced("dahdi", "K16", "6"); |
34 |
|
|
+#service_link_enhanced("dahdi", "K16", "0"); |
35 |
|
|
+#service_link_enhanced("dahdi", "K16", "1"); |
36 |
|
|
|
37 |
|
|
-safe_symlink("../daemontools" , 'root/etc/rc.d/init.d/supervise/httpd-fpbx'); |
38 |
|
|
-safe_symlink("/var/service/httpd-fpbx" , 'root/service/httpd-fpbx'); |
39 |
|
|
+#safe_symlink("../daemontools" , 'root/etc/rc.d/init.d/supervise/httpd-fpbx'); |
40 |
|
|
+#safe_symlink("/var/service/httpd-fpbx" , 'root/service/httpd-fpbx'); |
41 |
|
|
|
42 |
|
|
# Panel links |
43 |
|
|
|
44 |
jpp |
1.2 |
@@ -37,6 +37,8 @@ |
45 |
|
|
templates2events("/etc/httpd/conf/httpd.conf", $event); |
46 |
|
|
templates2events("/etc/httpd/fpbx-conf/httpd.conf", qw(freepbx-update bootstrap-console-save conf-userpanel)); |
47 |
|
|
templates2events("/etc/e-smith/sql/init/30freepbx_mysql_create_database", qw(freepbx-update bootstrap-console-save)); |
48 |
|
|
+templates2events("/etc/opt/remi/php74/php-fpm.d/www.conf", $event); |
49 |
|
|
+ |
50 |
|
|
|
51 |
|
|
event_link("freepbx-checkinstall", $event, "10"); |
52 |
|
|
event_link("freepbx-checkinstall-backup", $event, "11"); |
53 |
|
|
@@ -48,17 +50,43 @@ |
54 |
jpp |
1.1 |
safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/mysql.init"); |
55 |
|
|
safe_symlink("sigusr1", "root/etc/e-smith/events/$event/services2adjust/httpd-e-smith"); |
56 |
|
|
safe_symlink("sigusr1", "root/etc/e-smith/events/$event/services2adjust/httpd-fpbx"); |
57 |
|
|
+safe_symlink("reload-or-restart", "root/etc/e-smith/events/$event/services2adjust/php74-php-fpm"); |
58 |
|
|
+ |
59 |
|
|
safe_symlink("sigusr1", "root/etc/e-smith/events/logrotate/services2adjust/httpd-fpbx"); |
60 |
|
|
|
61 |
|
|
safe_symlink("sigusr1", "root/etc/e-smith/events/conf-userpanel/services2adjust/httpd-fpbx"); |
62 |
|
|
|
63 |
|
|
# Create empty files |
64 |
|
|
-safe_touch("root/etc/e-smith/events/logrotate/logfiles2timestamp/var/log/httpd/fpbx_access_log"); |
65 |
|
|
-safe_touch("root/etc/e-smith/events/logrotate/logfiles2timestamp/var/log/httpd/fpbx_error_log"); |
66 |
|
|
-safe_touch("root/var/service/httpd-fpbx/down"); |
67 |
|
|
+#safe_touch("root/etc/e-smith/events/logrotate/logfiles2timestamp/var/log/httpd/fpbx_access_log"); |
68 |
|
|
+#safe_touch("root/etc/e-smith/events/logrotate/logfiles2timestamp/var/log/httpd/fpbx_error_log"); |
69 |
|
|
+#safe_touch("root/var/service/httpd-fpbx/down"); |
70 |
|
|
|
71 |
|
|
# Create empty directories |
72 |
|
|
system("/bin/mkdir -p root/var/service/httpd-fpbx/supervise"); |
73 |
|
|
system("/bin/mkdir -p root/var/service/httpd-fpbx/log/supervise"); |
74 |
|
|
system("/bin/mkdir -p root/var/log/httpd-fpbx"); |
75 |
|
|
|
76 |
|
|
+ |
77 |
|
|
+## systemd install/update |
78 |
|
|
+my $event = 'smeserver-freepbx-update'; |
79 |
|
|
+templates2events("/etc/asterisk/asterisk.conf", $event); |
80 |
|
|
+templates2events("/etc/asterisk/cdr_mysql.conf", $event); |
81 |
|
|
+templates2events("/etc/asterisk/manager.conf", $event); |
82 |
|
|
+templates2events("/etc/logrotate.d/asterisk", $event); |
83 |
|
|
+templates2events("/etc/httpd/conf/httpd.conf", $event); |
84 |
|
|
+templates2events("/etc/httpd/fpbx-conf/httpd.conf", $event); |
85 |
|
|
+templates2events("/etc/e-smith/sql/init/30freepbx_mysql_create_database", $event); |
86 |
jpp |
1.2 |
+templates2events("/etc/opt/remi/php74/php-fpm.d/www.conf", $event); |
87 |
jpp |
1.1 |
+event_link("freepbx-checkinstall", $event, "10"); |
88 |
|
|
+event_link("freepbx-checkinstall-backup", $event, "11"); |
89 |
|
|
+event_link("freepbx-amportal.conf", $event, "91"); |
90 |
|
|
+event_link("freepbx-clean-crontab", $event, "40"); |
91 |
|
|
+ |
92 |
|
|
+safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/mysql.init"); |
93 |
|
|
+safe_symlink("sigusr1", "root/etc/e-smith/events/$event/services2adjust/httpd-e-smith"); |
94 |
|
|
+safe_symlink("sigusr1", "root/etc/e-smith/events/$event/services2adjust/httpd-fpbx"); |
95 |
|
|
+safe_symlink("reload-or-restart", "root/etc/e-smith/events/$event/services2adjust/php74-php-fpm"); |
96 |
|
|
+#action needed in case we have a systemd unit |
97 |
|
|
+event_link("systemd-default", $event, "88"); |
98 |
|
|
+event_link("systemd-reload", $event, "89"); |
99 |
|
|
+ |
100 |
|
|
diff -Nur --no-dereference smeserver-freepbx-13.old/root/etc/e-smith/events/actions/freepbx-checkinstall smeserver-freepbx-13/root/etc/e-smith/events/actions/freepbx-checkinstall |
101 |
|
|
--- smeserver-freepbx-13.old/root/etc/e-smith/events/actions/freepbx-checkinstall 2022-03-24 23:13:37.431000000 -0400 |
102 |
|
|
+++ smeserver-freepbx-13/root/etc/e-smith/events/actions/freepbx-checkinstall 2022-03-25 00:44:34.355000000 -0400 |
103 |
|
|
@@ -44,7 +44,11 @@ |
104 |
|
|
./start_asterisk start >> /root/freepbx_install.log 2>&1 |
105 |
|
|
echo "" >> /root/freepbx_install.log |
106 |
|
|
echo "Installing FreePBX..." >> /root/freepbx_install.log |
107 |
|
|
- echo "a" | ./install --webroot="/opt/freepbx" --dbengine="mysql" --dbname="freepbxdb" --dbuser="freepbxuser" --dbpass="$DBPASS" -n >> /root/freepbx_install.log 2>&1 |
108 |
|
|
+ echo "a" | /usr/bin/php74 ./install --webroot="/opt/freepbx" \ |
109 |
|
|
+ --dbengine="mysql" --dbname="freepbxdb" --dbuser="freepbxuser" --dbpass="$DBPASS" -n \ |
110 |
|
|
+ --cdrdbname="$CDRDBNAME" --astmoddir=/usr/lib64/asterisk/modules/ \ |
111 |
|
|
+ --astagidir=/usr/share/asterisk/agi-bin/ --ampsbin=/usr/local/bin --ampcgibin=/opt/freepbx/cgi-bin \ |
112 |
|
|
+ >> /root/freepbx_install.log 2>&1 |
113 |
|
|
else |
114 |
|
|
echo "error: /usr/share/freepbx/sources/freepbx/ doesn't exists" |
115 |
|
|
exit 1 |
116 |
|
|
diff -Nur --no-dereference smeserver-freepbx-13.old/root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/20Modules smeserver-freepbx-13/root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/20Modules |
117 |
|
|
--- smeserver-freepbx-13.old/root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/20Modules 2016-06-13 08:03:08.000000000 -0400 |
118 |
|
|
+++ smeserver-freepbx-13/root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/20Modules 2022-03-24 23:58:31.900000000 -0400 |
119 |
|
|
@@ -50,25 +50,7 @@ |
120 |
|
|
$OUT .= "LoadModule ${_}_module modules/mod_${_}.so\n"; |
121 |
|
|
} |
122 |
|
|
|
123 |
|
|
-if (exists $php{status} and $php{status} eq "enabled"){ |
124 |
|
|
- my $modphp = '4'; |
125 |
|
|
- if ( -r "/usr/lib/httpd/modules/libphp5.so" || -r "/usr/lib64/httpd/modules/libphp5.so" ){ |
126 |
|
|
- $modphp = '5'; |
127 |
|
|
- } |
128 |
|
|
- $OUT .= "LoadModule php".$modphp."_module modules/libphp".$modphp.".so\n"; |
129 |
|
|
-} |
130 |
|
|
- |
131 |
|
|
-$OUT .= <<HERE; |
132 |
|
|
- |
133 |
|
|
-<IfModule mod_php4.c> |
134 |
|
|
- AddIcon /icons/php4.gif .php3 .php4 .php .phtml |
135 |
|
|
- AddIcon /icons/phps.gif .phps |
136 |
|
|
-</IfModule> |
137 |
|
|
- |
138 |
|
|
-<IfModule mod_php5.c> |
139 |
|
|
- AddIcon /icons/php5.gif .php3 .php4 .php5 .php .phtml |
140 |
|
|
- AddIcon /icons/phps.gif .phps |
141 |
|
|
-</IfModule> |
142 |
|
|
+# we do not use php module anymore, but php-fpm |
143 |
|
|
|
144 |
|
|
PidFile /var/run/httpd-fpbx.pid |
145 |
|
|
UseCanonicalName off |
146 |
|
|
diff -Nur --no-dereference smeserver-freepbx-13.old/root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/90FreePBX20Root smeserver-freepbx-13/root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/90FreePBX20Root |
147 |
|
|
--- smeserver-freepbx-13.old/root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/90FreePBX20Root 2016-06-13 08:03:08.000000000 -0400 |
148 |
|
|
+++ smeserver-freepbx-13/root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/90FreePBX20Root 2022-03-25 00:01:25.372000000 -0400 |
149 |
|
|
@@ -2,10 +2,19 @@ |
150 |
|
|
<Directory /opt/freepbx/> |
151 |
|
|
AddType application/x-httpd-php .php |
152 |
|
|
Options +followSymlinks |
153 |
|
|
+ |
154 |
|
|
+{ |
155 |
|
|
+ my $key = "freepbx"; |
156 |
|
|
+ my $pool_name = lc $key; |
157 |
|
|
+ my $version = 74; |
158 |
|
|
+ $OUT .=" |
159 |
|
|
+ <FilesMatch .php\$> |
160 |
|
|
+ SetHandler \"proxy:unix:/var/run/php-fpm/php${version}-${pool_name}.sock|fcgi://localhost\" |
161 |
|
|
+ </FilesMatch>\n"; |
162 |
|
|
+} |
163 |
|
|
AllowOverride All |
164 |
|
|
order deny,allow |
165 |
|
|
deny from all |
166 |
|
|
allow from 127.0.0.1 |
167 |
|
|
- php_admin_value session.save_path /var/lib/php/fpbx-session |
168 |
|
|
</Directory> |
169 |
|
|
|
170 |
|
|
diff -Nur --no-dereference smeserver-freepbx-13.old/root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/90FreePBX30Admin smeserver-freepbx-13/root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/90FreePBX30Admin |
171 |
|
|
--- smeserver-freepbx-13.old/root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/90FreePBX30Admin 2022-03-24 23:13:37.426000000 -0400 |
172 |
|
|
+++ smeserver-freepbx-13/root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/90FreePBX30Admin 2022-03-25 00:04:30.523000000 -0400 |
173 |
|
|
@@ -1,12 +1,6 @@ |
174 |
|
|
|
175 |
|
|
<Directory /opt/freepbx/admin/> |
176 |
|
|
Options +followSymlinks |
177 |
|
|
- php_admin_flag allow_url_fopen On |
178 |
|
|
- php_admin_value memory_limit 256M |
179 |
|
|
- php_admin_value upload_max_filesize 100M |
180 |
|
|
- php_admin_value post_max_size 100M |
181 |
|
|
- php_admin_flag file_upload On |
182 |
|
|
- php_admin_flag magic_quotes_gpc Off |
183 |
|
|
</Directory> |
184 |
|
|
|
185 |
|
|
<Directory /opt/freepbx/admin/modules/> |
186 |
|
|
diff -Nur --no-dereference smeserver-freepbx-13.old/root/etc/e-smith/templates/etc/logrotate.d/asterisk/All smeserver-freepbx-13/root/etc/e-smith/templates/etc/logrotate.d/asterisk/All |
187 |
|
|
--- smeserver-freepbx-13.old/root/etc/e-smith/templates/etc/logrotate.d/asterisk/All 2016-06-13 08:03:08.000000000 -0400 |
188 |
|
|
+++ smeserver-freepbx-13/root/etc/e-smith/templates/etc/logrotate.d/asterisk/All 2022-03-25 00:20:25.749000000 -0400 |
189 |
|
|
@@ -1,9 +1,26 @@ |
190 |
|
|
-/var/log/asterisk/messages /var/log/asterisk/freepbx.log /var/log/asterisk/event_log /var/log/asterisk/queue_log /var/log/asterisk/full /var/log/asterisk/warnings /var/log/asterisk/misdn.log \{ |
191 |
|
|
+/var/log/asterisk/messages |
192 |
|
|
+/var/log/asterisk/event_log |
193 |
|
|
+/var/log/asterisk/queue_log |
194 |
|
|
+/var/log/asterisk/full |
195 |
|
|
+/var/log/asterisk/security |
196 |
|
|
+/var/log/asterisk/freepbx.log |
197 |
|
|
+/var/log/asterisk/freepbx_security.log |
198 |
|
|
+/var/log/asterisk/ucp_err.log |
199 |
|
|
+/var/log/asterisk/ucp_out.log |
200 |
|
|
+/var/log/asterisk/cdr-csv/Master.csv |
201 |
|
|
+/var/log/asterisk/warnings |
202 |
|
|
+/var/log/asterisk/misdn.log |
203 |
|
|
+\{ |
204 |
|
|
missingok |
205 |
|
|
notifempty |
206 |
|
|
compress |
207 |
|
|
+ compressoptions -T0 |
208 |
|
|
+ compresscmd /usr/bin/xz |
209 |
|
|
+ compressext .xz |
210 |
|
|
+ uncompresscmd /usr/bin/unxz |
211 |
|
|
daily |
212 |
|
|
- rotate 60 |
213 |
|
|
+ rotate 365 |
214 |
|
|
+ su asterisk asterisk |
215 |
|
|
create 0640 asterisk asterisk |
216 |
|
|
sharedscripts |
217 |
|
|
postrotate |
218 |
|
|
diff -Nur --no-dereference smeserver-freepbx-13.old/root/etc/e-smith/templates/etc/php-fpm.d/www.conf/16freepbx smeserver-freepbx-13/root/etc/e-smith/templates/etc/php-fpm.d/www.conf/16freepbx |
219 |
|
|
--- smeserver-freepbx-13.old/root/etc/e-smith/templates/etc/php-fpm.d/www.conf/16freepbx 1969-12-31 19:00:00.000000000 -0500 |
220 |
|
|
+++ smeserver-freepbx-13/root/etc/e-smith/templates/etc/php-fpm.d/www.conf/16freepbx 2022-03-25 00:05:11.932000000 -0400 |
221 |
|
|
@@ -0,0 +1,69 @@ |
222 |
|
|
+{ |
223 |
|
|
+ |
224 |
|
|
+if ($PHP_VERSION eq '74'){ |
225 |
|
|
+ if (($freepbx{'status'} || 'disabled') eq 'enabled'){ |
226 |
|
|
+ my $max_upload_size = ($freepbx{MaxUploadSize} || '100M'); |
227 |
|
|
+ $max_upload_size .= 'M' if ($max_upload_size =~ m/^\d+$/); |
228 |
|
|
+ my $memory_limit = ($freepbx{MemoryLimit} || '512M'); |
229 |
|
|
+ $memory_limit .= 'M' if ($memory_limit =~ m/^\d+$/); |
230 |
|
|
+ my $open_basedir= $freepbx{PHPBaseDir} || ''; |
231 |
|
|
+ $open_basedir = "/usr/share/freepbx:/var/lib/freepbx:/var/log/freepbx.log:/var/lib/php/freepbx:/home/e-smith/files/freepbx:/dev/urandom:/proc/meminfo:$open_basedir"; |
232 |
|
|
+ my $id = 'freepbx'; |
233 |
|
|
+ my $max_children = $freepbx{'PHPmaxChildren'} || 15; |
234 |
|
|
+ my $min_spare_servers = $freepbx{'PHPminServers'} || 3; |
235 |
|
|
+ my $start_servers = $freepbx{'PHPstartServers'} || 3; |
236 |
|
|
+ my $max_spare_servers = $freepbx{'PHPmaxServers'} || 6; |
237 |
|
|
+ my $max_requests = $freepbx{'PHPmaxRequests'} || 5000; |
238 |
|
|
+ $min_spare_servers = ( $min_spare_servers > $max_spare_servers ) ? printf("%.0f",$max_spare_servers/2) : $min_spare_servers; |
239 |
|
|
+ $start_servers = ( $start_servers > $max_spare_servers ) ? printf("%.0f", $max_spare_servers /2 + $min_spare_servers/2 ) : $start_servers; |
240 |
|
|
+ |
241 |
|
|
+ |
242 |
|
|
+ $OUT .=<<_EOF; |
243 |
|
|
+ |
244 |
|
|
+[freepbx] |
245 |
|
|
+ |
246 |
|
|
+listen.owner = root |
247 |
|
|
+listen.group = www |
248 |
|
|
+listen.mode = 0660 |
249 |
|
|
+listen = /var/run/php-fpm/php$PHP_VERSION-$id.sock |
250 |
|
|
+user = asterisk |
251 |
|
|
+group = asterisk |
252 |
|
|
+catch_workers_output = yes |
253 |
|
|
+ |
254 |
|
|
+pm = dynamic |
255 |
|
|
+pm.max_children = $max_children |
256 |
|
|
+pm.start_servers = $start_servers |
257 |
|
|
+pm.min_spare_servers = $min_spare_servers |
258 |
|
|
+pm.max_spare_servers = $max_spare_servers |
259 |
|
|
+pm.max_requests = $max_requests |
260 |
|
|
+request_terminate_timeout = 60m |
261 |
|
|
+ |
262 |
|
|
+php_flag[display_errors] = off |
263 |
|
|
+php_admin_flag[log_errors] = on |
264 |
|
|
+php_admin_value[error_log] = syslog |
265 |
|
|
+php_admin_value[memory_limit] = $memory_limit |
266 |
|
|
+php_admin_value[session.save_path] = /var/lib/php/$id/sessions |
267 |
|
|
+php_admin_value[upload_tmp_dir] = /var/lib/php/$id/tmp |
268 |
|
|
+php_admin_value[sys_temp_dir] = /var/lib/php/$id/tmp |
269 |
|
|
+php_admin_value[post_max_size] = $max_upload_size |
270 |
|
|
+php_admin_value[upload_max_filesize] = $max_upload_size |
271 |
|
|
+php_admin_value[max_execution_time] = 900 |
272 |
|
|
+php_admin_value[max_input_time] = 900 |
273 |
|
|
+php_admin_flag[allow_url_include] = off |
274 |
|
|
+php_admin_flag[allow_url_fopen] = on |
275 |
|
|
+php_admin_flag[file_uploads] = on |
276 |
|
|
+php_admin_flag[session.cookie_httponly] = on |
277 |
|
|
+ |
278 |
|
|
+; Needed so that the #!/usr/bin/env php shebang will point to the correct PHP version |
279 |
|
|
+env[PATH] = /opt/remi/php{{ fpbx_php_version }}/root/usr/bin:/opt/remi/php{{ fpbx_php_version }}/root/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin |
280 |
|
|
+;env[http_proxy] = {{ system_proxy }} |
281 |
|
|
+;env[https_proxy] = {{ system_proxy }} |
282 |
|
|
+;env[no_proxy] = |
283 |
|
|
+_EOF |
284 |
|
|
+ |
285 |
|
|
+ } |
286 |
|
|
+ else{ |
287 |
|
|
+ $OUT .= '; Nextcloud is disabled'; |
288 |
|
|
+ } |
289 |
|
|
+} |
290 |
|
|
+} |
291 |
|
|
diff -Nur --no-dereference smeserver-freepbx-13.old/root/etc/rc.d/init.d/freepbx smeserver-freepbx-13/root/etc/rc.d/init.d/freepbx |
292 |
|
|
--- smeserver-freepbx-13.old/root/etc/rc.d/init.d/freepbx 2008-08-05 17:07:12.000000000 -0400 |
293 |
|
|
+++ smeserver-freepbx-13/root/etc/rc.d/init.d/freepbx 1969-12-31 19:00:00.000000000 -0500 |
294 |
|
|
@@ -1,85 +0,0 @@ |
295 |
|
|
-#! /bin/sh |
296 |
|
|
-# chkconfig: 98 10 |
297 |
|
|
- |
298 |
|
|
-if [ -f /etc/init.d/functions ] ; then |
299 |
|
|
- . /etc/init.d/functions |
300 |
|
|
-elif [ -f /etc/rc.d/init.d/functions ] ; then |
301 |
|
|
- . /etc/rc.d/init.d/functions |
302 |
|
|
-else |
303 |
|
|
- exit 0 |
304 |
|
|
-fi |
305 |
|
|
- |
306 |
|
|
- |
307 |
|
|
- |
308 |
|
|
- |
309 |
|
|
-# make sure config file exists |
310 |
|
|
-if [ ! -e "/etc/amportal.conf" ]; then |
311 |
|
|
- echo "" |
312 |
|
|
- echo "/etc/amportal.conf does not exist!" |
313 |
|
|
- echo "Have you installed the AMP configuration?" |
314 |
|
|
- exit 1 |
315 |
|
|
-fi |
316 |
|
|
-. /etc/amportal.conf |
317 |
|
|
- |
318 |
|
|
-if [ -x ${AMPBIN}/freepbx_engine ]; then |
319 |
|
|
- FPBXENGINE=${AMPBIN}/freepbx_engine |
320 |
|
|
-elif [ -x ${ASTVARLIBDIR}/bin/freepbx_engine ]; then |
321 |
|
|
- FPBXENGINE=${ASTVARLIBDIR}/bin/freepbx_engine |
322 |
|
|
-elif [ -x /var/lib/asterisk/bin/freepbx_engine ]; then |
323 |
|
|
- FPBXENGINE=/var/lib/asterisk/bin/freepbx_engine |
324 |
|
|
-else |
325 |
|
|
- echo "FATAL: can not find freepbx_engine to start Asterisk" |
326 |
|
|
- exit 1 |
327 |
|
|
-fi |
328 |
|
|
- |
329 |
|
|
-FPBXSTATUS=$(/sbin/e-smith/db configuration getprop freepbx status) |
330 |
|
|
- |
331 |
|
|
-case "$1" in |
332 |
|
|
- start) |
333 |
|
|
- $FPBXENGINE start > /dev/null 2>&1 |
334 |
|
|
- echo -n "Starting FreePBX: " |
335 |
|
|
- RETVAL=$? |
336 |
|
|
- ;; |
337 |
|
|
- stop) |
338 |
|
|
- $FPBXENGINE stop > /dev/null 2>&1 |
339 |
|
|
- echo -n "Stoping FreePBX: " |
340 |
|
|
- RETVAL=$? |
341 |
|
|
- ;; |
342 |
|
|
- restart) |
343 |
|
|
- $FPBXENGINE restart > /dev/null 2>&1 |
344 |
|
|
- echo -n "Restarting FreePBX: " |
345 |
|
|
- RETVAL=$? |
346 |
|
|
- ;; |
347 |
|
|
- reload) |
348 |
|
|
- /usr/sbin/asterisk -rx 'reload' > /dev/null 2>&1 |
349 |
|
|
- echo -n "Reloading FreePBX: " |
350 |
|
|
- RETVAL=$? |
351 |
|
|
- ;; |
352 |
|
|
- kill) |
353 |
|
|
- $FPBXENGINE kill > /dev/null 2>&1 |
354 |
|
|
- echo -n "Killing FreePBX: " |
355 |
|
|
- RETVAL=$? |
356 |
|
|
- ;; |
357 |
|
|
- adjust) |
358 |
|
|
- if [ $FPBXSTATUS == 'enabled' ]; then |
359 |
|
|
- $FPBXENGINE restart > /dev/null 2>&1 |
360 |
|
|
- else |
361 |
|
|
- $FPBXENGINE stop > /dev/null 2>&1 |
362 |
|
|
- fi |
363 |
|
|
- echo -n "Adjusting FreePBX: " |
364 |
|
|
- RETVAL=$? |
365 |
|
|
- ;; |
366 |
|
|
- *) |
367 |
|
|
- echo "Usage: $0 {start|stop|restart|reload|adjust|kill}" |
368 |
|
|
- exit 1 |
369 |
|
|
-esac |
370 |
|
|
- |
371 |
|
|
-if [ $RETVAL -eq 0 ]; then |
372 |
|
|
- echo_success |
373 |
|
|
-else |
374 |
|
|
- echo_failure |
375 |
|
|
-fi |
376 |
|
|
-echo |
377 |
|
|
- |
378 |
|
|
-exit $RETVAL |
379 |
|
|
- |
380 |
|
|
diff -Nur --no-dereference smeserver-freepbx-13.old/root/usr/lib/systemd/system/asterisk.conf.d/50-koozali.conf smeserver-freepbx-13/root/usr/lib/systemd/system/asterisk.conf.d/50-koozali.conf |
381 |
|
|
--- smeserver-freepbx-13.old/root/usr/lib/systemd/system/asterisk.conf.d/50-koozali.conf 1969-12-31 19:00:00.000000000 -0500 |
382 |
|
|
+++ smeserver-freepbx-13/root/usr/lib/systemd/system/asterisk.conf.d/50-koozali.conf 2022-03-24 23:34:56.871000000 -0400 |
383 |
|
|
@@ -0,0 +1,4 @@ |
384 |
|
|
+[Service] |
385 |
|
|
+# we do not want asterisk to run as a service, freepbx will handle it |
386 |
|
|
+ExecStart= |
387 |
|
|
+ExecStart=/dev/null |
388 |
|
|
diff -Nur --no-dereference smeserver-freepbx-13.old/root/usr/lib/systemd/system/freepbx.service smeserver-freepbx-13/root/usr/lib/systemd/system/freepbx.service |
389 |
|
|
--- smeserver-freepbx-13.old/root/usr/lib/systemd/system/freepbx.service 1969-12-31 19:00:00.000000000 -0500 |
390 |
|
|
+++ smeserver-freepbx-13/root/usr/lib/systemd/system/freepbx.service 2022-03-24 23:17:16.044000000 -0400 |
391 |
|
|
@@ -0,0 +1,19 @@ |
392 |
|
|
+[Unit] |
393 |
|
|
+Description=FreePBX VoIP Server |
394 |
|
|
+Requires=mariadb.service |
395 |
|
|
+ |
396 |
|
|
+[Service] |
397 |
|
|
+Type=forking |
398 |
|
|
+ |
399 |
|
|
+ExecStartPre=/sbin/e-smith/service-status freepbx |
400 |
|
|
+ |
401 |
|
|
+ExecStart=/usr/local/bin/fwconsole start -q |
402 |
|
|
+ExecStop=/usr/local/bin/fwconsole stop -q |
403 |
|
|
+ExecReload=/usr/local/bin/fwconsole reload -q |
404 |
|
|
+SyslogIdentifier=FreePBX |
405 |
|
|
+Restart=on-failure |
406 |
|
|
+StartLimitInterval=0 |
407 |
|
|
+RestartSec=30 |
408 |
|
|
+ |
409 |
|
|
+[Install] |
410 |
|
|
+WantedBy=multi-user.target sme-server.target |
411 |
|
|
diff -Nur --no-dereference smeserver-freepbx-13.old/root/usr/lib/systemd/system/httpd-fpbx.service smeserver-freepbx-13/root/usr/lib/systemd/system/httpd-fpbx.service |
412 |
|
|
--- smeserver-freepbx-13.old/root/usr/lib/systemd/system/httpd-fpbx.service 1969-12-31 19:00:00.000000000 -0500 |
413 |
|
|
+++ smeserver-freepbx-13/root/usr/lib/systemd/system/httpd-fpbx.service 2022-03-24 23:40:24.092000000 -0400 |
414 |
|
|
@@ -0,0 +1,21 @@ |
415 |
|
|
+[Unit] |
416 |
|
|
+Description=The Koozali SME Server FreePBX web service |
417 |
|
|
+After=network.service remote-fs.target |
418 |
|
|
+Documentation=man:httpd(8) |
419 |
|
|
+Documentation=man:apachectl(8) |
420 |
|
|
+ |
421 |
|
|
+[Service] |
422 |
|
|
+Type=notify |
423 |
|
|
+EnvironmentFile=/etc/sysconfig/httpd |
424 |
|
|
+ExecStartPre=/sbin/e-smith/service-status httpd-fpbx |
425 |
|
|
+ExecStartPre=/sbin/e-smith/expand-template /etc/httpd/fpbx-conf/httpd.conf |
426 |
|
|
+ExecStart=/usr/sbin/httpd -f /etc/httpd/fpbx-conf/httpd.conf -DFOREGROUND |
427 |
|
|
+ExecReload=/usr/sbin/httpd -f /etc/httpd/fpbx-conf/httpd.conf -k graceful |
428 |
|
|
+ExecStop=/bin/kill -WINCH ${MAINPID} |
429 |
|
|
+KillSignal=SIGCONT |
430 |
|
|
+PrivateTmp=true |
431 |
|
|
+ |
432 |
|
|
+ |
433 |
|
|
+[Install] |
434 |
|
|
+WantedBy=sme-server.target |
435 |
|
|
+ |
436 |
|
|
diff -Nur --no-dereference smeserver-freepbx-13.old/root/usr/local/bin/safe_asterisk smeserver-freepbx-13/root/usr/local/bin/safe_asterisk |
437 |
|
|
--- smeserver-freepbx-13.old/root/usr/local/bin/safe_asterisk 1969-12-31 19:00:00.000000000 -0500 |
438 |
|
|
+++ smeserver-freepbx-13/root/usr/local/bin/safe_asterisk 2022-03-24 23:26:33.185000000 -0400 |
439 |
|
|
@@ -0,0 +1,228 @@ |
440 |
|
|
+#!/bin/sh |
441 |
|
|
+ |
442 |
|
|
+ASTETCDIR="/etc/asterisk" |
443 |
|
|
+ASTSBINDIR="/usr/sbin" |
444 |
|
|
+ASTVARRUNDIR="/var/run/asterisk" |
445 |
|
|
+ASTVARLOGDIR="/var/log/asterisk" |
446 |
|
|
+ |
447 |
|
|
+CLIARGS="$*" # Grab any args passed to safe_asterisk |
448 |
|
|
+TTY=9 # TTY (if you want one) for Asterisk to run on |
449 |
|
|
+CONSOLE=yes # Whether or not you want a console |
450 |
|
|
+#NOTIFY=root@localhost # Who to notify about crashes |
451 |
|
|
+#EXEC=/path/to/somescript # Run this command if Asterisk crashes |
452 |
|
|
+#LOGFILE="${ASTVARLOGDIR}/safe_asterisk.log" # Where to place the normal logfile (disabled if blank) |
453 |
|
|
+#SYSLOG=local0 # Which syslog facility to use (disabled if blank) |
454 |
|
|
+MACHINE=`hostname` # To specify which machine has crashed when getting the mail |
455 |
|
|
+DUMPDROP="${DUMPDROP:-/tmp}" |
456 |
|
|
+RUNDIR="${RUNDIR:-/tmp}" |
457 |
|
|
+SLEEPSECS=4 |
458 |
|
|
+ASTPIDFILE="${ASTVARRUNDIR}/asterisk.pid" |
459 |
|
|
+ |
460 |
|
|
+# comment this line out to have this script _not_ kill all mpg123 processes when |
461 |
|
|
+# asterisk exits |
462 |
|
|
+KILLALLMPG123=1 |
463 |
|
|
+ |
464 |
|
|
+# run asterisk with this priority |
465 |
|
|
+PRIORITY=0 |
466 |
|
|
+ |
467 |
|
|
+# set system filemax on supported OSes if this variable is set |
468 |
|
|
+# SYSMAXFILES=262144 |
469 |
|
|
+ |
470 |
|
|
+# Asterisk allows full permissions by default, so set a umask, if you want |
471 |
|
|
+# restricted permissions. |
472 |
|
|
+#UMASK=022 |
473 |
|
|
+ |
474 |
|
|
+# set max files open with ulimit. On linux systems, this will be automatically |
475 |
|
|
+# set to the system's maximum files open devided by two, if not set here. |
476 |
|
|
+# MAXFILES=32768 |
477 |
|
|
+ |
478 |
|
|
+message() { |
479 |
|
|
+ if test -n "$TTY" && test "$TTY" != "no"; then |
480 |
|
|
+ echo "$1" >/dev/${TTY} |
481 |
|
|
+ fi |
482 |
|
|
+ if test -n "$SYSLOG"; then |
483 |
|
|
+ logger -p "${SYSLOG}.warn" -t safe_asterisk[$$] "$1" |
484 |
|
|
+ fi |
485 |
|
|
+ if test -n "$LOGFILE"; then |
486 |
|
|
+ echo "safe_asterisk[$$]: $1" >>"$LOGFILE" |
487 |
|
|
+ fi |
488 |
|
|
+} |
489 |
|
|
+ |
490 |
|
|
+# Check if Asterisk is already running. If it is, then bug out, because |
491 |
|
|
+# starting safe_asterisk when Asterisk is running is very bad. |
492 |
|
|
+VERSION=`"${ASTSBINDIR}/asterisk" -nrx 'core show version' 2>/dev/null` |
493 |
|
|
+if test "`echo $VERSION | cut -c 1-8`" = "Asterisk"; then |
494 |
|
|
+ message "Asterisk is already running. $0 will exit now." |
495 |
|
|
+ exit 1 |
496 |
|
|
+fi |
497 |
|
|
+ |
498 |
|
|
+# since we're going to change priority and open files limits, we need to be |
499 |
|
|
+# root. if running asterisk as other users, pass that to asterisk on the command |
500 |
|
|
+# line. |
501 |
|
|
+# if we're not root, fall back to standard everything. |
502 |
|
|
+if test `id -u` != 0; then |
503 |
|
|
+ echo "Oops. I'm not root. Falling back to standard prio and file max." >&2 |
504 |
|
|
+ echo "This is NOT suitable for large systems." >&2 |
505 |
|
|
+ PRIORITY=0 |
506 |
|
|
+ message "safe_asterisk was started by `id -n` (uid `id -u`)." |
507 |
|
|
+else |
508 |
|
|
+ if `uname -s | grep Linux >/dev/null 2>&1`; then |
509 |
|
|
+ # maximum number of open files is set to the system maximum |
510 |
|
|
+ # divided by two if MAXFILES is not set. |
511 |
|
|
+ if test -z "$MAXFILES"; then |
512 |
|
|
+ # just check if file-max is readable |
513 |
|
|
+ if test -r /proc/sys/fs/file-max; then |
514 |
|
|
+ MAXFILES=$((`cat /proc/sys/fs/file-max` / 2)) |
515 |
|
|
+ # don't exceed upper limit of 2^20 for open |
516 |
|
|
+ # files on systems where file-max is > 2^21 |
517 |
|
|
+ if test $MAXFILES -gt 1048576; then |
518 |
|
|
+ MAXFILES=1048576 |
519 |
|
|
+ fi |
520 |
|
|
+ fi |
521 |
|
|
+ fi |
522 |
|
|
+ SYSCTL_MAXFILES="fs.file-max" |
523 |
|
|
+ elif `uname -s | grep Darwin /dev/null 2>&1`; then |
524 |
|
|
+ SYSCTL_MAXFILES="kern.maxfiles" |
525 |
|
|
+ fi |
526 |
|
|
+ |
527 |
|
|
+ |
528 |
|
|
+ if test -n "$SYSMAXFILES"; then |
529 |
|
|
+ if test -n "$SYSCTL_MAXFILES"; then |
530 |
|
|
+ sysctl -w $SYSCTL_MAXFILES=$SYSMAXFILES |
531 |
|
|
+ fi |
532 |
|
|
+ fi |
533 |
|
|
+ |
534 |
|
|
+ # set the process's filemax to whatever set above |
535 |
|
|
+ ulimit -n $MAXFILES |
536 |
|
|
+ |
537 |
|
|
+ if test ! -d "${ASTVARRUNDIR}"; then |
538 |
|
|
+ mkdir -p "${ASTVARRUNDIR}" |
539 |
|
|
+ chmod 770 "${ASTVARRUNDIR}" |
540 |
|
|
+ fi |
541 |
|
|
+ |
542 |
|
|
+fi |
543 |
|
|
+ |
544 |
|
|
+if test -n "$UMASK"; then |
545 |
|
|
+ umask $UMASK |
546 |
|
|
+fi |
547 |
|
|
+ |
548 |
|
|
+# |
549 |
|
|
+# Let Asterisk dump core |
550 |
|
|
+# |
551 |
|
|
+ulimit -c unlimited |
552 |
|
|
+ |
553 |
|
|
+# |
554 |
|
|
+# Don't fork when running "safely" |
555 |
|
|
+# |
556 |
|
|
+ASTARGS="" |
557 |
|
|
+if test -n "$TTY" && test "$TTY" != "no"; then |
558 |
|
|
+ if test -c /dev/tty${TTY}; then |
559 |
|
|
+ TTY=tty${TTY} |
560 |
|
|
+ elif test -c /dev/vc/${TTY}; then |
561 |
|
|
+ TTY=vc/${TTY} |
562 |
|
|
+ elif test "$TTY" = "9"; then # ignore default if it was untouched |
563 |
|
|
+ # If there is no /dev/tty9 and not /dev/vc/9 we don't |
564 |
|
|
+ # necessarily want to die at this point. Pretend that |
565 |
|
|
+ # TTY wasn't set. |
566 |
|
|
+ TTY= |
567 |
|
|
+ else |
568 |
|
|
+ message "Cannot find specified TTY (${TTY})" |
569 |
|
|
+ exit 1 |
570 |
|
|
+ fi |
571 |
|
|
+ if test -n "$TTY"; then |
572 |
|
|
+ ASTARGS="${ASTARGS} -vvvg" |
573 |
|
|
+ if test "$CONSOLE" != "no"; then |
574 |
|
|
+ ASTARGS="${ASTARGS} -c" |
575 |
|
|
+ fi |
576 |
|
|
+ fi |
577 |
|
|
+fi |
578 |
|
|
+ |
579 |
|
|
+if test ! -d "${RUNDIR}"; then |
580 |
|
|
+ message "${RUNDIR} does not exist, creating" |
581 |
|
|
+ if ! mkdir -p "${RUNDIR}"; then |
582 |
|
|
+ message "Unable to create ${RUNDIR}" |
583 |
|
|
+ exit 1 |
584 |
|
|
+ fi |
585 |
|
|
+fi |
586 |
|
|
+ |
587 |
|
|
+if test ! -w "${DUMPDROP}"; then |
588 |
|
|
+ message "Cannot write to ${DUMPDROP}" |
589 |
|
|
+ exit 1 |
590 |
|
|
+fi |
591 |
|
|
+ |
592 |
|
|
+# |
593 |
|
|
+# Don't die if stdout/stderr can't be written to |
594 |
|
|
+# |
595 |
|
|
+trap '' PIPE |
596 |
|
|
+ |
597 |
|
|
+# |
598 |
|
|
+# Run scripts to set any environment variables or do any other system-specific setup needed |
599 |
|
|
+# |
600 |
|
|
+ |
601 |
|
|
+if test -d "${ASTETCDIR}/startup.d"; then |
602 |
|
|
+ for script in "${ASTETCDIR}/startup.d/"*.sh; do |
603 |
|
|
+ if test -r "${script}"; then |
604 |
|
|
+ . "${script}" |
605 |
|
|
+ fi |
606 |
|
|
+ done |
607 |
|
|
+fi |
608 |
|
|
+ |
609 |
|
|
+run_asterisk() |
610 |
|
|
+{ |
611 |
|
|
+ while :; do |
612 |
|
|
+ if test -n "$TTY" && test "$TTY" != "no"; then |
613 |
|
|
+ cd "${RUNDIR}" |
614 |
|
|
+ stty sane </dev/${TTY} |
615 |
|
|
+ nice -n $PRIORITY "${ASTSBINDIR}/asterisk" -f ${CLIARGS} ${ASTARGS} >/dev/${TTY} 2>&1 </dev/${TTY} |
616 |
|
|
+ else |
617 |
|
|
+ cd "${RUNDIR}" |
618 |
|
|
+ nice -n $PRIORITY "${ASTSBINDIR}/asterisk" -f ${CLIARGS} ${ASTARGS} >/dev/null 2>&1 </dev/null |
619 |
|
|
+ fi |
620 |
|
|
+ EXITSTATUS=$? |
621 |
|
|
+ message "Asterisk ended with exit status $EXITSTATUS" |
622 |
|
|
+ if test $EXITSTATUS -eq 0; then |
623 |
|
|
+ # Properly shutdown.... |
624 |
|
|
+ message "Asterisk shutdown normally." |
625 |
|
|
+ exit 0 |
626 |
|
|
+ elif test $EXITSTATUS -gt 128; then |
627 |
|
|
+ EXITSIGNAL=$((EXITSTATUS - 128)) |
628 |
|
|
+ message "Asterisk exited on signal $EXITSIGNAL." |
629 |
|
|
+ if test -n "$NOTIFY"; then |
630 |
|
|
+ echo "Asterisk on $MACHINE exited on signal $EXITSIGNAL. Might want to take a peek." | \ |
631 |
|
|
+ mail -s "Asterisk on $MACHINE died (sig $EXITSIGNAL)" $NOTIFY |
632 |
|
|
+ fi |
633 |
|
|
+ if test -n "$EXEC"; then |
634 |
|
|
+ $EXEC |
635 |
|
|
+ fi |
636 |
|
|
+ |
637 |
|
|
+ PID=`cat ${ASTPIDFILE}` |
638 |
|
|
+ DATE=`date "+%Y-%m-%dT%H:%M:%S%z"` |
639 |
|
|
+ if test -f "${RUNDIR}/core.${PID}"; then |
640 |
|
|
+ mv "${RUNDIR}/core.${PID}" "${DUMPDROP}/core.`hostname`-$DATE" & |
641 |
|
|
+ elif test -f "${RUNDIR}/core"; then |
642 |
|
|
+ mv "${RUNDIR}/core" "${DUMPDROP}/core.`hostname`-$DATE" & |
643 |
|
|
+ fi |
644 |
|
|
+ else |
645 |
|
|
+ message "Asterisk died with code $EXITSTATUS." |
646 |
|
|
+ |
647 |
|
|
+ PID=`cat ${ASTPIDFILE}` |
648 |
|
|
+ DATE=`date "+%Y-%m-%dT%H:%M:%S%z"` |
649 |
|
|
+ if test -f "${RUNDIR}/core.${PID}"; then |
650 |
|
|
+ mv "${RUNDIR}/core.${PID}" "${DUMPDROP}/core.`hostname`-$DATE" & |
651 |
|
|
+ elif test -f "${RUNDIR}/core"; then |
652 |
|
|
+ mv "${RUNDIR}/core" "${DUMPDROP}/core.`hostname`-$DATE" & |
653 |
|
|
+ fi |
654 |
|
|
+ fi |
655 |
|
|
+ message "Automatically restarting Asterisk." |
656 |
|
|
+ sleep $SLEEPSECS |
657 |
|
|
+ if test "0$KILLALLMPG123" -gt 0; then |
658 |
|
|
+ pkill -9 mpg123 |
659 |
|
|
+ fi |
660 |
|
|
+ done |
661 |
|
|
+} |
662 |
|
|
+ |
663 |
|
|
+if test -n "$ASTSAFE_FOREGROUND"; then |
664 |
|
|
+ run_asterisk |
665 |
|
|
+else |
666 |
|
|
+ run_asterisk & |
667 |
|
|
+fi |