-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (44 loc) · 1.49 KB
/
Copy pathMakefile
File metadata and controls
58 lines (44 loc) · 1.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
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
current_dir := $(dir $(mkfile_path))
port ?= 8080
all: install
install: remove
@echo "Building Application"
@npm install
@npx next build
@echo "Installing Service"
@echo "[Unit]" > /tmp/PiDash.service
@echo "Description=PiDash Service" >> /tmp/PiDash.service
@echo "After=network.target" >> /tmp/PiDash.service
@echo "" >> /tmp/PiDash.service
@echo "[Service]" >> /tmp/PiDash.service
@echo "WorkingDirectory=${current_dir}" >> /tmp/PiDash.service
@echo "ExecStart=/usr/bin/npx next start -p ${port}" >> /tmp/PiDash.service
@echo "Restart=on-failure" >> /tmp/PiDash.service
@echo "User=pi" >> /tmp/PiDash.service
@echo "" >> /tmp/PiDash.service
@echo "[Install]" >> /tmp/PiDash.service
@echo "WantedBy=multi-user.target" >> /tmp/PiDash.service
@echo "" >> /tmp/PiDash.service
@sudo cp /tmp/PiDash.service /etc/systemd/system/
@sudo systemctl enable PiDash.service
@echo "Starting Service"
@sudo systemctl start PiDash.service
@echo "Installation Done"
upgrade:
@echo "Disabling Service"
@sudo systemctl stop PiDash.service
@echo "Updating Code"
@git pull origin
@echo "Building Application"
@npm install
@npx next build
@echo "Starting Service"
@sudo systemctl start PiDash.service
@echo "Upgrade Done"
remove:
@echo "Removing Service"
@-sudo systemctl stop PiDash.service
@-sudo systemctl disable PiDash.service
@-sudo rm -f /etc/systemd/system/PiDash.Service
@echo "Service Removed"