From 5699d18dd35ac39fee4bb7d8fa3acb853ded2cce Mon Sep 17 00:00:00 2001 From: neingeist Date: Wed, 23 Mar 2011 14:15:53 +0100 Subject: [PATCH] use env to get user/hostname --- virssh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/virssh b/virssh index 1f923fa..5d326c7 100755 --- a/virssh +++ b/virssh @@ -1,9 +1,17 @@ #!/usr/bin/perl +# +# virssh - allow users to control their libvirt VM through SSH. +# +# For usage please see README.md. +# + use strict; use warnings; my $logtag = $0; my $vm = $ARGV[0]; +my $HOSTNAME = `hostname -f` || "vmserver"; chomp($HOSTNAME); +my $USER = $ENV{"USER"} || "vmadmin"; my $SSH_ORIGINAL_COMMAND = $ENV{"SSH_ORIGINAL_COMMAND"} || ""; if ($SSH_ORIGINAL_COMMAND =~ /^sudo virsh (list|console $vm|destroy $vm|shutdown $vm|start $vm( --console)?)$/s) { @@ -15,12 +23,12 @@ if ($SSH_ORIGINAL_COMMAND =~ /^sudo virsh (list|console $vm|destroy $vm|shutdown print STDERR <