#!/bin/bash #(c) DatuX 2008 #This script is Only usable on a Syn-3 server # configure configdir="/home/system/samba" server=`cat /home/system/samba/smb.conf | grep "netbios name" | sed 's/.*= //'` defaultscriptdir=$configdir/netlogon/default userscriptdir=$configdir/netlogon/users groupscriptdir=$configdir/netlogon/groups netlogondir=/home/shares/netlogon username=$1 batchfile=$netlogondir/$username.bat tmpbatchfile=$netlogondir/$username.tmp # Remove $username batch file if [ -e $batchfile ] then rm $batchfile || exit 1 fi # Remove garbage for tmp batch file if [ -e $tmpbatchfile ] then rm $tmpbatchfile || exit 1 fi # Add header file if it exists if [ -e $defaultscriptdir/header.txt ] then cat $defaultscriptdir/header.txt > $tmpbatchfile echo -en "\n" >> $tmpbatchfile else touch $tmpbatchfile fi # Add all group directives, incl secundairy groups for group in `groups $username` do if [ -e $groupscriptdir/$group.txt ] then cat $groupscriptdir/$group.txt >> $tmpbatchfile echo -en "\n" >> $tmpbatchfile fi done # Add specific user directives if [ -e $userscriptdir/$username.txt ] then cat $userscriptdir/$username.txt >> $tmpbatchfile echo -en "\n" >> $tmpbatchfile fi # Add footer if [ -e $defaultscriptdir/footer.txt ] then cat $defaultscriptdir/footer.txt >> $tmpbatchfile fi sed -e "s/SERVER/$server/g" -i $tmpbatchfile sed -e "s/USER/$username/g" -i $tmpbatchfile cd $netlogondir # Convert line breaks to Windows format (requires unix2dos utility) unix2dos -n $tmpbatchfile $batchfile # Clean up tmp files rm $tmpbatchfile exit