From 8dced78dc75cdc9e76f410c4d6d0cf377d1df0e7 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Mon, 7 Oct 2013 16:30:19 +0200 Subject: [PATCH] Add an indexer cron job --- root/etc/cron.daily/ajaxplorer-indexer | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 root/etc/cron.daily/ajaxplorer-indexer diff --git a/root/etc/cron.daily/ajaxplorer-indexer b/root/etc/cron.daily/ajaxplorer-indexer new file mode 100644 index 0000000..b9af107 --- /dev/null +++ b/root/etc/cron.daily/ajaxplorer-indexer @@ -0,0 +1,35 @@ +#!/usr/bin/perl -w + +use strict; +use esmith::ConfigDB; +use esmith::AccountsDB; + +my $c = esmith::ConfigDB->open_ro || die "Couldn't open ConfigDB\n"; +my $a = esmith::AccountsDB->open_ro || die "Couldn't open AccountsDB\n"; + +my $ajaxplorer = $c->get('ajaxplorer') || die "ajaxplorer entry is missing in the configuration database\n"; +my $status = $ajaxplorer->prop('status') || 'disabled'; +my $indexer = $ajaxplorer->prop('Indexer') || 'enabled'; + +exit(0) if ($status ne 'enabled' || $indexer ne 'enabled'); + +# Generate a random ID for our requests +my @chars = ('a'..'z','A..Z','0'..'9'); +my $id = ''; +foreach (0..32){ + $id .= $chars[rand @chars]; +} +foreach my $share ($a->get_all_by_prop(type => 'share')){ + $ajaxplorer = $share->prop('Ajaxplorer') || 'disabled'; + $indexer = $share->prop('AjaxplorerIndexer') || 'enabled'; + next if ($ajaxplorer ne 'enabled' || $indexer ne 'enabled'); + my $name = $share->key; + system('/usr/bin/sudo -u www /usr/bin/php /usr/share/ajaxplorer/cmd.php ' . + '-u=RDiin175M40T0cYvXLARpAi+1TsSVkbksEDZ4KvwBuY= '. + '-t=e71479ebc4365176d9f09fe957780024 -a=index '. + '-r='.$name.' --secure_token='.$id.' --dir=/ --_method=put 2>/dev/null 2>&1'); +} +# We should now restart OOo to release memory +if (-d '/var/service/ooo'){ + system('/usr/bin/sv t /service/ooo'); +}