mirror of
https://github.com/samba-team/samba.git
synced 2024-12-27 03:21:53 +03:00
28177ca73b
- changed the order of PROGS and SPROGS in Makefile (SPROGS first)
- another 64 bit cleanup (for INADDR_NONE)
- added paranoia code in DirCacheAdd() to detect looping
- fixed important DirCache flush bug
- rewrote the NetServerEnum code after I found it could return servers
from multiple workgroups at once, and this could cause browsing
havoc. Now a null workgroup query is equivalent to a query for the
servers primary workgroup
- got rid of my_workgroup()
- got rid of "workgroup = *" comment in Makefile. We no longer support
a workgroup of *, users must set the workgroup explicitly
- the wins.dat file was being stored in a different format to what it
was being loaded in - this could cause havoc. fixed.
- uppercase our netbios name and the workgroup name at startup
- if accept fails in main loop when running as a daemon then continue,
don't just exit!
- don't use ./ on smbclient in smbtar
- better code to detect if a process exists
(This used to be commit ec3d539630
)
141 lines
4.1 KiB
Bash
141 lines
4.1 KiB
Bash
#!/bin/sh
|
|
#
|
|
# smbtar script - front end to smbclient
|
|
#
|
|
# Authors: Martin.Kraemer <Martin.Kraemer@mch.sni.de>
|
|
# and Ricky Poulten (ricky@logcam.co.uk)
|
|
#
|
|
# (May need to change shell to ksh for HPUX or OSF for better getopts)
|
|
|
|
case $0 in
|
|
# when called by absolute path, assume smbclient is in the same directory
|
|
/*)
|
|
SMBCLIENT="`dirname $0`/smbclient";;
|
|
*) # you may need to edit this to show where your smbclient is
|
|
SMBCLIENT="smbclient";;
|
|
esac
|
|
|
|
# These are the default values. You could fill them in if you know what
|
|
# you're doing, but beware: better not store a plain text password!
|
|
server=""
|
|
service="backup" # Default: a service called "backup"
|
|
password=""
|
|
username=$LOGNAME # Default: same user name as in *nix
|
|
verbose="2>/dev/null" # Default: no echo to stdout
|
|
log="-d 2"
|
|
newer=""
|
|
blocksize=""
|
|
tarcmd="c"
|
|
tarargs=""
|
|
cdcmd="\\"
|
|
tapefile=${TAPE-tar.out}
|
|
|
|
Usage(){
|
|
ex=$1
|
|
shift
|
|
echo >&2 "Usage: `basename $0` [<options>] [<include/exclude files>]
|
|
Function: backup/restore a Windows PC directories to a local tape file
|
|
Options: (Description) (Default)
|
|
-r Restore from tape file to PC Save from PC to tapefile
|
|
-i Incremental mode Full backup mode
|
|
-v Verbose mode: echo command Don't echo anything
|
|
-s <server> Specify PC Server $server
|
|
-p <password> Specify PC Password $password
|
|
-x <share> Specify PC Share $service
|
|
-X Exclude mode Include
|
|
-N <newer> File for date comparison `set -- $newer; echo $2`
|
|
-b <blocksize> Specify tape's blocksize `set -- $blocksize; echo $2`
|
|
-d <dir> Specify a directory in share $cdcmd
|
|
-l <log> Specify a Samba Log Level `set -- $log; echo $2`
|
|
-u <user> Specify User Name $username
|
|
-t <tape> Specify Tape device $tapefile
|
|
"
|
|
echo >&2 "$@"
|
|
exit $ex
|
|
}
|
|
|
|
while getopts rivl:b:d:N:s:p:x:u:Xt: c; do
|
|
case $c in
|
|
r) # [r]estore to Windows (instead of the default "Save from Windows")
|
|
tarcmd="x"
|
|
;;
|
|
i) # [i]ncremental
|
|
tarargs=${tarargs}g
|
|
;;
|
|
l) # specify [l]og file
|
|
log="-d $OPTARG"
|
|
case "$OPTARG" in
|
|
[0-9]*) ;;
|
|
*) echo >&2 "$0: Error, log level not numeric: -l $OPTARG"
|
|
exit 1
|
|
esac
|
|
;;
|
|
d) # specify [d]irectory to change to in server's share
|
|
cdcmd="$OPTARG"
|
|
;;
|
|
N) # compare with a file, test if [n]ewer
|
|
if [ -f $OPTARG ]; then
|
|
newer=$OPTARG
|
|
tarargs=${tarargs}N
|
|
else
|
|
echo >&2 $0: Warning, $OPTARG not found
|
|
fi
|
|
;;
|
|
X) # Add exclude flag
|
|
tarargs=${tarargs}X
|
|
;;
|
|
s) # specify [s]erver's share to connect to - this MUST be given.
|
|
server="$OPTARG"
|
|
;;
|
|
b) # specify [b]locksize
|
|
blocksize="blocksize $OPTARG"
|
|
case "$OPTARG" in
|
|
[0-9]*) ;;
|
|
*) echo >&2 "$0: Error, block size not numeric: -b $OPTARG"
|
|
exit 1
|
|
esac
|
|
tarargs=${tarargs}b
|
|
;;
|
|
p) # specify [p]assword to use
|
|
password="$OPTARG"
|
|
;;
|
|
x) # specify windows [s]hare to use
|
|
service="$OPTARG"
|
|
;;
|
|
t) # specify [t]apefile on local host
|
|
tapefile="$OPTARG"
|
|
;;
|
|
u) # specify [u]sername for connection
|
|
username="$OPTARG"
|
|
;;
|
|
v) # be [v]erbose and display what's going on
|
|
verbose=""
|
|
;;
|
|
'?') # any other switch
|
|
Usage 2 "Invalid switch specified - abort."
|
|
;;
|
|
esac
|
|
done
|
|
|
|
shift `expr $OPTIND - 1`
|
|
|
|
if [ "$server" = "" ] || [ "$service" = "" ]; then
|
|
Usage 1 "No server or no service specified - abort."
|
|
fi
|
|
|
|
# if the -v switch is set, the echo the current parameters
|
|
if [ -z "$verbose" ]; then
|
|
echo "server is $server"
|
|
# echo "share is $service"
|
|
echo "share is $service\\$cdcmd"
|
|
echo "tar args is $tarargs"
|
|
# echo "password is $password" # passwords should never be sent to screen
|
|
echo "tape is $tapefile"
|
|
echo "blocksize is $blocksize"
|
|
fi
|
|
|
|
eval $SMBCLIENT "'\\\\$server\\$service'" "'$password'" -U "'$username'" \
|
|
-E -N $log -D "'$cdcmd'" \
|
|
-T${tarcmd}${tarargs} $blocksize $newer $tapefile $* $verbose
|
|
|