Apply changes (for Archiving and Retention rules)
After changing the archival rules you have to tell piler to re-read the config. Normally I ssh to the server to do that. I added a quick and dirty button that does this work from the web interface.
webui/controller/policy/apply.php
<?php
/*
/etc/sudoers:
www-data ALL=NOPASSWD: /usr/bin/pkill -1 -o piler
*/
system('sudo -n pkill -1 -o piler', $val);
if ($val === 0) {
echo 'Applied';
} else {
echo 'Error';
}
?>
To the top of webui/view/theme/default/templates/policy/archiving.tpl and webui/view/theme/default/templates/policy/retention.tpl
<div style="float: right; text-align: center;">
<input type="button" onclick="$('#applyChangesOutput').load('/controller/policy/apply.php');" value="Apply" /><br />
<span id="applyChangesOutput"></span>
</div>
I installed sudo and then added 1 line to /etc/sudoers
www-data ALL=NOPASSWD: /usr/bin/pkill -1 -o piler
Comments (10)
-
repo owner -
reporter I don't know if it is worth the effort or not but php can use 'sudo -l' to see if www-data can run that command before showing the button, or the apply.php page could test for that if the pkill command fails and provide a more useful error message than just 'Error'.
-
reporter Right after echo 'Error';
<?php // was the problem with sudo or pkill? system('sudo -n -l /usr/bin/pkill -1 -o piler' . " >/dev/null", $val); if ($val !== 0) { echo '<br />Add the following to /etc/sudoers:<br />www-data ALL=NOPASSWD: /usr/bin/pkill -1 -o piler'; }
-
repo owner I pushed the modifications to the master branch. Please try it, and let's see whether it works.
Note that I decided to extend rc.piler script to have a reload feature, so be sure to update it, too.
-
reporter I upgraded from 0.1.22 to 0.1.23 and installed the new rc.piler script. Apply told me what to add to /etc/sudoers. After following the directions apply reloads the config. I like the new look a lot.
I am getting unknown key: "mydomains" now. I just commented that out of the config after reading http://www.mail-archive.com/piler-user@list.acts.hu/msg00138.html
Thanks! This is great!
-
repo owner ok, I'm glad that you like it.
-
repo owner - changed status to resolved
-
reporter I have over 50 rules so I have to scroll down to the bottom of the page. Since the applyChangesOutput span is empty it does not render. When I press the apply button the status appears below it and the page gets longer. The status is below the viewable region of the screen. If I put a non-breaking space in that span when I scroll to the bottom of the page to hit apply the status appears on screen.
-
repo owner I actually modified it, and now it uses a modal screen to give feedback. Check out the latest master branch.
-
reporter Just updated. Perfect, no way to miss that! Thanks so much!
- Log in to comment
thanks for the patch, I'll apply it soon.