【问题标题】:Shell script will not be executedShell 脚本不会被执行
【发布时间】:2015-05-07 12:06:22
【问题描述】:

我的 Galaxy S3 上有 CM12.1。我正在尝试设置 SSHD。目前一切正常,除了最后一步:在启动时启动 sshd 恶魔。

问题在于脚本

/data/local/userinit.sh

将被执行,但是 不再是里面的调用了。

这是脚本:

#!/system/bin/sh

if [ -e /data/local/userinit.d/99sshd ]
then
   log -p i -t userinit "Launching /data/local/userinit.d/99sshd--before"
   /system/bin/sh /data/local/userinit.d/99sshd
   log -p i -t userinit "Launching /data/local/userinit.d/99sshd--after"
fi

99sshd脚本很简单,只是为了调试:

#!/system/bin/sh

log -p i -t userinit "Executing /data/local/userinit.d/99sshd"

这是来自 logcat 的结果:

userinit - 启动 /data/local/userinit.d/99sshd--之前

userinit - 启动 /data/local/userinit.d/99sshd--after

缺少的是消息:

userinit - 执行 /data/local/userinit.d/99sshd

怎么会这样?!

【问题讨论】:

  • 您可以手动运行它作为测试吗?
  • 是的,从终端没问题。
  • 好吧伙计们,我发现文件系统没有准备好:执行时scipt不存在。非常感谢非常了解 android 启动过程的 sy 提供的任何帮助。
  • this 可能是相关的。
  • 这里只是猜测,因为我没有 G3 可以测试。这一行:“/system/bin/sh /data/local/userinit.d/99sshd”,这不是在子shell中执行99sshd吗?也许这可以解释丢失的内容。即,'$x' 在这里丢失的方式相同: echo -e "x=yes\necho \$x\n" > foo ;重击富;回声:$x:.

标签: android shell


【解决方案1】:

init.d 和 userinit.d 支持来自 CM12 和 CM13 的 removed

【讨论】:

    最近更新 更多