basistest-svn.sh
Go to the documentation of this file.
00001 #! /bin/bash 00002 __FILE__="$(cd -P -- "$(dirname -- "$BASH_SOURCE")" && pwd -P)/$(basename -- "$BASH_SOURCE")"; if [[ -n "$SGE_ROOT" ]] && [[ $__FILE__ =~ $SGE_ROOT/.* ]] && [[ -n "${BASIS_DIR}" ]] && [[ -f "${BASIS_DIR}/bin/basistest-svn.sh" ]]; then __FILE__="${BASIS_DIR}/bin/basistest-svn.sh"; fi; i=0; lnk="$__FILE__"; while [[ -h "$lnk" ]] && [[ $i -lt 100 ]]; do dir=`dirname -- "$lnk"`; lnk=`readlink -- "$lnk"`; lnk=`cd "$dir" && cd $(dirname -- "$lnk") && pwd`/`basename -- "$lnk"`; let i++; done; [[ $i -lt 100 ]] && __FILE__="$lnk"; unset -v i dir lnk; __DIR__="$(dirname -- "$__FILE__")"; BASIS_BASH_UTILITIES="$__DIR__/bash/basis/basis.sh"; BASHPATH="$__DIR__/.:$__DIR__/bash:$BASHPATH" # <-- added by BASIS 00003 ############################################################################## 00004 # @file basistest-svn.sh 00005 # @brief Wrapper script for Subversion svn command. 00006 # 00007 # This script is used as wrapper for the svn command to enable automated 00008 # software testing at our lab. In general, anonymous access to the Subversion 00009 # repositories is not permitted. Only the svnuser is allowed to do so. 00010 # Hence, a wrapper script was implemented which is only readable by the 00011 # svnuser where the password is hard code. Moreover, only the svnuser can 00012 # execute this script. The swtest user on the other side is allowed to run 00013 # this script as svnuser via sudoers list. 00014 # 00015 # Copyright (c) 2011 University of Pennsylvania. All rights reserved.<br /> 00016 # See https://www.cbica.upenn.edu/sbia/software/license.html or COPYING file. 00017 # 00018 # Contact: SBIA Group <sbia-software at uphs.upenn.edu> 00019 # @ingroup Tools 00020 ############################################################################## 00021 00022 . ${BASIS_BASH_UTILITIES} || exit 1 00023 00024 args=() 00025 verbose=0 00026 00027 while [ $# -gt 0 ]; do 00028 case "$1" in 00029 --verbose|-v) 00030 (( verbose++ )) 00031 ;; 00032 00033 --help|-h) 00034 exename exec_name 00035 echo "Usage:" 00036 echo " ${exec_name} [svn options/arguments]" 00037 echo " ${exec_name} [options]" 00038 echo 00039 echo "Description:" 00040 echo " This command is used as a wrapper for the svn command to enable" 00041 echo " automated software testing at SBIA where anonymous Subversion" 00042 echo " access is generally not permitted." 00043 echo 00044 echo "Options:" 00045 echo " --help, -h Print help and exit." 00046 echo " --helpshort Print short help and exit." 00047 echo " --version Print version information and exit." 00048 echo 00049 print_contact 00050 exit 0 00051 ;; 00052 00053 --helpshort) 00054 exename exec_name 00055 echo "Usage:" 00056 echo " ${exec_name} [svn options/arguments]" 00057 echo " ${exec_name} [options]" 00058 echo 00059 echo "Options:" 00060 echo " --help, -h Print help and exit." 00061 echo " --helpshort Print short help and exit." 00062 echo " --version Print version information and exit." 00063 echo 00064 print_contact 00065 exit 0 00066 ;; 00067 00068 --version) 00069 print_version '' 00070 exit 0 00071 ;; 00072 *) 00073 args=("${args[@]}" "$1") 00074 ;; 00075 esac 00076 shift 00077 done 00078 00079 # simply call the wrapper script with the password encoded as svnuser 00080 cmd=(sudo -u svnuser /bin/sh /sbia/home/svn/bin/svnwrap "${args[@]}") 00081 if [ $verbose -gt 0 ]; then 00082 echo "$ ${cmd[@]}" 00083 fi 00084 exec "${cmd[@]}"