我需要守护在Wine中运行的Windows应用程序,并在/var/run创build一个pid。 由于它需要运行X11会话,所以我需要确保在正在运行的用户环境中设置$ DISPLAYvariables。
假设我已经有了一个运行X11的会话,在一个给定的显示中,下面是我的/etc/init.d脚本中start-stop-daemon行的样子:
start-stop-daemon --start --pidfile /var/run/wine-app.pid -m -c myuser -g mygroup -k 002 --exec /home/myuser/.wine/drive_c/Program\ Files/wine-app.exe
不幸的是,我在Ubuntu 8.04上的start-stop-daemon版本没有-e选项来设置环境variables。 我收集你可以简单地设置$ DISPLAY命令之前,像这样:
VAR1="Value" start-stop-daemon ...
但它不起作用。 由于我使用-c {user}选项以特定用户身份运行,所以我猜测有一个环境开关,VAR1丢失了。 我试图从正在运行的用户的.profile和/或.bashrc导出DISPLAY,但它也不起作用。
有没有另外一种方法来做到这一点? 这甚至有可能吗? 我可以俯视吗?
你可以编写一个shell脚本来设置variables,然后运行wine。
您可以使用env来修改环境:
start-stop-daemon --start --pidfile /var/run/wine-app.pid -m -c myuser -g mygroup -k 002 --exec /usr/bin/env VAR1="Value" /home/myuser/.wine/drive_c/Program\ Files/wine-app.exe