summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
authorKamal Wickramanayake <kamal@inbox.lk>2026-06-06 14:54:49 +0530
committerKamal Wickramanayake <kamal@inbox.lk>2026-06-06 14:54:49 +0530
commit21608db65bb38341c86eb4414b1aa8357c5fcade (patch)
tree8d9d2c3e85105e4fdd57c8dbefa9016ba1b998cd /linux
parenta8aa731ccb6c3c39469e95ac4c19a6bf2f8b1136 (diff)
Added create-new-project.sh to create a new Debian packaging project
Diffstat (limited to 'linux')
-rw-r--r--linux/deb/02-fs-spring-boot-kamal/.gitignore1
-rw-r--r--linux/deb/02-fs-spring-boot-kamal/README11
-rwxr-xr-xlinux/deb/02-fs-spring-boot-kamal/build.sh2
-rwxr-xr-xlinux/deb/02-fs-spring-boot-kamal/create-new-project.sh41
4 files changed, 53 insertions, 2 deletions
diff --git a/linux/deb/02-fs-spring-boot-kamal/.gitignore b/linux/deb/02-fs-spring-boot-kamal/.gitignore
index c00df13..080a387 100644
--- a/linux/deb/02-fs-spring-boot-kamal/.gitignore
+++ b/linux/deb/02-fs-spring-boot-kamal/.gitignore
@@ -1 +1,2 @@
*.deb
+out
diff --git a/linux/deb/02-fs-spring-boot-kamal/README b/linux/deb/02-fs-spring-boot-kamal/README
index aaf92bc..0dd79a9 100644
--- a/linux/deb/02-fs-spring-boot-kamal/README
+++ b/linux/deb/02-fs-spring-boot-kamal/README
@@ -1,11 +1,20 @@
This directory contains everything to build a deb package that bundles a Spring Boot app that starts a web server.
-The Spring Boot application has not been bundled with this. You need to build it seperately and put it in the correct directory (run build.sh for further details).
+ build.sh - This script builds the deb package.
+ create-new-project.sh - This script can be used to create a new deb package project similar to this project that uses a different name (than fs-spring-boot-kamal). Output will be placed inside 'out' directory.
+
+To create a new deb package project that uses 'mycompany-myapp' as the name, run the following command:
+
+ ./create-new-project.sh mycompany-myapp
+
+ The newly generated project files will be found inside the out directory.
To build, run the following command:
./build.sh
+ Note that the Spring Boot application has not been bundled with this. You need to build it seperately and put it in the correct directory (run build.sh for further details).
+
To install the build deb package run the following commands replacing the package.deb with the correct name of the deb file.
cp package.deb /tmp
diff --git a/linux/deb/02-fs-spring-boot-kamal/build.sh b/linux/deb/02-fs-spring-boot-kamal/build.sh
index c54571d..877f5c5 100755
--- a/linux/deb/02-fs-spring-boot-kamal/build.sh
+++ b/linux/deb/02-fs-spring-boot-kamal/build.sh
@@ -22,7 +22,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Check if the spring boot jar is in the correct location
if [ ! -f $DIR/package/opt/mycompany/fs-spring-boot-kamal/app/fs-spring-boot-kamal.jar ]; then
- errcho "[ERROR] Jar file missing: $DIR/package/opt/mycompany/fs-spring-boot-kamal/app/fs-spring-boot-kamal.jar"
+ errcho "[ERROR] Jar file missing: package/opt/mycompany/fs-spring-boot-kamal/app/fs-spring-boot-kamal.jar"
errcho "[ERROR] Run this build script only after placing the jar file in that location."
exit 1
fi
diff --git a/linux/deb/02-fs-spring-boot-kamal/create-new-project.sh b/linux/deb/02-fs-spring-boot-kamal/create-new-project.sh
new file mode 100755
index 0000000..7136ce9
--- /dev/null
+++ b/linux/deb/02-fs-spring-boot-kamal/create-new-project.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+# This script simply clones this project itself and changes the name of the deb package generated including other required adjustments.
+#
+# This is useful to create a new but similar debian package that can be used to package another Spring Boot application.
+#
+# The generated output will be placed inside the out directory.
+#
+# How to run this script:
+# ./create-new-project.sh name-of-new-deb-package
+#
+# Example:
+# ./create-new-project.sh mycompany-webapp
+
+errcho() {
+ echo "$@" 1>&2;
+}
+
+if [ "$1" = "" ]; then
+ errcho "ERROR: Specify the package name as an argument to this script."
+ exit 1
+fi
+
+if [ -d out/$1 ]; then
+ errcho "ERROR: out/$1 already exists. Delete it first to regenerate."
+ exit 1
+fi
+
+mkdir -p out/$1
+
+cp -a build.sh package README out/$1
+
+# Change all string occurences of fs-spring-boot-kamal in files.
+find out/$i -type f -exec sed -i "s/fs-spring-boot-kamal/$1/g" {} +
+
+# Rename all files and directories that use the name fs-spring-boot-kamal
+mv out/$1/package/etc/fs-spring-boot-kamal out/$1/package/etc/$1
+mv out/$1/package/etc/systemd/system/fs-spring-boot-kamal.service out/$1/package/etc/systemd/system/$1.service
+mv out/$1/package/opt/mycompany/fs-spring-boot-kamal out/$1/package/opt/mycompany/$1
+
+echo "New project created inside out/$1."