summaryrefslogtreecommitdiff
path: root/source/script
diff options
context:
space:
mode:
Diffstat (limited to 'source/script')
-rw-r--r--source/script/addtosmbpass74
-rwxr-xr-xsource/script/installbin.sh42
-rwxr-xr-xsource/script/installman.sh35
-rwxr-xr-xsource/script/mksmbpasswd.sh6
-rwxr-xr-xsource/script/revert.sh15
-rw-r--r--source/script/smbtar141
-rwxr-xr-xsource/script/updatesmbpasswd.sh14
7 files changed, 327 insertions, 0 deletions
diff --git a/source/script/addtosmbpass b/source/script/addtosmbpass
new file mode 100644
index 00000000000..42af518397c
--- /dev/null
+++ b/source/script/addtosmbpass
@@ -0,0 +1,74 @@
+#!/usr/bin/awk -f
+# edit the line above to point to your real location of awk interpreter
+
+# awk program for adding new entries in smbpasswd files
+# arguments are account names to add; feed it an existent Samba password
+# file on stdin, results will be written on stdout
+#
+# Michal Jaegermann, michal@ellpspace.math.ualberta.ca, 1995-11-09
+
+BEGIN {
+ me = "addtosmbpass";
+ count = ARGC;
+ FS = ":";
+
+ if (count == 1) {
+ print "Usage:", me,
+ "name1 [name2 ....] < smbpasswd.in > smbpasswd.out";
+ ARGV[1] = "/dev/null";
+ ARGC = 2;
+ exit;
+ }
+
+ for(i = 1; i < count; i++) {
+ names[ARGV[i]] = " ";
+ delete ARGV[i];
+ }
+# sane awk should work simply with 'ARGC = 1', but not every awk
+# implementation is sane - big sigh!!
+ ARGV[1] = "-";
+ ARGC = 2;
+#
+# If you have ypmatch but is not RPC registered (some Linux systems
+# for example) comment out the next line.
+# "which ypmatch" | getline ypmatch;
+ if (1 != match(ypmatch, /^\//)) {
+ ypmatch = "";
+ }
+ pwdf = "/etc/passwd";
+}
+#check for names already present in input
+{
+ print $0;
+ for(name in names) {
+ if($1 ~ name) {
+ delete names[name];
+ }
+ }
+}
+END {
+ fmt = "%s:%s:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:";
+ fmt = fmt "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:%s:%s:%s\n";
+ for(name in names) {
+ while ((getline < pwdf) > 0) {
+ if ($1 == name) {
+ printf(fmt, $1, $3, $5, $6, $7);
+ close(pwdf);
+ notfound = "";
+ break;
+ }
+ notfound = "n";
+ }
+ $0 = "";
+ if (notfound && ypmatch) {
+# try to find in NIS databases
+ command = ypmatch " " name " passwd";
+ command | getline;
+ if (NF > 0) {
+ printf(fmt, $1, $3, $5, $6, $7);
+ }
+ close(command);
+ }
+ }
+}
+
diff --git a/source/script/installbin.sh b/source/script/installbin.sh
new file mode 100755
index 00000000000..633e6cb5bb2
--- /dev/null
+++ b/source/script/installbin.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+INSTALLPERMS=$1
+BASEDIR=$2
+BINDIR=$3
+LIBDIR=$4
+VARDIR=$5
+shift
+shift
+shift
+shift
+shift
+
+for d in $BASEDIR $BINDIR $LIBDIR $VARDIR; do
+if [ ! -d $d ]; then
+mkdir $d
+if [ ! -d $d ]; then
+ echo Failed to make directory $d
+ exit 1
+fi
+fi
+done
+
+
+for p in $*; do
+ echo Installing $p as $BINDIR/$p
+ if [ -f $BINDIR/$p ]; then
+ mv $BINDIR/$p $BINDIR/$p.old
+ fi
+ cp $p $BINDIR/$p
+ chmod $INSTALLPERMS $BINDIR/$p
+done
+
+
+cat << EOF
+======================================================================
+The binaries are installed. You may restore the old binaries (if there
+were any) using the command "make revert"
+======================================================================
+EOF
+
+exit 0
+
diff --git a/source/script/installman.sh b/source/script/installman.sh
new file mode 100755
index 00000000000..a79d157c5f5
--- /dev/null
+++ b/source/script/installman.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+MANDIR=$1
+SRCDIR=$2
+
+echo Installing man pages in $MANDIR
+
+for d in $MANDIR $MANDIR/man1 $MANDIR/man5 $MANDIR/man7 $MANDIR/man8; do
+if [ ! -d $d ]; then
+mkdir $d
+if [ ! -d $d ]; then
+ echo Failed to make directory $d
+ exit 1
+fi
+fi
+done
+
+cp $SRCDIR../docs/*.1 $MANDIR/man1
+cp $SRCDIR../docs/*.5 $MANDIR/man5
+cp $SRCDIR../docs/*.8 $MANDIR/man8
+cp $SRCDIR../docs/*.7 $MANDIR/man7
+echo Setting permissions on man pages
+chmod 0644 $MANDIR/man1/smbstatus.1
+chmod 0644 $MANDIR/man1/smbclient.1
+chmod 0644 $MANDIR/man1/smbrun.1
+chmod 0644 $MANDIR/man1/testparm.1
+chmod 0644 $MANDIR/man1/testprns.1
+chmod 0644 $MANDIR/man1/smbtar.1
+chmod 0644 $MANDIR/man5/smb.conf.5
+chmod 0644 $MANDIR/man7/samba.7
+chmod 0644 $MANDIR/man8/smbd.8
+chmod 0644 $MANDIR/man8/nmbd.8
+
+echo Man pages installed
+exit 0
+
diff --git a/source/script/mksmbpasswd.sh b/source/script/mksmbpasswd.sh
new file mode 100755
index 00000000000..6e592acd652
--- /dev/null
+++ b/source/script/mksmbpasswd.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+awk 'BEGIN {FS=":"
+ printf("#\n# SMB password file.\n#\n")
+ }
+{ printf( "%s:%s:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:%s:%s:%s\n", $1, $3, $5, $6, $7) }
+'
diff --git a/source/script/revert.sh b/source/script/revert.sh
new file mode 100755
index 00000000000..68b47bf39d0
--- /dev/null
+++ b/source/script/revert.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+BINDIR=$1
+shift
+
+for p in $*; do
+ if [ -f $BINDIR/$p.old ]; then
+ echo Restoring $BINDIR/$p.old as $BINDIR/$p
+ mv $BINDIR/$p $BINDIR/$p.new
+ mv $BINDIR/$p.old $BINDIR/$p
+ rm -f $BINDIR/$p.new
+ fi
+done
+
+exit 0
+
diff --git a/source/script/smbtar b/source/script/smbtar
new file mode 100644
index 00000000000..fc032ed41cd
--- /dev/null
+++ b/source/script/smbtar
@@ -0,0 +1,141 @@
+#!/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";;
+ *) # 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
+
+
diff --git a/source/script/updatesmbpasswd.sh b/source/script/updatesmbpasswd.sh
new file mode 100755
index 00000000000..1d7e0d7332f
--- /dev/null
+++ b/source/script/updatesmbpasswd.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+nawk 'BEGIN {FS=":"}
+{
+ if( $0 ~ "^#" ) {
+ print $0
+ } else if( (length($4) == 32) && (($4 ~ "^[0-9A-F]*$") || ($4 ~ "^[X]*$") || ( $4 ~ "^[*]*$"))) {
+ print $0
+ } else {
+ printf( "%s:%s:%s:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:", $1, $2, $3);
+ for(i = 4; i <= NF; i++)
+ printf("%s:", $i)
+ printf("\n")
+ }
+}'