initial commit of file from CVS for smeserver-freepbx on Sat Sep 7 20:25:35 AEST 2024
This commit is contained in:
22
root/etc/e-smith/events/actions/freepbx-cron
Normal file
22
root/etc/e-smith/events/actions/freepbx-cron
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
path='PATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/root\/bin'
|
||||
cronfile='/var/spool/cron/asterisk'
|
||||
[ ! -f $cronfile ] && exit 0
|
||||
status=$(/sbin/e-smith/config getprop freepbx status || echo "disabled")
|
||||
|
||||
# add PATH to fist line if not present; else update it
|
||||
sed -i "1!b;s/^PATH.*/$path/; t; 1i $path" $cronfile
|
||||
# remove any other occurence of PATH
|
||||
sed -i "1p;t; /^PATH.*/d" $cronfile
|
||||
|
||||
# check if freepbx enabled
|
||||
if [[ $status == "enabled" ]]; then
|
||||
# if enabled uncomment
|
||||
sed -ri 's/^#(\@[a-zA-Z]+ .*|[0-9*]+ [0-9*]+ [0-9*]+ [0-9*]+ [0-9*]+ .*)/\1/' $cronfile
|
||||
else
|
||||
# if disabled comment out
|
||||
sed -ri 's/^(\@[a-zA-Z]+ .*|[0-9*]+ [0-9*]+ [0-9*]+ [0-9*]+ [0-9*]+ .*)/#\1/' $cronfile
|
||||
fi
|
||||
#remove any duplicate entry
|
||||
awk '!x[$0]++' ${cronfile} >${cronfile}-tmp && cat ${cronfile}-tmp > ${cronfile} && rm -f ${cronfile}-tmp
|
Reference in New Issue
Block a user