summaryrefslogtreecommitdiff
path: root/linux/deb/02-fs-spring-boot-kamal/create-new-project.sh
diff options
context:
space:
mode:
Diffstat (limited to 'linux/deb/02-fs-spring-boot-kamal/create-new-project.sh')
-rwxr-xr-xlinux/deb/02-fs-spring-boot-kamal/create-new-project.sh41
1 files changed, 41 insertions, 0 deletions
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."