I have a python script which runs a daemon-like service, now I created the python package. I created a .deb package from there but I want the script to be run with upstart, but I can't mange to write the files in the /etc/init ubuntu folder automatically when .deb package is installed so that my daemon doesn't have to be started manually on reboot. I don't know if I explained this well, but I don't know how to explain it better...
what I have: python_script.py ->runs a python-daemon
python_script.tar.gz -> python package
what I need:
python.deb -> which install the python script and sets up the upstart for my python scrip so that it runs as a service/daemon
You should look for the debian packaging doc for python, other that can be useful is the stdeb tool, a Python to Debian source package conversion utility.
For running it as a daemon you need to create a init.d script (you can see how to here, and here a more complete example), you can add the init.d script in the package and then call "update-rc.d myscript defaults" from the postinst script of the python.deb and call "update-rc.d -f myscript remove" from the prerm script.
If you are using Ubuntu standard way to create deb package all you need to do is to place package-name.upstart in debian folder.
dh_installinit is a debhelper program that is responsible for installing upstart job files or init scripts with associated defaults files into package build directories, and in the former case providing compatibility handling for non-upstart systems.
See dh_installinit.
I find building a Debian package from Bazaar branch to be the easiest way to create deb package.
See Packaging New Software as well.
I used such approach to create Gearman Job Server set of packages. Placing gearman-job-server.upstart was sufficient.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With