[c5c522c] | 1 | #!/bin/bash |
---|
| 2 | #(c) DatuX 2008 |
---|
| 3 | #This script is Only usable on a Syn-3 server |
---|
| 4 | |
---|
| 5 | # configure |
---|
| 6 | configdir="/home/system/samba" |
---|
| 7 | |
---|
| 8 | server=`cat /home/system/samba/smb.conf | grep "netbios name" | sed 's/.*= //'` |
---|
| 9 | defaultscriptdir=$configdir/netlogon/default |
---|
| 10 | userscriptdir=$configdir/netlogon/users |
---|
| 11 | groupscriptdir=$configdir/netlogon/groups |
---|
| 12 | netlogondir=/home/shares/netlogon |
---|
| 13 | username=$1 |
---|
| 14 | batchfile=$netlogondir/$username.bat |
---|
| 15 | tmpbatchfile=$netlogondir/$username.tmp |
---|
| 16 | # Remove $username batch file |
---|
| 17 | if [ -e $batchfile ] |
---|
| 18 | then |
---|
| 19 | rm $batchfile || exit 1 |
---|
| 20 | fi |
---|
| 21 | |
---|
| 22 | # Remove garbage for tmp batch file |
---|
| 23 | if [ -e $tmpbatchfile ] |
---|
| 24 | then |
---|
| 25 | rm $tmpbatchfile || exit 1 |
---|
| 26 | fi |
---|
| 27 | |
---|
| 28 | |
---|
| 29 | # Add header file if it exists |
---|
| 30 | if [ -e $defaultscriptdir/header.txt ] |
---|
| 31 | then |
---|
| 32 | cat $defaultscriptdir/header.txt > $tmpbatchfile |
---|
| 33 | echo -en "\n" >> $tmpbatchfile |
---|
| 34 | else |
---|
| 35 | touch $tmpbatchfile |
---|
| 36 | fi |
---|
| 37 | |
---|
| 38 | # Add all group directives, incl secundairy groups |
---|
| 39 | for group in `groups $username` |
---|
| 40 | do |
---|
| 41 | if [ -e $groupscriptdir/$group.txt ] |
---|
| 42 | then |
---|
| 43 | cat $groupscriptdir/$group.txt >> $tmpbatchfile |
---|
| 44 | echo -en "\n" >> $tmpbatchfile |
---|
| 45 | fi |
---|
| 46 | done |
---|
| 47 | |
---|
| 48 | # Add specific user directives |
---|
| 49 | if [ -e $userscriptdir/$username.txt ] |
---|
| 50 | then |
---|
| 51 | cat $userscriptdir/$username.txt >> $tmpbatchfile |
---|
| 52 | echo -en "\n" >> $tmpbatchfile |
---|
| 53 | fi |
---|
| 54 | |
---|
| 55 | # Add footer |
---|
| 56 | if [ -e $defaultscriptdir/footer.txt ] |
---|
| 57 | then |
---|
| 58 | cat $defaultscriptdir/footer.txt >> $tmpbatchfile |
---|
| 59 | fi |
---|
| 60 | sed -e "s/SERVER/$server/g" -i $tmpbatchfile |
---|
| 61 | sed -e "s/USER/$username/g" -i $tmpbatchfile |
---|
| 62 | |
---|
| 63 | cd $netlogondir |
---|
| 64 | # Convert line breaks to Windows format (requires unix2dos utility) |
---|
| 65 | unix2dos -n $tmpbatchfile $batchfile |
---|
| 66 | |
---|
| 67 | # Clean up tmp files |
---|
| 68 | rm $tmpbatchfile |
---|
| 69 | |
---|
| 70 | exit |
---|