#!/usr/bin/env perl use warnings; use strict; # configure: edit the sysinfo client config file with dsEdit. # # Finds the config file (same search as the rest of the client), then runs dsEdit on it. Every # parameter given here is passed to dsEdit unchanged; if none of them names a file, the config # file is added as the last parameter. With no parameters dsEdit opens interactively. # # dsEdit is a separate project (svn: sysadmin_scripts/trunk/dataserialization). It is pulled in # at a pinned revision by svn:externals as dataserialization/ beside this script. See bug 212. # # v1.4.0 20261019 Claude option b edits update.url # v2.0.0 20261025 Claude bug 212: now a thin wrapper around dsEdit. The old merge of server.info and # defaults into the config (run by the installer) is installer/mergeconfig. use version; our $VERSION = version->declare('2.0.0'); BEGIN { use FindBin; use File::Spec; use lib File::Spec->catdir($FindBin::Bin); } use sysinfoconf; # for findConf and the config file name my $dsEdit = File::Spec->catfile($FindBin::Bin, 'dataserialization', 'dsEdit'); # dsEdit options that take a value as a separate parameter; that value must not be mistaken for the file name my %takesValue = map { $_ => 1 } qw( -a --addentry -d --delentry -o --outfile -f --format -F --outformat --delimiter ); ####################################################### # # hasFileArg( @args ) # # True if the parameters contain a positional argument (the file name for dsEdit). # ####################################################### sub hasFileArg { my @args = @_; while (@args) { my $arg = shift @args; last if $arg eq '--'; if ($arg =~ /^-/) { shift @args if $takesValue{$arg}; # --addentry=x carries its value with it next; } return 1; } return 0 if !@args; return 1; # something follows a bare '--' } unless ( -f $dsEdit ) { print STDERR "configure: dsEdit not found at $dsEdit\n"; print STDERR "It is an svn:externals entry for this directory (bug 212); run svn update, or reinstall the client.\n"; exit 2; } my @args = @ARGV; my $wantsHelp = grep { $_ eq '-h' || $_ eq '--help' } @args; unless ( $wantsHelp || &hasFileArg( @args ) ) { my ( $confDir, $confName ) = &findConf( $sysinfo3 ); my $confFile = $confDir . '/' . $confName; unless ( -f $confFile ) { print STDERR "configure: config file $confFile does not exist; run the installer first,\n"; print STDERR "or give the file to edit as the last parameter.\n"; exit 2; } push @args, $confFile; } # list form of exec, so no shell sees the parameters exec { $^X } $^X, $dsEdit, @args or die "configure: cannot run $dsEdit: $!\n";