Skip to content
Snippets Groups Projects
Forked from 713 / Warden / Warden
739 commits behind the upstream repository.
unregisterClient.pl 4.70 KiB
#!/usr/bin/perl -w
#
# unregisterClient.pl
#
# Copyright (C) 2011-2013 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.

use strict;
use Getopt::Std;
use Switch;
use DBI;
use DBD::mysql;
use DateTime;
use Sys::Syslog qw(:DEFAULT setlogsock);
Sys::Syslog::setlogsock('unix');
use Carp;
use FindBin qw($RealBin $RealScript);
use lib "$FindBin::RealBin/../lib";
use WardenCommon;



################################################################################
#				VARIABLES
################################################################################
our $VERSION = "2.2";
my $etc = "$FindBin::RealBin/../etc";



################################################################################
#                               FUNCTIONS
################################################################################
sub usage {
  print "Usage: $RealScript [-h -i <client_id>]\n";
  exit 1;
}


sub help {
  print "$RealScript [-h -i <client_id>]\n";
  print "-h     print this text and exit\n";
  print "-i     client_id for unregistration\n";
  exit 0;
}



################################################################################
#                               MAIN
################################################################################
our ($opt_h, $opt_i);

if ($#ARGV == -1) {usage}

die usage unless getopts("i:h");
my $client_id	= $opt_i;
my $help        = $opt_h;

# catch help param
if ($help) {help}

# superuser controle
my $UID = $<;
if ($UID != 0) {WardenCommon::errMsg("You must be root for running this script!")}

# check parameters definition
if (!defined $client_id) {WardenCommon::errMsg("Parameter 'client_id' is not defined!")}