summaryrefslogtreecommitdiff
path: root/linux/deb/02-fs-spring-boot-kamal/create-new-project.sh
blob: 7136ce974c94c6393b9fa1a54414b9c91f1e78ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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."