This script collection will create:
- a RPM package
- a DEB package
- a Windows self installer (via NSIS and WinSW)
For a Spring Boot project, runned as service, or as command line interface (CLI / shell), and build npm/front during packaging.
Via bash, on Linux (RHEL/Debian) and Windows/WSL, not tested on macOS.
See the md/man files on the project root for more informations.
Free feel to add corrections and/or new features (it's really not rocket science).
And you can found two others scripts (see below):
- a RPM package to install this scripts collection
- a DEB package to install this scripts collection
For build RPMs and/or DEB files, you will need, in addition to maven
and java
:
realpath
basename
pandoc
xmlstarlet
mktemp
dpkg-deb
(DEB)lintian
(DEB)rpmbuild
(RPM)rpmlint
(RPM)- and optionnaly
npm
The builded DEB/RPM will run some install/uninstall scripts and do a few things, apart from that, it's a classic, non-signed DEB and RPM files.
The setup script check the presence of bash
, man
, useradd
(not for CLI), and systemctl
(idem), and will deploy:
- A man file (template here), as
man artifactId
- some example files (not for CLI):
- An configuration file (
application.yml
) - An configuration log file (
log4j2.xml
orlogback.xml
) - An default file
- An configuration file (
- The application
jar
file - A
Systemd
service file, deployed, ready to run (not for CLI) - A command line runner (only for CLI)
- THIRD-PARTY and LICENCE files if available.
- An user/group and home dir for this user, as service name, to run the created service (not for CLI).
- A log directory ready to get log files (not for CLI)
All templates are in the src/usr/lib/linux-springboot-packager/templates
directory.
Java presence will not be checked by the installer. The default service file will expect to found it in /usr/bin/java
. Change it as you what after setup.
Before deploy files, the service will be stopped (if exists and if running). After deploy files, it will be enabled, at boot, but not started (not for CLI).
Run the setup with:
# Install / upgrade
sudo dpkg -i <artifactid-version.deb>
# Remove
sudo dpkg -r <artifactid>
# Install / upgrade
sudo rpm -U <artifactid-version.rpm>
# Remove
sudo rpm -e <artifactid>
# Remove "all"
sudo rpm -e --allmatches <artifactid>
You can run manually service with:
runuser -u <SERVICE_NAME> \
-- java -Dlogging.config=/etc/<SERVICE_NAME>/log4j2.xml|logback.xml \
-jar /usr/lib/<SERVICE_NAME>/<artifactId>-bin.jar \
--spring.config.location=/etc/<SERVICE_NAME>/application.yml
And can run CLI with:
<artifactId> [params] [...]
By default, all service options (systemd, user, logs...) will be setup.
To switch to CLI mode, just add a POM proprerty on project pom (or it's ancestry) as:
<properties>
<linux-springboot-packager.kind>cli</linux-springboot-packager.kind>
</properties>
And you MUST provide a MAN page. Free feel to generate it as you want. The first .man
file founded on project directory will be used. This call will be done after generate JAR with Maven, so you can link mvn package
and man generation.
On Service building, the man page will be provided (see template-man.md
).
On all cases, the man page will be displayed with:
man <artifactId>
Executable files, and uninstaller will be placed on C:\Program Files\<project name>
, and "variable files" like log and application.yml in C:\ProgramData\<project name>
.
An uninstall script add an entry in "Add/Remove programs" is setup.
Setup script are crafted to be simply "over installed": the next setup will uninstall the previous one (with a service stop and remove), but keep the actual "variable files".
By default, the service run will need a valid application.yml
and log4j2.xml
. Samples/examples are provided.
Actually, Windows builds don't support logback/log4j automatic switch as Linux does. log4j.xml
still is here the only option now.
CLI option is not setup for Windows.
Just run setup files with admin rights. If you use WinSW with a .NET dependency, you should install it before.
After the setup, with the help of WinSW, a Windows service in declared, but not started and set to Manual.
Free feel to edit servicewinsw.xml
before build the setup, or edit the production file winsw.xml
. Please to refer to WinSW documentation.
Don't forget to setup a compatible JVM, and put java.exe directory in PATH.
Do a
./make-deb.bash
./make-rpm.bash
You will need git
, realpath
, man
, pandoc
, rpmlint
, rpmbuild
, rpm
, dpkg-deb
and lintian
to run it.
It's fonctionnal for RPM on Debian-like hosts (to build it, not run it), and vice-versa on DEB on RHEL-like hosts.
Don't forget to install/setup java
, maven
, pandoc
...
Do a
./run-tests.bash
It will create a test DEB and RPM files for a demo java project on test/demospringboot
and test/democlispringboot
for CLI option, and optionnaly a EXE file.
You will need all the mandatory DEB and RPM deps, optionnaly EXE deps.