简体   繁体   English

无法在OS X Lion上的启动/关闭中启动工作

[英]Can't get launchd to work at Startup/Shutdown on OS X Lion

I followed some online guides trying to get some headless VMs to start/suspend automatically at boot/shutdown on my Mac. 我遵循了一些在线指南,尝试使一些无头的VM在Mac上的启动/关闭时自动启动/挂起。 I can't get it to work at all. 我根本无法正常工作。 This is my first time trying to get script runs on Startup/Shutdown, so it could be that I'm just missing something very basic and if that's the case I apologize. 这是我第一次尝试在Startup / Shutdown上运行脚本,所以可能是我缺少一些非常基本的内容,如果是这种情况,我表示歉意。

These are the steps I followed: 这些是我遵循的步骤:

  • Created a directory /Library/StartupItems/HeadlessVM 创建目录/Library/StartupItems/HeadlessVM
  • Created two files within that directory: 在该目录中创建了两个文件:

     -rwxr--r-- 1 root wheel 242 Feb 19 19:05 HeadlessVM -rw-r--r-- 1 root wheel 188 Feb 20 12:42 StartupParameters.plist 

    Contents for HeadlessVM HeadlessVM的内容

     $ cat HeadlessVM #!/bin/sh . /etc/rc.common StartService () { ConsoleMessage "Starting HeadlessVM" /usr/local/bin/runvmheadless } StopService () { ConsoleMessage "Suspending HeadlessVM" /usr/local/bin/suspendvmheadless } RunService "$1" 

    Contents for StartupParameters.plist StartupParameters.plist的内容

     $ cat StartupParameters.plist { Description = "Runs/Suspends Virtual Machine Headless on OS X Startup/Shutdown"; Provides = ("HeadlessVM"); Uses = ("Disks"); OrderPreference = ("Late"); } 
  • Created my script files, that will perform both actions: 创建了我的脚本文件,它将执行以下两项操作:

      -rwxr-xr-x@ 1 xxxxxxx admin 164 Feb 19 01:06 runvmheadless -rwxr-xr-x@ 1 xxxxxxx admin 160 Feb 19 01:19 suspendvmheadless 

    Contents for runvmheadless runvmheadless的内容

     $ cat runvmheadless #!/bin/bash "/Applications/VMware Fusion.app/Contents/Library/vmrun" -T fusion start "/Volumes/Archive/Virtual Machines/vm.vmwarevm/vm.vmx" nogui 

    Contents for suspendvmheadless suspendvmheadless的内容

     $ cat suspendvmheadless #!/bin/bash "/Applications/VMware Fusion.app/Contents/Library/vmrun" -T fusion suspend "/Volumes/StaticData/Virtual Machines/vm.vmwarevm/vm.vmx" 
  • My troubleshooting so far: 到目前为止,我的疑难解答:

    • If I run the scripts from the terminal, they work as intended. 如果我从终端运行脚本,它们将按预期运行。
    • If I run sudo /sbin/SystemStarter (start or stop) "HeadlessVM" it also works. 如果我运行sudo /sbin/SystemStarter (start or stop) "HeadlessVM"它也可以工作。
    • On console I only see the following when I reboot, no clue on what's wrong tho. 在控制台上,当我重新启动时,我只会看到以下内容,不知道出了什么问题。

      2/20/12 12:11:09.128 PM SystemStarter: Runs/Suspends Virtual Machine Headless on OS X Startup/Shutdown (100) did not complete successfully 2012年2月20日12:11:09.128 PM SystemStarter:在OS X启动/关闭(100)上无头运行/挂起虚拟机未成功完成

Appreciate any help, Thank you. 感谢您的帮助,谢谢。

I found what was wrong. 我发现出了什么问题。 The code above is fine, the problem is that my scripts are trying to get data from an encrypted secondary disk which was not available at boot time. 上面的代码很好,问题是我的脚本试图从启动时不可用的加密辅助磁盘上获取数据。

I used this in order to bypass this problem:https://github.com/jridgewell/Unlock 我用它来绕过此问题:https://github.com/jridgewell/Unlock

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM