-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (52 loc) · 2.49 KB
/
Makefile
File metadata and controls
73 lines (52 loc) · 2.49 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
VERSION = 0.4.2
PROJECT_NAME = ovena
DIST = ./dist/$(PROJECT_NAME)
# Location for Orthanc configuration
OVENA_CONFIG = /usr/local/etc/ovena
# Name of docker image of PostgreSQL
DATABASE_DOCKER_IMAGE = database
# Name of PostgreSQL Database to use for orthanc
DATABASE_NAME = orthanc
# Name of PostgreSQL Database to use for orthanc
DATABASE_USERNAME = orthanc
$(shell if [ ! -e .env ]; then cp dot-env .env; fi)
include .env
export $(shell sed 's/=.*//' .env)
TARBALL = $(dir $(DIST))$(PROJECT_NAME)-$(VERSION).tgz
INSTALLER = bin/ovena-install.sh
.PHONY: clean all substitution deploy github-release tarball default
default: clean tarball
clean:
rm -rf $(dir $(DIST))
all: $(DIST)/bin $(DIST)/docker substitution fix-file-modes
$(DIST):
mkdir -p $(DIST)
$(DIST)/bin: $(DIST)
cp -Rv bin $@
mv $(DIST)/$(INSTALLER) $(DIST)
$(DIST)/docker: $(DIST)
cp -Rv docker $@
substitution:
# Substitute all $<> variables. Purposely avoiding the -i command, to ensure compatibility between macOS and Linux.
find $(DIST) -type f -exec sh -c 'sed -e "s#\$$<DATABASE_DOCKER_IMAGE>#${DATABASE_DOCKER_IMAGE}#g" "$$1" > "$$1.tmp" && mv "$$1.tmp" "$$1"' sh {} \;
find $(DIST) -type f -exec sh -c 'sed -e "s#\$$<DATABASE_NAME>#${DATABASE_NAME}#g" "$$1" > "$$1.tmp" && mv "$$1.tmp" "$$1"' sh {} \;
find $(DIST) -type f -exec sh -c 'sed -e "s#\$$<DATABASE_USERNAME>#${DATABASE_USERNAME}#g" "$$1" > "$$1.tmp" && mv "$$1.tmp" "$$1"' sh {} \;
find $(DIST) -type f -exec sh -c 'sed -e "s#\$$<OVENA_CONFIG>#${OVENA_CONFIG}#g" "$$1" > "$$1.tmp" && mv "$$1.tmp" "$$1"' sh {} \;
find $(DIST) -type f -exec sh -c 'sed -e "s#\$$<ORTHANC_IP>#${ORTHANC_IP}#g" "$$1" > "$$1.tmp" && mv "$$1.tmp" "$$1"' sh {} \;
find $(DIST) -type f -exec sh -c 'sed -e "s#\$$<PROJECT_NAME>#${PROJECT_NAME}#g" "$$1" > "$$1.tmp" && mv "$$1.tmp" "$$1"' sh {} \;
fix-file-modes:
chmod 755 $(DIST)/$(notdir $(INSTALLER))
tarball: $(TARBALL)
$(TARBALL): all
cd $(DIST)/.. && tar zcvf ../$(notdir $@) --exclude='$(notdir $@)' ./
rm -rf $(DIST)
mv $(notdir $@) $@
deploy: $(TARBALL)
# Fully expanded rsync options. Same as -auv, except without --time --perms
scp "$(TARBALL)" "$(DEST_SERVER):/tmp"
echo "WARNING!! Next step will prompt for root password, and restart orthanc server !!"
echo "Ctrl-C to interrupt"
read A
ssh -t "$(DEST_SERVER)" "cd /tmp && rm -rf ovena && tar zxvf $(notdir $(TARBALL)) && cd $(PROJECT_NAME) && ./$(notdir $(INSTALLER))"
github-release:
gh release create v$(VERSION) $(TARBALL) --generate-notes --title "$(PROJECT_NAME)-$(VERSION)"