11SERVICE_NAME := showcase-website
2+ SERVICE_FILE_PATH := /etc/systemd/system/$(SERVICE_NAME ) .service
23
3- define SERVICE_FILE
4+ define SERVICE_FILE_CONTENT
45[Unit]
56Description=Showcase Website
67After=network.target
@@ -16,24 +17,25 @@ User=$(shell whoami)
1617WantedBy=multi-user.target
1718endef
1819
19- export SERVICE_FILE
20+ export SERVICE_FILE_CONTENT
2021
21- .PHONY : help init update logs
22+ .PHONY : help init update logs delete
2223
2324help :
2425 @echo " This is a production only tool. Please use bun directly in development."
2526 @echo " "
2627 @echo " Run 'sudo make init' once, and then every time you want to update the website, run 'sudo make update'."
2728 @echo " "
2829 @echo " Rules:"
29- @echo " - init: creates the service"
30+ @echo " - init: creates the service"
3031 @echo " - restart: restart website wthout pulling latest version"
31- @echo " - update: updates and restarts"
32- @echo " - logs: opens the logs"
33- @echo " - help: displays this message"
32+ @echo " - update: updates and restarts"
33+ @echo " - logs: opens the logs"
34+ @echo " - delete: undoes init"
35+ @echo " - help: displays this message"
3436
3537init :
36- echo " $$ SERVICE_FILE " | sudo tee /etc/systemd/system/ $( SERVICE_NAME ) .service
38+ echo " $$ SERVICE_FILE_CONTENT " | sudo tee $( SERVICE_FILE_PATH )
3739 sudo systemctl daemon-reload
3840 sudo systemctl enable $(SERVICE_NAME )
3941
@@ -48,6 +50,11 @@ update:
4850
4951restart :
5052 sudo systemctl restart $(SERVICE_NAME )
53+
54+ delete :
55+ sudo systemctl stop $(SERVICE_NAME )
56+ sudo rm -f $(SERVICE_FILE_PATH )
57+ sudo systemctl daemon-reload
5158
5259logs :
5360 sudo journalctl -xeu $(SERVICE_NAME )
0 commit comments