Commit dfe07233 authored by Ryan Jackson's avatar Ryan Jackson

Add script to sync subboss /tftpboot

parent fc6ab986
......@@ -20,7 +20,7 @@ SBIN_SCRIPTS = avail inuse showgraph if2port backup webcontrol node_status \
idletimes idlemail setsitevar audit changeuid changepid \
elabinelab_bossinit update_permissions mysqld_watchdog \
dumperrorlog changeleader checkstats changecreator \
dbupdate geni_control
dbupdate geni_control subboss_sync
WEB_SBIN_SCRIPTS= webnodelog webnewwanode webidlemail webchangeuid \
webchangeleader
......
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
use Getopt::Std;
use Fcntl ':flock';
my $RSYNC = 'rsync';
my $RSYNC_OPTS = "-c -W -u -av --delete --force";
my @excludes=qw#cisco-config/ cisco-config. hp-config/ OLD/ tmp/ /proj/#;
my @includes=qw#INCLUDE_ME#;
#
# dhcpd_makeconf - helper script to create dhcpd.conf files from the database.
# The template file should look like an ordinary dhcpd.conf file, but have
# the string %%nodetype=<type> where you want entries for a set of nodes
# filled out. See the template file in the dhcp directory for an example.
#
sub usage {
print "Usage: $0 [-h]\n";
print "-h Show this message\n";
exit(1);
}
my $optlist = "h";
my $install = 0;
my $vnames = 0;
my $restart = 0;
# un-taint path
$ENV{'PATH'} = '/bin:/usr/bin:/usr/sbin:/usr/local/bin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
# Turn off line buffering on output
$| = 1;
use lib "@prefix@/lib";
use libdb;
use libtestbed;
#
# Parse command arguments. Once we return from getopts, all that should
# left are the required arguments.
#
%options = ();
if (! getopts($optlist, \%options)) {
usage();
}
if (defined($options{"h"})) {
usage();
}
my $cmdline = $RSYNC . ' ' . $RSYNC_OPTS;
for (@excludes) {
$cmdline .= " --exclude=$_";
}
for (@includes) {
$cmdline .= " --include=$_";
}
$cmdline .= " -e ssh /tftpboot/";
# Slurp in all of the subboss data to know A) if we should serve the DHCP
# lease to a given node, or if the next-server field should be something
# other than the IP for boss.
$query_result =
DBQueryWarn("select distinct subboss_id from subbosses where service = 'tftp'");
if (! $query_result) {
fatal("Could not dhcpd data from DB!");
}
while (my %row = $query_result->fetchhash()) {
my $subboss_id = $row{"subboss_id"};
print $cmdline . " $subboss_id:/tftpboot/\n");
system($cmdline . " $subboss_id:/tftpboot/");
}
exit(0);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment