source: npl/fileserver/advanced_netlogon/netlogon_script_creator @ c5c522c

gcc484ntopperl-5.22
Last change on this file since c5c522c was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

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