[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 #!/bin/bash 2 # Run and Kill share's services defined in /usr/share/se3/shares/%NAME% 3 # Works like Sys V init 4 5 RC_SHARE=/usr/share/se3/shares/shares.d 6 VERBOSE=0 7 LOGON=0 8 LOGOUT=0 9 10 function usage { 11 echo "usage: $0 -v [-s|-k] share user computer address arch" 12 echo " -s : call logon scripts for share " 13 echo " -k : call logout scripts for share " 14 echo " -v : Verbose " 15 exit $1; 16 } 17 18 function rc_logon { 19 20 ERROR=0 21 for script in "$RC_SHARE/$1/$5/"S* 22 do 23 [ ! -x $script ] && continue 24 if [ "$VERBOSE" == "1" ] 25 then 26 echo "Running: $(basename $script) $2 $3 $4 $5" >> /var/log/samba/debug.log 27 fi 28 $script $2 $3 $4 $5 29 if (( $? != 0 )) 30 then 31 ERROR=1 32 fi 33 done 34 return $ERROR 35 } 36 37 function rc_logout { 38 ERROR=0 39 for script in "$RC_SHARE/$1/$5"/K* 40 do 41 [ ! -x $script ] && continue 42 if [ "$VERBOSE" == "1" ] 43 then 44 echo "Running: $(basename $script) $2 $3 $4 $5" >> /var/log/samba/debug.log 45 fi 46 $script $2 $3 $4 $5 47 if (( $? != 0 )) 48 then 49 ERROR=1 50 fi 51 done 52 return $ERROR 53 54 } 55 56 while getopts ":skv" cmd 57 do 58 case $cmd in 59 s) LOGON=1 ;; 60 k) LOGOUT=1 ;; 61 v) VERBOSE=1 ;; 62 ?) echo "bad option!" 63 usage 1;; 64 esac 65 done 66 67 shift $(($OPTIND-1)) 68 if (( $# != 5 )) 69 then 70 usage 1 71 fi 72 73 # filtrage 74 user=$(echo "$2" | tr 'A-Z' 'a-z' | sed "s/[\$_]$//") 75 machine=$(echo "$3" | tr 'A-Z' 'a-z' | sed "s/[\$_]$//") 76 77 # on teste si windows fait des siennes 78 if [ "$user" == "$machine" ] 79 then 80 exit 0 81 elif [ "$user" == "adminse3" ] 82 then 83 exit 0 84 fi 85 86 # ok, on transmet les infos sans transformation 87 if [ "$LOGON" == "1" ] 88 then 89 rc_logon $1 $2 $3 $4 $5 90 elif [ "$LOGOUT" == "1" ] 91 then 92 rc_logout $1 $2 $3 $4 $5 93 fi 94 exit $?
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |