BackupPC-users

Re: [BackupPC-users] check if user is still logged on before shutting down client after dump

2011-09-07 18:10:52
Subject: Re: [BackupPC-users] check if user is still logged on before shutting down client after dump
From: Holger Parplies <wbppc AT parplies DOT de>
To: Kenneth <meel2mi AT hotmail DOT com>
Date: Thu, 8 Sep 2011 00:09:03 +0200
Hi,

Kenneth wrote on 2011-08-29 11:53:01 +0200 [[BackupPC-users] check if user is 
still logged on before shutting down client after dump]:
> Hello, I'd like to shutdown my linux workstation after a dump, but it 
> shouldn't shutdown the workstation when a user is still logged in. 
> However, my scripts do not seem to work when called from backuppc. 

sorry for the delay in responding.

In which way does the script not work when called from BackupPC? Please give
as much detail as you can (e.g. quotes from log files). Your problem is not
apparent from what you write.

> However, it works when I call wrapper.sh from the shell by entering 
> ./wrapper.sh "HOSTNAME" as user backuppc.
> [...]
> config exerpt:
> $Conf{DumpPostUserCmd} = 'wrapper.sh $host';

You should supply the path to wrapper.sh here. I'm not sure what directories
would be searched without path, but I wouldn't rely on it being the correct
ones.

Does your HOSTNAME contain any unusual characters? I'm just asking because you
quoted it on the command line.

> wrapper.sh contains:
> HOSTNAME=$1
> ssh root@$HOSTNAME  'bash' < /etc/backuppc/shutdown.sh

The only real difference I can see at the moment is that stdin for ssh will be
a tty when you call that from the command line, while it won't when BackupPC
calls it. I don't think that makes any difference, though.

> shutdown.sh contains:
> #!/bin/bash
> 
> # Read logged users
> USERCOUNT=`who | wc -l`;
> # No Shutdown if there are any users logged in
> if (($USERCOUNT>0))
> then exit
> else shutdown -h now
> fi
> exit 0

Depending on the nature of "it doesn't work", you could try giving the code
inline to bash rather than via input redirection ... something like

        ssh root@$HOSTNAME '[ `who | wc -l` == 0 ] && shutdown -h now'

(you might need an additional "|| true" at the end, not sure). Or you could
use Perl. It's not something obvious like ssh asking you for a password, I
guess?

Hope that helps.

Regards,
Holger

------------------------------------------------------------------------------
Using storage to extend the benefits of virtualization and iSCSI
Virtualization increases hardware utilization and delivers a new level of
agility. Learn what those decisions are and how to modernize your storage 
and backup environments for virtualization.
http://www.accelacomm.com/jaw/sfnl/114/51434361/
_______________________________________________
BackupPC-users mailing list
BackupPC-users AT lists.sourceforge DOT net
List:    https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:    http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/

<Prev in Thread] Current Thread [Next in Thread>
  • Re: [BackupPC-users] check if user is still logged on before shutting down client after dump, Holger Parplies <=