home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
cs.rhul.ac.uk
/
www.cs.rhul.ac.uk.zip
/
www.cs.rhul.ac.uk
/
pub
/
NX
/
nomachine-mac-osx.dmg
/
NoMachine.pkg
/
nxserver.pkg
/
Scripts
/
Scripts~
/
preinstall
< prev
next >
Wrap
Text File
|
2014-01-31
|
4KB
|
148 lines
#!/bin/bash
#
# Shutting down nxserver, if available
#
if [ -x /etc/NX/nxserver ];
then
echo "Shutting down: nxserver"
/etc/NX/nxserver --shutdown > /dev/null 2>&1
fi
#
# Unload main localnxserver agent
#
out=`ps aux | grep loginwindow.app | grep -v grep | grep -m 1 loginwindow.app`
if [ "x${out}" != "x" ] && [ -f /Library/LaunchAgents/com.nomachine.localnxserver.plist ];
then
command=`ps aux | grep loginwindow.app | grep -v grep | grep -m 1 loginwindow.app | awk -v cmdsudo=sudo -v cmdlaunch=launchctl '{print (cmdsudo " " cmdlaunch " bsexec "$2" " cmdsudo " -u "$1" " cmdlaunch " unload -S Aqua /Library/LaunchAgents/com.nomachine.localnxserver.plist")}'`
out=`$command 2>&1`
if [ $? = 0 ];
then
echo "Stopped service: com.nomachine.localnxserver.plist"
else
echo "Cannot stop service: com.nomachine.localnxserver.plist: $out"
fi
rm -f /Library/LaunchAgents/com.nomachine.localnxserver.plist
fi
#
# Unload running daemons
#
for nxdaemon in server nxd nxhtd nxusb uninstall; do
if [ -f /Library/LaunchDaemons/com.nomachine.${nxdaemon}.plist ];
then
out=`launchctl unload /Library/LaunchDaemons/com.nomachine.${nxdaemon}.plist 2>&1`
if [ $? = 0 ];
then
echo "Stopped daemon: com.nomachine.${nxdaemon}.plist"
else
echo "Cannot stop daemon: com.nomachine.${nxdaemon}.plist: $out"
fi
rm -f /Library/LaunchDaemons/com.nomachine.${nxdaemo}.plist
fi
done
#
# Unload kexts daemons
#
for nxkext in nxusb_helper nxtun nxfs nxaudio nxnetwork; do
if [ -d /System/Library/Extensions/${nxkext}.kext ];
then
KEXTST=`kextstat | grep "nomachine.*${nxkext}" 2>/dev/null`
if [ "${KEXTST}x" != "x" ] && [ -d /System/Library/Extensions/${nxkext}.kext ];
then
out=`kextunload /System/Library/Extensions/${nxkext}.kext 2>&1`
if [ $? = 0 ];
then
echo "Unloaded kext: ${nxkext}.kext"
else
echo "Cannot unload kext (first attempt): ${nxkext}.kext: $out"
fi
fi
fi
if [ -d /System/Library/StartupItems/${nxkext} ];
then
rm -rf /System/Library/StartupItems/${nxkext}
fi
if [ -d /Library/Extensions/${nxkext}.kext ];
then
KEXTST=`kextstat | grep "nomachine.*${nxkext}"`
if [ "${KEXTST}x" != "x" ] && [ -d /Library/Extensions/${nxkext}.kext ];
then
out=`kextunload /Library/Extensions/${nxkext}.kext 2>&1`
if [ $? = 0 ];
then
echo "Unloaded kext: ${nxkext}.kext"
else
echo "Cannot unload kext: ${nxkext}.kext: $out"
fi
fi
fi
if [ -d /Library/StartupItems/${nxkext} ];
then
rm -rf /Library/StartupItems/${nxkext}
fi
done
#
# Unload other kexts daemons
#
for nxkext in nxaudio nxusb.io nxusb; do
KEXTST=`kextstat | grep "nomachine.*${nxkext}"`
if [ "${KEXTST}x" != "x" ];
then
out=`kextunload -b com.nomachine.driver.${nxkext} 2>&1`
if [ $? = 0 ];
then
echo "Unloaded kext: com.nomachine.driver.${nxkext}"
else
echo "Cannot unload kext: com.nomachine.driver.${nxkext}: $out"
fi
fi
done
#
# Backup libav and libx264 libraries to avoid removing during update
#
if [ -f /Applications/NoMachine.app/Contents/Frameworks/lib/libav.dylib ];
then
cp -pPR /Applications/NoMachine.app/Contents/Frameworks/lib/libav.dylib /Applications/NoMachine.app/Contents/Frameworks/lib/libav.dylib.save
fi
if [ -f /Applications/NoMachine.app/Contents/Frameworks/lib/libx264.dylib ];
then
cp -pPR /Applications/NoMachine.app/Contents/Frameworks/lib/libx264.dylib /Applications/NoMachine.app/Contents/Frameworks/lib/libx264.dylib.save
fi