Hi all,
I have an issue with one of my scripts called fog.postclient which will create the directory “/ntfs/Windows/Setup/Scripts/” and then copy across the FogService.msi into it, as well as various other things (like moving the Sophos installer across, etc.). This has worked perfectly fine in the past with no issues whatsoever, and nothing has been changed in the script. Fog.Postdownload calls two scripts: fog.postclient, and fog.postdrivers. The drivers script works great.
However, I’ve found recently that nothing in the fog.postclient works. Going by past experience and the recommendations here, I set a spare laptop to image as a debug task. When in debug mode, I call fog.postdownloads and it complains that it can’t see the postdrivers script. I get the error:
./fog.postdownload: line 7: .: fog.postdrivers: file not found
Yet when running the fog.postclient script, it seems to work as it echoes ‘Non-Windows Deployment’ (which is a part of the script), but nothing else works - it doesn’t create the directory, or copy across the .msi file.
The aforementioned scripts are below. I would appreciate any assistance/guidance on this issue.
fog.postdownload:
#!/bin/sh
## This file serves as a starting point to call your custom postimaging scripts.
## <SCRIPTNAME> should be changed to the script you're planning to use.
## Syntax of post download scripts are
#. ${postdownpath}<SCRIPTNAME>
. ${postdownpath}fog.postdrivers
. ${postdownpath}fog.postclient
fog.postclient:
#!/bin/bash
. /usr/share/fog/lib/funcs.sh
case $osid in
5|6|7|9)
clear
[[ ! -d /ntfs ]] && mkdir -p /ntfs
getHardDisk
if [[ -z $hd ]]; then
handleError "Could not find hdd to use"
fi
getPartitions $hd
for part in $parts; do
umount /ntfs >/dev/null 2>&1
fsTypeSetting "$part"
case $fstype in
ntfs)
dots "Testing partition $part"
ntfs-3g -o force,rw $part /ntfs
ntfsstatus="$?"
if [[ ! $ntfsstatus -eq 0 ]]; then
echo "Skipped"
continue
fi
if [[ ! -d /ntfs/windows && ! -d /ntfs/Windows && ! -d /ntfs/WINDOWS ]]; then
echo "Not found"
umount /ntfs >/dev/null 2>&1
continue
fi
echo "Success"
break
;;
*)
echo " * Partition $part not NTFS filesystem"
;;
esac
done
if [[ ! $ntfsstatus -eq 0 ]]; then
echo "Failed"
debugPause
handleError "Failed to mount $part ($0)\n Args: $*"
# Give the reader a chance to see what the error was
sleep 12;
# Terminate the post install script
exit 1;
fi
# This next section determines the IP of the host system, cuts the last two octects and sets the FOGIP variable to
# the correct IP address of the FOG server depending on the location (as the subnets are designed by location - i.e.
# 10.1 is for the UK, 10.2 is for the US, etc.)
myip=$(ip route get 8.8.8.8 | awk 'NR==1 {print $NF}' | cut -d "." -f1-2)
case "${myip}" in
10.1)
sitecode="UK";
timezone="GMT Standard Time";
FOGIP="10.1.0.102";
sitelocal="en-GB";
uilang="en-US";
;;
10.2)
sitecode="US";
timezone="Eastern Standard Time";
FOGIP="10.2.1.103";
sitelocal="en-US";
uilang="en-US";
;;
*)
# Default code for the unknowns - we set the FOGIP to the development server in the UK.
sitecode="CompanyName";
timezone="Greenwich Mean Time";
FOGIP="10.1.0.102";
sitelocal="en-GB";
uilang="en-GB";
;;
esac
# Check if the direcotry /ntfs/Windows/Setup/Scripts exists, and if not then create it.
if [ ! -d "ntfs/Windows/Setup/Scripts" ]
then
mkdir /ntfs/Windows/Setup/Scripts
fi
# Copy the FOGService.msi across to the target computer.
[[ -f ${postdownpath}FOGService.msi ]] && cp ${postdownpath}FOGService.msi "/ntfs/Windows/Setup/Scripts/FOGService.msi"
# Check if the file SophosInstaller.exe exists in the source folder and then copy it to the destination on
# the C: drive.
if [ -f "/images/drivers/Common/SophosInstall.exe" ]; then
cp /images/drivers/Common/SophosInstall.exe /ntfs/Windows/Setup/SophosInstall.exe
fi
# Check if the file SetupComplete.cmd exists in the source folder and then copy it to the destination on
# the C: drive.
if [ -f "/images/drivers/Common/SetupComplete.cmd" ]; then
cp /images/drivers/Common/SetupComplete.cmd /ntfs/Windows/Setup/Scripts/SetupComplete.cmd
# append the msiexec command to the end of the setupComplete.cmd file
echo "msiexec.exe /i %windir%\Setup\Scripts\FOGService.msi /quiet USETRAY=\"0\" WEBADDRESS=\"${FOGIP}\" " >> /ntfs/Windows/Setup/Scripts/SetupComplete.cmd
# Re-enable the FOGService
echo "sc config FOGService start= auto
del /Q /F c:\windows\system32\sysrep\unattend.xml
del /Q /F c:\windows\panther\unattend.xml
shutdown -t 0 -r" >> /ntfs/Windows/Setup/Scripts/SetupComplete.cmd
# just in case we edited the setupcomplete.cmd file in unix lets filter it to make it DOS compatible
unix2dos /ntfs/Windows/Setup/Scripts/SetupComplete.cmd
fi
# now lets use the timezone variable and update the unattend.xml file. You may need to edit the variable to
# point to where your unattend.xml file exists. Remember case IS important.
unattendfile="/ntfs/Windows/Panther/unattend.xml";
sed -i -e "s#<TimeZone>\([^<][^<]*\)</TimeZone>#<TimeZone>$timezone</TimeZone>#gi" $unattendfile
# now lets deal with the internationalization stuff in the unattend.xml file
sed -i -e "s#<InputLocale>\([^<][^<]*\)</InputLocale>#<InputLocale>$sitelocal</InputLocale>#gi" $unattendfile
sed -i -e "s#<SystemLocale>\([^<][^<]*\)</SystemLocale>#<SystemLocale>$sitelocal</SystemLocale>#gi" $unattendfile
sed -i -e "s#<UILanguage>\([^<][^<]*\)</UILanguage>#<UILanguage>$uilang</UILanguage>#gi" $unattendfile
sed -i -e "s#<UserLocale>\([^<][^<]*\)</UserLocale>#<UserLocale>$sitelocal</UserLocale>#gi" $unattendfile
;;
*)
echo "Non-Windows Deployment"
debugPause
return
;;
esac
Edit: Also, before I get asked, the FOG version is the following:
Running Version 1.5.0-RC-8
SVN Revision: 6080