#!/usr/bin/env perl

use warnings;
use diagnostics;

use lib "../../lib";
use HotSaNICparser;
use HotSaNICshellio;

my @CONFmod=HotSaNICparser::read_settings(".",$MODNAME);

if ( ! -e "settings" ) { $OUTFILE="settings"; } else { $OUTFILE="settings.new"; }

open OUTFILE,">$OUTFILE" || die "could not open $MODNAME settings file for writing.\n";

print OUTFILE "# SHORT DESCRIPTION
#
# define path to the apc access tool including the cmdline option
# to retrieve the status protocol
#
# Example:
#   APCACCESS=/usr/local/bin/apcaccess status
#
";

if ($OUTFILE eq "settings.new") { 
  for (@CONFmod) { print OUTFILE $_,"\n" if /^APCACCESS *=/; }
  }
else {
  my @found=HotSaNICparser::locate_files("apcaccess");
  my $file=HotSaNICshellio::choose("","apcaccess could not be found.",@found);
  print OUTFILE "APCACCESS=$file\n"
  }

close OUTFILE;

if ($OUTFILE eq "settings.new") {
  HotSaNICparser::backup_file("settings");
  rename "settings.new","settings";
  }

print "Please check the settings file and adapt it to satisfy your needs.\n";

