]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:script: Reformat shell scripts
authorAndreas Schneider <asn@samba.org>
Mon, 21 Feb 2022 13:11:19 +0000 (14:11 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 3 Mar 2022 01:53:16 +0000 (01:53 +0000)
shfmt -f source3/script/ | xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Thu Mar  3 01:53:16 UTC 2022 on sn-devel-184

source3/script/creategroup
source3/script/mknissmbpasswd.sh
source3/script/mknissmbpwdtbl.sh
source3/script/mksyms.sh
source3/script/smbtar

index 01fb06594441e6553c00496008442780e0001f28..1e2486744a8576cefd0508627f38a900bc3bc102 100755 (executable)
@@ -5,23 +5,21 @@
 # then create a random group and print the numeric group id.
 #
 # Note that this is only an example and assumes /dev/urandom.
-# 
+#
 # Volker
 
 GROUPNAME="$1"
 ITERS=0
 
-while ! /usr/sbin/groupadd "$GROUPNAME" > /dev/null 2>&1
-do
-    # we had difficulties creating that group. Maybe the name was
-    # too weird, or it already existed. Create a random name.
-    GROUPNAME=nt-$(dd if=/dev/urandom bs=16 count=1 2>/dev/null | md5sum | cut -b 1-5)
-    ITERS=$(expr "$ITERS" + 1)
-    if [ "$ITERS" -gt 10 ]
-    then
-       # Too many attempts
-       exit 1
-    fi
+while ! /usr/sbin/groupadd "$GROUPNAME" >/dev/null 2>&1; do
+       # we had difficulties creating that group. Maybe the name was
+       # too weird, or it already existed. Create a random name.
+       GROUPNAME=nt-$(dd if=/dev/urandom bs=16 count=1 2>/dev/null | md5sum | cut -b 1-5)
+       ITERS=$(expr "$ITERS" + 1)
+       if [ "$ITERS" -gt 10 ]; then
+               # Too many attempts
+               exit 1
+       fi
 done
 
 getent group | grep ^"$GROUPNAME": | cut -d : -f 3
index a94c963bdcee44439caa4d5fb5b64817d5cde60f..2fea32c5e53ac453ac4f1069cc41aa48ed204759 100755 (executable)
@@ -5,27 +5,24 @@
 # Script to import smbpasswd file into the smbpasswd NIS+ table. Reads
 # from stdin the smbpasswd file.
 #
-while true
-do
-  read row
-  if [ -z "$row" ]
-  then
-    break
-  fi
+while true; do
+       read row
+       if [ -z "$row" ]; then
+               break
+       fi
 
-  if [ "`echo $row | cut -c1`" = "#" ]
-  then
-    continue
-  fi
+       if [ "$(echo $row | cut -c1)" = "#" ]; then
+               continue
+       fi
 
-  nistbladm -a \
-    name=\"`echo $row | cut -d: -f1`\" \
-    uid=\"`echo $row | cut -d: -f2`\" \
-    lmpwd=\"`echo $row | cut -d: -f3`\" \
-    ntpwd=\"`echo $row | cut -d: -f4`\" \
-    acb=\"`echo $row | cut -d: -f5`\" \
-    pwdlset_t=\"`echo $row | cut -d: -f6`\" \
-    gcos=\"`echo $row | cut -d: -f7`\" \
-    home=\"`echo $row | cut -d: -f8`\" \
-    shell=\"`echo $row | cut -d: -f9`\"  smbpasswd.org_dir.`nisdefaults -d`
+       nistbladm -a \
+               name=\"$(echo $row | cut -d: -f1)\" \
+               uid=\"$(echo $row | cut -d: -f2)\" \
+               lmpwd=\"$(echo $row | cut -d: -f3)\" \
+               ntpwd=\"$(echo $row | cut -d: -f4)\" \
+               acb=\"$(echo $row | cut -d: -f5)\" \
+               pwdlset_t=\"$(echo $row | cut -d: -f6)\" \
+               gcos=\"$(echo $row | cut -d: -f7)\" \
+               home=\"$(echo $row | cut -d: -f8)\" \
+               shell=\"$(echo $row | cut -d: -f9)\" smbpasswd.org_dir.$(nisdefaults -d)
 done
index a9b34ff9a75d867a3ad5a3a96bbf50070061f2a7..d7291bbe8f359557fcf222a6c64bfc005176051a 100755 (executable)
@@ -6,37 +6,36 @@
 #
 
 nistbladm \
-    -D access=og=rmcd,nw= -c \
-    -s : smbpasswd_tbl \
-       name=S,nogw=r \
-       uid=S,nogw=r \
-               user_rid=S,nogw=r \
-               smb_grpid=,nw+r \
-               group_rid=,nw+r \
-               acb=,nw+r \
-                         \
-       lmpwd=C,nw=,g=r,o=rm \
-       ntpwd=C,nw=,g=r,o=rm \
-                                    \
-               logon_t=,nw+r \
-               logoff_t=,nw+r \
-               kick_t=,nw+r \
-               pwdlset_t=,nw+r \
-               pwdlchg_t=,nw+r \
-               pwdmchg_t=,nw+r \
-                               \
-               full_name=,nw+r \
-               home_dir=,nw+r \
-               dir_drive=,nw+r \
-               logon_script=,nw+r \
-               profile_path=,nw+r \
-               acct_desc=,nw+r \
-               workstations=,nw+r \
-                                  \
-               hours=,nw+r \
-       smbpasswd.org_dir.`nisdefaults -d`
+       -D access=og=rmcd,nw= -c \
+       -s : smbpasswd_tbl \
+       name=S,nogw=r \
+       uid=S,nogw=r \
+       user_rid=S,nogw=r \
+       smb_grpid=,nw+r \
+       group_rid=,nw+r \
+       acb=,nw+r \
+       \
+       lmpwd=C,nw=,g=r,o=rm \
+       ntpwd=C,nw=,g=r,o=rm \
+       \
+       logon_t=,nw+r \
+       logoff_t=,nw+r \
+       kick_t=,nw+r \
+       pwdlset_t=,nw+r \
+       pwdlchg_t=,nw+r \
+       pwdmchg_t=,nw+r \
+       \
+       full_name=,nw+r \
+       home_dir=,nw+r \
+       dir_drive=,nw+r \
+       logon_script=,nw+r \
+       profile_path=,nw+r \
+       acct_desc=,nw+r \
+       workstations=,nw+r \
+       \
+       hours=,nw+r \
+       smbpasswd.org_dir.$(nisdefaults -d)
 
-nisgrpadm -c smb.`nisdefaults -d`
-
-nischgrp smb.`nisdefaults -d` smbpasswd.org_dir.`nisdefaults -d`
+nisgrpadm -c smb.$(nisdefaults -d)
 
+nischgrp smb.$(nisdefaults -d) smbpasswd.org_dir.$(nisdefaults -d)
index 7fb4031e2bf8db7a8e2a813e63ea7fd67777e370..2a412ec8bdf2497d4cb58118ccaa3ac2bdb0a0f6 100755 (executable)
 # Copyright (C) 2008 Michael Adam <obnox@samba.org>
 #
 
-LANG=C; export LANG
-LC_ALL=C; export LC_ALL
-LC_COLLATE=C; export LC_COLLATE
-
-if [ $# -lt 2 ]
-then
-  echo "Usage: $0 awk output_file header_files"
-  exit 1
+LANG=C
+export LANG
+LC_ALL=C
+export LC_ALL
+LC_COLLATE=C
+export LC_COLLATE
+
+if [ $# -lt 2 ]; then
+       echo "Usage: $0 awk output_file header_files"
+       exit 1
 fi
 
 awk="$1"
@@ -28,18 +30,17 @@ symsfile="$1"
 shift
 symsfile_tmp="$symsfile.$$.tmp~"
 
-proto_src="`echo $@ | tr ' ' '\n' | sort | uniq `"
+proto_src="$(echo $@ | tr ' ' '\n' | sort | uniq)"
 
 echo creating $symsfile
 
-mkdir -p `dirname $symsfile`
+mkdir -p $(dirname $symsfile)
 
-${awk} -f `dirname $0`/mksyms.awk $proto_src > $symsfile_tmp
+${awk} -f $(dirname $0)/mksyms.awk $proto_src >$symsfile_tmp
 
-if cmp -s $symsfile $symsfile_tmp 2>/dev/null
-then
-  echo "$symsfile unchanged"
-  rm $symsfile_tmp
+if cmp -s $symsfile $symsfile_tmp 2>/dev/null; then
+       echo "$symsfile unchanged"
+       rm $symsfile_tmp
 else
-  mv $symsfile_tmp $symsfile
+       mv $symsfile_tmp $symsfile
 fi
index e86448cbf6ca5a6c5b8ffbea85e3a0f53ff01fe4..439d0853d146c3ff9663e80d601ae63004949cdf 100644 (file)
 # being backed up.
 
 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";;
+# 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"
+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
+username=$LOGNAME     # Default: same user name as in *nix
+verbose="2>/dev/null" # Default: no echo to stdout
 log="-d 2"
 newer=""
 newerarg=""
@@ -39,10 +40,11 @@ tarargs=""
 cdcmd="\\"
 tapefile=${TAPE-tar.out}
 
-Usage(){
-    ex=$1
-    shift
-echo >&2 "Usage: `basename $0` [<options>] [<include/exclude files>]
+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
@@ -53,114 +55,127 @@ Options:         (Description)                 (Default)
   -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`
+  -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`
+  -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
+       echo >&2 "$@"
+       exit $ex
 }
 
 # echo Params count: $#
 
-# DEC OSF AKA Digital UNIX does not seem to return a value in OPTIND if 
+# DEC OSF AKA Digital UNIX does not seem to return a value in OPTIND if
 # there are no command line params, so protect us against that ...
 if [ $# = 0 ]; then
 
-  Usage 2 "Please enter a command line parameter!"
+       Usage 2 "Please enter a command line parameter!"
 
 fi
 
 while getopts riavl: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}ga
-      clientargs="-c 'tarmode inc'"
-      ;;
-   a) # [a]rchive
-      tarargs=${tarargs}a
-      ;;
-   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
-       newerarg="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="$OPTARG"
-      case "$OPTARG" in
-       [0-9]*) ;;
-       *)      echo >&2 "$0: Error, block size not numeric: -b $OPTARG"
-               exit 1
-      esac
-      blocksizearg="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=""
-      tarargs=${tarargs}v
-      ;;
-   '?') # any other switch
-       Usage 2 "Invalid switch specified - abort."
-      ;;
-  esac
+       case $c in
+       r) # [r]estore to Windows (instead of the default "Save from Windows")
+               tarcmd="x"
+               ;;
+       i) # [i]ncremental
+               tarargs=${tarargs}ga
+               clientargs="-c 'tarmode inc'"
+               ;;
+       a) # [a]rchive
+               tarargs=${tarargs}a
+               ;;
+       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
+                       newerarg="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="$OPTARG"
+               case "$OPTARG" in
+               [0-9]*) ;;
+               *)
+                       echo >&2 "$0: Error, block size not numeric: -b $OPTARG"
+                       exit 1
+                       ;;
+               esac
+               blocksizearg="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=""
+               tarargs=${tarargs}v
+               ;;
+       '?') # any other switch
+               Usage 2 "Invalid switch specified - abort."
+               ;;
+       esac
 done
 
-shift `expr $OPTIND - 1`
+shift $(expr $OPTIND - 1)
 
 if [ "$server" = "" ] || [ "$service" = "" ]; then
-  Usage 1 "No server or no service specified - abort."
+       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"
+       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
 
 tarargs=${tarargs}${blocksizearg}${newerarg}
 
 eval $SMBCLIENT "'\\\\$server\\$service'" "'$password'" -U "'$username'" \
--E $log -D "'$cdcmd'" ${clientargs} \
--T${tarcmd}${tarargs} $blocksize $newer $tapefile '${1+"$@"}' $verbose
+       -E $log -D "'$cdcmd'" ${clientargs} \
+       -T${tarcmd}${tarargs} $blocksize $newer $tapefile '${1+"$@"}' $verbose