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 >
Text File  |  2014-01-31  |  4KB  |  148 lines

  1. #!/bin/bash
  2.  
  3. #
  4. # Shutting down nxserver, if available
  5. #
  6.  
  7. if [ -x /etc/NX/nxserver ];
  8. then
  9.   echo "Shutting down: nxserver"
  10.   /etc/NX/nxserver --shutdown > /dev/null 2>&1
  11. fi
  12.  
  13.  
  14. #
  15. # Unload main localnxserver agent
  16. #
  17.  
  18.   out=`ps aux | grep loginwindow.app | grep -v grep | grep -m 1 loginwindow.app`
  19.   if [ "x${out}" != "x" ] && [ -f /Library/LaunchAgents/com.nomachine.localnxserver.plist ];
  20.   then
  21.     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")}'`
  22.     out=`$command 2>&1`
  23.     if [ $? = 0 ];
  24.     then
  25.       echo "Stopped service: com.nomachine.localnxserver.plist"
  26.     else
  27.       echo "Cannot stop service: com.nomachine.localnxserver.plist: $out"
  28.     fi
  29.  
  30.     rm -f /Library/LaunchAgents/com.nomachine.localnxserver.plist
  31.   fi
  32.  
  33.  
  34. #
  35. # Unload running daemons
  36. #
  37.  
  38.   for nxdaemon in server nxd nxhtd nxusb uninstall; do
  39.  
  40.     if [ -f /Library/LaunchDaemons/com.nomachine.${nxdaemon}.plist ];
  41.     then
  42.  
  43.       out=`launchctl unload /Library/LaunchDaemons/com.nomachine.${nxdaemon}.plist 2>&1`
  44.       if [ $? = 0 ];
  45.       then
  46.         echo "Stopped daemon: com.nomachine.${nxdaemon}.plist"
  47.       else
  48.         echo "Cannot stop daemon: com.nomachine.${nxdaemon}.plist: $out"
  49.       fi
  50.  
  51.      rm -f /Library/LaunchDaemons/com.nomachine.${nxdaemo}.plist
  52.  
  53.     fi
  54.  
  55.   done
  56.  
  57.  
  58. #
  59. # Unload kexts daemons
  60. #
  61.  
  62.   for nxkext in nxusb_helper nxtun nxfs nxaudio nxnetwork; do
  63.  
  64.     if [ -d /System/Library/Extensions/${nxkext}.kext ];
  65.     then
  66.       KEXTST=`kextstat | grep "nomachine.*${nxkext}" 2>/dev/null`
  67.  
  68.       if [ "${KEXTST}x" != "x" ] && [ -d /System/Library/Extensions/${nxkext}.kext ];
  69.       then
  70.         out=`kextunload /System/Library/Extensions/${nxkext}.kext 2>&1`
  71.  
  72.         if [ $? = 0 ];
  73.         then
  74.           echo "Unloaded kext: ${nxkext}.kext"
  75.         else
  76.           echo "Cannot unload kext (first attempt): ${nxkext}.kext: $out"
  77.         fi
  78.       fi
  79.     fi
  80.  
  81.     if [ -d /System/Library/StartupItems/${nxkext} ];
  82.     then
  83.       rm -rf /System/Library/StartupItems/${nxkext}
  84.     fi
  85.  
  86.     if [ -d /Library/Extensions/${nxkext}.kext ];
  87.     then
  88.       KEXTST=`kextstat | grep "nomachine.*${nxkext}"`
  89.  
  90.       if [ "${KEXTST}x" != "x" ] && [ -d  /Library/Extensions/${nxkext}.kext ];
  91.       then
  92.         out=`kextunload /Library/Extensions/${nxkext}.kext 2>&1`
  93.         if [ $? = 0 ];
  94.         then
  95.           echo "Unloaded kext: ${nxkext}.kext"
  96.         else
  97.           echo "Cannot unload kext: ${nxkext}.kext: $out"
  98.  
  99.         fi
  100.       fi
  101.     fi
  102.  
  103.     if [ -d /Library/StartupItems/${nxkext} ];
  104.     then
  105.       rm -rf /Library/StartupItems/${nxkext}
  106.     fi
  107.  
  108.   done
  109.  
  110.  
  111. #
  112. # Unload other kexts daemons
  113. #
  114.  
  115.   for nxkext in nxaudio nxusb.io nxusb; do
  116.     KEXTST=`kextstat | grep "nomachine.*${nxkext}"`
  117.  
  118.     if [ "${KEXTST}x" != "x" ];
  119.     then
  120.       out=`kextunload -b com.nomachine.driver.${nxkext} 2>&1`
  121.       if [ $? = 0 ];
  122.       then
  123.         echo "Unloaded kext: com.nomachine.driver.${nxkext}"
  124.       else
  125.         echo "Cannot unload kext: com.nomachine.driver.${nxkext}: $out"
  126.       fi
  127.     fi
  128.  
  129.   done
  130.  
  131.  
  132.  
  133. #
  134. # Backup libav and libx264 libraries to avoid removing during update
  135. #
  136.  
  137. if [ -f /Applications/NoMachine.app/Contents/Frameworks/lib/libav.dylib ];
  138. then
  139.   cp -pPR /Applications/NoMachine.app/Contents/Frameworks/lib/libav.dylib /Applications/NoMachine.app/Contents/Frameworks/lib/libav.dylib.save
  140. fi
  141.  
  142. if [ -f /Applications/NoMachine.app/Contents/Frameworks/lib/libx264.dylib ];
  143. then
  144.   cp -pPR /Applications/NoMachine.app/Contents/Frameworks/lib/libx264.dylib  /Applications/NoMachine.app/Contents/Frameworks/lib/libx264.dylib.save
  145. fi
  146.  
  147.  
  148.