add cron script to sync plc db and rt every hour
authorStephen Soltesz <soltesz@cs.princeton.edu>
Sun, 21 Jun 2009 20:12:25 +0000 (20:12 +0000)
committerStephen Soltesz <soltesz@cs.princeton.edu>
Sun, 21 Jun 2009 20:12:25 +0000 (20:12 +0000)
install cron script.

Monitor.spec
rt3/adduserstort.pl
rt3/syncrtusers.cron [new file with mode: 0644]

index 4a57efe..6d4bf82 100644 (file)
@@ -225,6 +225,7 @@ rm -rf $RPM_BUILD_ROOT
 %defattr(-,root,root)
 /usr/share/%{name}/rt3
 %{_sysconfdir}/plc.d/rt3
+%{_sysconfdir}/cron.d/syncrcusers.cron
 
 %files pcucontrol
 %{python_sitearch}/pcucontrol
@@ -271,6 +272,7 @@ plc-config --save /etc/planetlab/default_config.xml \
 %post rt
 plc-config --save /etc/planetlab/default_config.xml \
                        --category plc_rt --variable enabled --value true
+install -D -m 644 /usr/share/monitor/rt3/synncrtusers.cron $RPM_BUILD_ROOT/%{_sysconfdir}/cron.d/syncrcusers.cron
 
 %post server
 # TODO: this will be nice when we have a web-based service running., such as
index 7037ca6..899e4ce 100644 (file)
@@ -26,7 +26,9 @@ my $address1 = '';
 my $city = '';
 my $country = '';
 
-open(USERS_DATA, "./users_data.csv") || die("Could not open file!");
+print $ARGV[0];
+
+open(USERS_DATA, $ARGV[0]) || die("Could not open file!");
 @raw_data=<USERS_DATA>;
 close(USERS_DATA);
 foreach $bc_user (@raw_data)
@@ -35,12 +37,13 @@ foreach $bc_user (@raw_data)
  ($email_address,$realname,$organization)=split(/\,/,$bc_user);
 
   my $UserObj = new RT::User(RT::SystemUser);
+  print "adding user: $email_address\n";
   $UserObj->Create(Name => $email_address,
              RealName => $realname,
              EmailAddress => $email_address,
              Password => 'Passw0rd',
              Organization => $organization,
-             Privileged => 1);
+             Privileged => 0);
              #Address1 => $address1,
              #City => $city,
              #Country => country,
diff --git a/rt3/syncrtusers.cron b/rt3/syncrtusers.cron
new file mode 100644 (file)
index 0000000..97de75a
--- /dev/null
@@ -0,0 +1,7 @@
+SHELL=/bin/bash
+PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/share/monitor/rt3
+HOME=/usr/share/monitor
+MAILTO=soltesz@cs.princeton.edu
+
+01 * * * * root getusersfromplc.py | adduserstort.pl -
+