feat: make install
This commit is contained in:
@@ -44,3 +44,33 @@ vet:
|
||||
clean:
|
||||
rm -f OpenGFW
|
||||
rm -rf $(FRONTEND)/node_modules
|
||||
|
||||
.PHONY: install
|
||||
install: build
|
||||
@echo "Installing OpenGFW to /usr/local/bin"
|
||||
@install -m 755 OpenGFW /usr/local/bin/OpenGFW || (echo "install failed: try running as root or use sudo" && exit 1)
|
||||
@echo "Installing systemd unit to /etc/systemd/system/opengfw.service"
|
||||
@printf '%s\n' \
|
||||
'[Unit]' \
|
||||
'Description=OpenGFW' \
|
||||
'After=network.target' \
|
||||
'' \
|
||||
'[Service]' \
|
||||
'ExecStart=/usr/local/bin/OpenGFW -c /etc/opengfw/config.yaml /etc/opengfw/rules.yaml' \
|
||||
'Restart=on-failure' \
|
||||
'User=root' \
|
||||
'Group=root' \
|
||||
'WorkingDirectory=/etc/opengfw' \
|
||||
'' \
|
||||
'[Install]' \
|
||||
'WantedBy=multi-user.target' \
|
||||
> /tmp/opengfw.service || (echo "write failed: try running as root or use sudo" && exit 1)
|
||||
|
||||
@echo "Installing default config to /etc/opengfw/"
|
||||
@mkdir -p /etc/opengfw || (echo "mkdir failed: try running as root or use sudo" && exit 1)
|
||||
@install -m 644 config.yaml /etc/opengfw/config.yaml || (echo "copy config failed: try running as root or use sudo" && exit 1)
|
||||
@install -m 644 rules.yaml /etc/opengfw/rules.yaml || (echo "copy rules failed: try running as root or use sudo" && exit 1)
|
||||
@mv /tmp/opengfw.service /etc/systemd/system/opengfw.service || (echo "move failed: try running as root or use sudo" && exit 1)
|
||||
@echo "Reloading systemd daemon and enabling service"
|
||||
@systemctl daemon-reload || (echo "daemon-reload failed: ensure systemd is available" && exit 1)
|
||||
@systemctl enable --now opengfw.service || (echo "enabling service failed: try running as root or use sudo" && exit 1)
|
||||
|
||||
Reference in New Issue
Block a user