Custom Linux service for a VLC stream?

I'm sure this is a dumb question, especially considering I've been using Linux for a lot of things for over 3 years now. But I'm asking anyway

I have a streaming server (at school for a broadcasting class) running on a Core 2 Quad box running Ubuntu 14.04LTS server. We do our streaming using cvlc (the command-line version of VLC, for those who don't know), and now that we've got streaming settings we like, I'd like to see if I can make it a service which starts automatically on startup. The trick is what it does. This server isn't an AIO solution, it is only responsible for transcoding. It receives the stream over a network via UDP, and transcodes it and serves it up in Theora/OGG via HTTP.

If I want to make an init script for this, how would I do it? I want it to start automatically on boot, but it MUST start after almost everything else, most importantly the network services since it receives the stream via a network. Let's say for now, to save space, that the streaming command is cvlc MYSUPERCOOLSTREAMCRAP. How would I set up an init script for that so that it starts automatically, can be restarted or stopped by root, and stops automatically when you shut down the server?

I know this is a weird use case, so if you have questions about why I'm doing it the way I am, ask away. Just need some help on this.

TL;DR - How would I create an init.d script for a given command that starts last on boot and shuts down first on power off?

If your OK with it starting at login rather than at boot, (it starts after everything else and would stop first), you could add a .desktop file into the ~/.config/autostart/ folder with a format a bit like this:
and auto-login

[Desktop Entry]
Type=Application
Name=<Name of application as displayed>
Exec=<command to execute>
Icon=<full path to icon>
Comment=<optional comments>
X-GNOME-Autostart-enabled=true

[from http://askubuntu.com/questions/48321/how-do-i-start-applications-automatically-on-login]

or you could add cvlc MYSUPERCOOLSTREAMCRAP & to the ~/.profile instead.

You could use upstart, although I almost never mess with init scripts.

sudo nano /etc/init/service-name.conf

description "your service description"

start on net-device-up IFACE=eth0
stop on net-device-down IFACE=eth0

exec command or path to script

That should start the service when eth0 is brought up and stop the service when eth0 is brought down. Upstart is kind of weird with bash completion, if your the root user it works, but not if you use sudo so you'll have to type out the service name.

To start the service

sudo start service-name <-- the name of the conf file before .conf

To stop the service

sudo stop service-name

Simple test example --> http://paste.ubuntu.com/12191700/

Unfortunately, since this is a headless server, nobody will log on to the physical machine on startup. We only log on via SSH on occasion.

Thank you, this looks like it will work. I'll try it later this week and let you know