#!/usr/bin/perl -w use Zymonic::Config; use Zymonic::Utils qw(death_handler clean); # Needs an argument if ( !(@ARGV) ) { warn "Usage is $0 [zymonic repo directory]"; exit 1; } # lookup zymonic version, incoming is repo/file in repo path my $zymonic_dir = clean( shift @ARGV, '/-_\\.' ); my $info_revision = `svn info $zymonic_dir | grep "Revision: "`; my $info_url = `svn info $zymonic_dir | grep "URL: "`; my $zymonic_version = substr( $info_revision, 10 ); chomp $zymonic_version; my $zymonic_type = 'U'; if ( $info_url =~ /trunk/ ) { $zymonic_type = 'D'; } elsif ( $info_url =~ /qa/ ) { $zymonic_type = 'Q'; } elsif ( $info_url =~ /live/ ) { $zymonic_type = 'L'; } print "Zymonic Version: Version is >$zymonic_version<, Type is >$zymonic_type<\n"; # set on each system foreach my $system_path ( grep { -d } glob "/etc/zymonic/*" ) { my $system = ( split( "/etc/zymonic/", $system_path ) )[1]; if ( !( -f "/etc/zymonic/$system/ZymonicCore.xml" ) ) { print "Zymonic Version: System $system does not have a core xml file, skipping\n"; next; } eval { my $config = Zymonic::Config->new( system_name => $system, config_dir => "/etc/zymonic", ip_address => '127.0.0.1', ); $config->set_version_number( 'Z' . $zymonic_type . $zymonic_version ); print "Zymonic Version: Version set for $system\n"; } or do { my $error = death_handler( $@, '', 'return' ); print "Zymonic Version: Version not set for $system - Error $error->{reference}\n"; } }