我获得了 systemd 服务,但出于各种原因我仍在使用 Ubuntu 14.04。您可能知道 ubuntu 使用 upstart 而不是 systemd。你们能帮我将此 systemd 服务转换为新贵服务吗?
[Unit]
Description=Conan - dong sliders to MAX
After=syslog.target network.target
[Service]
ExecStart=/home/steam/exiles/start_conan.sh
User=steam
Type=simple
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
答案1
作为根用户:
- 将以下文本另存为
/etc/init.d/conan
. - 设置可执行标志
chmod +x /etc/init.d/conan
。 - 尝试运行它:
/etc/init.d/conan start
- 都好?将其添加到运行级别
update-rc.d conan defaults
#! /bin/sh PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="conan service" NAME=conan DAEMON=/usr/sbin/$NAME DAEMON_ARGS="--options args" PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME . /lib/init/vars.sh . /lib/lsb/init-functions case "$1" in start) log_daemon_msg "Starting $DESC" "$NAME" export DISPLAY=:0 export WINEARCH=win64 export WINEPREFIX=/home/steam/.wine64 xvfb-run --auto-servernu m--server-args='-screen 0 640x480x24:32' wine /home/steam/exiles/common/Conan/ConanSandboxServer.exe -log -QueryPort=27055 & ;; stop) log_daemon_msg "Stopping $DESC" "$NAME" wineserver -k #wineserver -k9 ;; status) [ $(pgrep -f wine | wc -l) -gt 0 ] && log_daemon_msg "is running" || log_daemon_msg "not running" ;; restart) stop sleep 2 start ;; *) echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2 exit 3 ;; esac