From: "Michel Meyers" <steltek@tcnnet.dyndns.org>
To: "bacula-users" <bacula-users@lists.sourceforge.net>
Subject: [Bacula-users] Script for pushing new clients to Windows boxes
Date: Mon, 2 Feb 2004 16:10:48 +0100

Hello,

Some of you may remember my document on how to remotely push a Win32 bacula
client onto a WinNT/2k/XP box. Well, I've written a script to do it for me
and thought I'd share it with you:
- ----------------------------------------------------------------
#!/bin/bash
#
# Remote Win32 client upgrade script
# written by Michel Meyers (last update 02/02/04 16:10)
#
# WARNING: Make sure that no bacula-fd.conf exists in the source directory!
# You will destroy/overwrite all your client's configs if you don't
# be careful with this.
#
# The upgrade function does the following:
# - Shutdown Bacula service on remote machine
# - Wait 30 seconds (to allow proper shutdown)
# - Mount C: drive of remote box
# - Copy new client to remote machine
# - Unmount C;
# - Startup the new Bacula service
#
# To upgrade a machine append the following at the bottom of this file:
#
# SERVERNAME=<hostname>
# USERNAME=<username>
# PASSWORD=<password, "" for blank>
# upgrade

upgrade() {
rpcclient -S $SERVERNAME -U $USERNAME%"$PASSWORD" -c "service stop bacula"
sleep 30
smbmount //$SERVERNAME/c$ /mnt -o username=$USERNAME,password="$PASSWORD"
cp /home/michel/winbacula/bin/* /mnt/bacula/bin
umount /mnt
rpcclient -S $SERVERNAME -U $USERNAME%"$PASSWORD" -c "service start bacula"
}

SERVERNAME=xerxes
USERNAME=administrator
PASSWORD=secret
upgrade

SERVERNAME=shodan
USERNAME=teh_one
PASSWORD=""
upgrade
- ----------------------------------------------------------------

It should be pretty self-explanatory. I'm not good at shell programming and
I don't know whether there's any notion of arrays or 'for' loops that could
make it cleaner so I simply wrote a function which references some variables
and then call that repeatedly (once per machine). You can of course change
the values according to your system and liking (if 30 secs seem to much for
you, just reduce the value after sleep, make sure to check on the paths and
mountpoint /mnt may not be usable on your system, ...)

Note: The requirements are the same as described in my other document
(Samba-TNG clients among others, otherwise you'll be missing rpcclient).

Enjoy!

