From b7afd023a8e5ff86f751196984ba87dcb9d451cd Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Tue, 8 May 2012 00:44:49 -0500 Subject: initial repo add --- sboconfig | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100755 sboconfig (limited to 'sboconfig') diff --git a/sboconfig b/sboconfig new file mode 100755 index 0000000..b440edb --- /dev/null +++ b/sboconfig @@ -0,0 +1,119 @@ +#!/usr/bin/env perl +# +# sboconfig +# script to handle sbotools configuration +# +# author: Jacob Pipkin +# date: Pungenday, the 40th day of Discord in the YOLD 3178 +# license: WTFPL + +use strict; +use warnings FATAL => 'all'; +use SBO::Lib; +use File::Basename; +use Getopt::Std; +use File::Copy; +use File::Path qw(make_path); +use Fcntl; + +my %config = %SBO::Lib::config; +my $self = basename($0); + +sub show_usage { + print <; + close($fh); + tie my @temp, 'Tie::File', $filename; + my $has = 'FALSE'; + my $regex = qr/\A\Q$key\E=/; + FIRST: for my $tmpline (@temp) { + if ($tmpline =~ $regex) { + $has = 'TRUE'; + $tmpline = "$key=$val"; + last FIRST; + } + } + untie @temp; + if ($has eq 'FALSE') { + open (my $writer, '>>', $filename); + print {$writer} "$key=$val\n"; + close($writer); + } + move($filename,$conf_file); + } else { + open my $writer, '>', $conf_file; + print {$writer} "$key=$val\n"; + close($writer); + } +} + +while (my ($key,$value) = each %changes) { + print "Setting $key to $value...\n"; + config_write($key,$value); +} + +exit(0); -- cgit v1.2.3