/[smecontribs]/rpms/smeserver-freepbx/contribs10/smeserver-freepbx-bz11613-sme10.patch
ViewVC logotype

Annotation of /rpms/smeserver-freepbx/contribs10/smeserver-freepbx-bz11613-sme10.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Fri Mar 25 04:44:47 2022 UTC (2 years, 6 months ago) by jpp
Branch: MAIN
* Wed Nov 10 2021 Jean-Philippe Pialasse <tests@pialasse.com> 13-17.sme
- first import to SME10 [SME: 11613]
- make it Freepbx 14 compatible [SME: 10705] 
  add dependencies for SME10 mariadb nodejs >= 10 php74*
  remove missing rpms asterisk-sounds-extra-en-ulaw asterisk-resample asterisk-addons
  remove double owned folders /etc/asterisk /var/lib/asterisk
  systemd ready for asterisk(disabled), freepbx, httpd-fpbx
  smeserver-freepbx-update event created NEED TEST
  php74-php-fpm fragment
  update httpd-fpbx template for php-fpm use
  TODO : update httpd-e-smith to use php-fpm for fpbx
  TODO : update install script for php74
  add a copy of safe_asterisk
  TODO : create php folders and set rights
  improve logrotate

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

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed