On Ubuntu (and Debian), creating a deb
package would be the best way to go, as everything can be automated, so that no end-user intervention is needed. The only cases where package installation or upgrades are not automated are if the package has some configuration options that need input from the user (mainly during installation only) or if a configuration file was modified by the user and is also modified by a newer version of the package (during upgrading). In addition, after installing/upgrading a package, any startup scripts it installs are automatically started.
You can have multiple init
scripts be installed, and have everything still work. In the case of systemd
being installed and used on the user's computer, if there is both an init
script and a systemd
script for the same service, then the init
script is ignored and the systemd
script is used.
In terms of the packaging itself, Debian provides helper scripts that (among other things) automatically install any startup scripts you provide (I don't think upstart
is supported by their helper scripts, since this is only used on Ubuntu) and start the service. For an example of the packaging, see this debian
folder for the dump1090-mutability
package. (Disclaimer: this is my Github account) Note that the dump1090-mutability.init
file contains the init
script while the dump1090-mutability.service
file contains the systemd
script. Note that the names of these files should be package-name.init
and package-name.service
, where package-name
is the name of the binary package being created. (See man dh_systemd_enable
and man dh_systemd_start
for the systemd case.)
On packaging, both of these files are placed in the appropriate directories on the user's system, and the service is then started. For the rules
file, I recommend that you have something like the following, so that you benefit from the automation (see this for the --with systemd
part):
#!/usr/bin/make -f
%:
dh $@ --with systemd
override_dh_auto_build:
# Specify how to build the Java files here, if there is no Makefile provided
override_dh_auto_install:
# Specify how to install the Java files here, if there is no `install` target in the Makefile. Don't worry about anything in the `debian` directory unless you need to install some icons.
- If your app doesn't have a Makefile and is just a collection of Java source files, fill out
override_dh_auto_build
(where the source files are compiled and packaged into a JAR) and override_dh_auto_install
(where the JAR is installed).
- If your app has a Makefile, but doesn't have an
install
target, remove the override_dh_auto_build
target and fill out override_dh_auto_install
.
- If your app has a Makefile and it has an
install
target (that can be used), remove both targets.
- If your app is just a JAR file, remove
override_dh_auto_build
, and fill out override_dh_auto_install
.