Alfred expects to be fed data periodically, but there's currently no easy
way to do that from scripts, prompting people to write whole C programs
to accomplish tasks that could easily be scripted.
Provide a really simple framework to run scripts every 5 minutes, using a
cronjob, when alfred is started by the init.d script.
Signed-off-by: Gui Iribarren <gui@altermundi.net>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
option mode 'master'
option batmanif 'bat0'
option start_vis '1'
option mode 'master'
option batmanif 'bat0'
option start_vis '1'
# REMOVE THIS LINE TO ENABLE ALFRED
option disabled '1'
# REMOVE THIS LINE TO ENABLE ALFRED
option disabled '1'
STOP=99
alfred_args=""
vis_args=""
STOP=99
alfred_args=""
vis_args=""
+facters_dir="/etc/alfred"
pid_file_alfred="/var/run/alfred.pid"
pid_file_vis="/var/run/vis.pid"
enable=0
pid_file_alfred="/var/run/alfred.pid"
pid_file_vis="/var/run/vis.pid"
enable=0
append vis_args "-i $batmanif -s"
fi
append vis_args "-i $batmanif -s"
fi
+ config_get_bool run_facters "$section" run_facters 0
+
SERVICE_PID_FILE="$pid_file_alfred"
service_start /usr/sbin/alfred ${alfred_args}
SERVICE_PID_FILE="$pid_file_alfred"
service_start /usr/sbin/alfred ${alfred_args}
- if [ "$vis_enable" = "0" ]; then
- exit 0
- fi
- echo "${initscript}: starting vis"
- SERVICE_PID_FILE="$pid_file_vis"
- service_start /usr/sbin/vis ${vis_args}
+ if [ "$vis_enable" = "1" ]; then
+ echo "${initscript}: starting vis"
+ SERVICE_PID_FILE="$pid_file_vis"
+ service_start /usr/sbin/vis ${vis_args}
+ fi
+
+ if [ "$run_facters" = "1" ]; then
+ ( for file in $facters_dir/* ; do [ -x $file ] && $file ; done )
+ if ! ( grep -q "for file in $facters_dir/\* ; do " /etc/crontabs/root 2>/dev/null ) ; then
+ echo "*/5 * * * * ( for file in $facters_dir/* ; do [ -x \$file ] && \$file ; done )" >> /etc/crontabs/root
+ /etc/init.d/cron enable
+ /etc/init.d/cron restart
+ fi
+ fi
service_stop /usr/sbin/alfred
SERVICE_PID_FILE="$pid_file_vis"
[ -x /usr/sbin/vis ] && service_stop /usr/sbin/vis
service_stop /usr/sbin/alfred
SERVICE_PID_FILE="$pid_file_vis"
[ -x /usr/sbin/vis ] && service_stop /usr/sbin/vis
+ sed "\|for file in $facters_dir/\* ; do |d" -i /etc/crontabs/root
+ /etc/init.d/cron restart