]> git.defcon.no Git - hermes/blobdiff - guc-clients/feide2sipuser
Adding --dryrun|-d option to assignphone and feide2sipuser
[hermes] / guc-clients / feide2sipuser
index 48e20c8a207c083b31a3c60c0b845a3b2e88fab7..5660c5e1b18ff9fbf5644a96e1135c8e25edcf3e 100755 (executable)
@@ -14,6 +14,7 @@ my $api_key;
 my $help;
 my $username;
 my $configfile;
+my $dryrun = 0;
 my ($g_ua, $session, $api_key, $auth_key, $data, $domain);
 my ($user, $displayname, $phone, $mail, $sipuser, $linetext);
 
@@ -34,6 +35,7 @@ GetOptions(
        "help"          => \$help,
        "username=s"    => \$username,
        "configfile=s"  => \$configfile,
+       "dryrun"        => \$dryrun,
 );
 
 if (
@@ -62,6 +64,7 @@ print <<END_HELP;
 Verify that the following options are set:
        --configfile=s
        --username=s
+       --dryrun
 
 Verify the contents of the configuration file.
 Verify that the key-file exists.
@@ -133,6 +136,7 @@ $g_ua->cookie_jar({}); # In-memory jar, look at HTTP::Cookies for persistant
 
 login_apikey();
 
+
 $data = exec_apinode("user/available", { "user" => $sipuser });
 if ( not $data->{'response'} eq 'ok' )
 {
@@ -141,6 +145,12 @@ if ( not $data->{'response'} eq 'ok' )
 }
 undef $data;
 
+if ( $dryrun ) {
+       print("Dryrun specified. All OK so far, stopping before add.\n");
+       logout();
+       exit;
+}
+
 $data = exec_apinode("user/add_local", { 
        "user" => $sipuser,
        "displayname" => $displayname,