1

I got a systemd service and I am still using Ubuntu 14.04 for various reasons. As you probably know ubuntu uses upstart and not systemd. Can you guys help me convert this systemd service to an upstart service ?

[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
8
  • You can read the Getting Started provided by the upstart developer. This will help you for sure.
    – ckruczek
    Mar 1, 2017 at 7:48
  • Also, as an aside, what with the early access and no dedicated linux server available yet this probably isn't the best time to try and set up an Exiles server. I've tried, and it kind of works, but things are sort of messy still. Mar 1, 2017 at 8:48
  • I thought 14.04 had sysVinit, too. So just copy /etc/init.d/skeleton to /etc/init.d/myjob and edit the start) and restart). Put /home/steam/exiles/start_conan.sh` in start) and stop;sleep 42;start in restart). Then run update-rc.d defaults myjob if I remember correctly.
    – Michael D.
    Mar 1, 2017 at 8:54
  • @Shadur It's more or less testing. Nothing serious planned yet, but we have some ressources left on our server. Michael Thanks, will try that out
    – SaeSi
    Mar 1, 2017 at 9:03
  • I strongly urge you to consider upgrading. 14.04 is no longer supported, so you will be facing many issues going forward.
    – terdon
    Mar 1, 2017 at 9:15

1 Answer 1

1

As root:

  • Save the following text as /etc/init.d/conan.
  • Set executable flag chmod +x /etc/init.d/conan.
  • Try to run it: /etc/init.d/conan start
  • all good? add it to the runlevels 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
4
  • Thanks for your help. One last question, how do I start this script in a new screen ? Sorry for all the "stupid" questions but the whole init thing is totally new for me. I was glad a few days ago to write a simple shell script but I cannot quite connect the dots yet :/
    – SaeSi
    Mar 1, 2017 at 11:51
  • Screen as in Terminal? gnu.org/software/screen/manual/screen.html
    – Michael D.
    Mar 1, 2017 at 13:13
  • This might work, but it's not an Upstart script, it's a SysVinit script. Mar 1, 2017 at 13:50
  • @MarkStosberg yes, check 3rd comment below question.
    – Michael D.
    Mar 1, 2017 at 13:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .