Writing simple upstart script

0

I'm trying to write a simple upstart script for my ubuntu server, which starts vnc4server. But it does not work.

Here's the script:

# vnc-server.conf

start on runlevel [2345]
stop on runlevel [016]

script
        su skerit -c 'vnc4server :0 -geometry 1024x768'
end script

post-stop script
        su skerit -c 'vnc4server -kill :0'
end script

#End of File

The command in the first script block works fine when executing it in the terminal, but running start vnc-server does not have the same effect.

skerit

Posted 2012-03-20T12:48:24.840

Reputation: 746

check dmesg for more detail. – accuya – 2013-02-01T06:49:32.560

Answers

0

Even though the documentation I've read says upstart shouldn't work this way, I had to place the command in a 'post-start script' block in stead of a regular 'script' block.

So:

post-start script
        su skerit -c 'vnc4server :0 -geometry 1024x768'
end script

That did the trick

skerit

Posted 2012-03-20T12:48:24.840

Reputation: 746

0

Could it be a PATH issue? Try giving the full path to vnc4server in the script. You can find the full path through

which vnc4server

Disclaimer: have not used upstart.

Daniel Andersson

Posted 2012-03-20T12:48:24.840

Reputation: 20 465

Hmm, I've changed the command to /usr/bin/vnc4server, but it still does not work. So that's not it I'm afraid. – skerit – 2012-03-20T17:28:56.103