add install and uninstall targets for systemctl

pull/1/head
Jordan Sokolic 2020-02-22 21:22:33 +02:00
parent 87301e1c10
commit 4cc98935b0
2 changed files with 25 additions and 2 deletions

View File

@ -1,4 +1,4 @@
.PHONY: build run clean
.PHONY: build run clean install uninstall
include openwrt.conf
@ -12,3 +12,17 @@ clean:
docker rm ${CONTAINER} || true
docker network rm ${LAN_NAME} ${WAN_NAME} || true
docker rmi ${BUILD_TAG}
install:
install -Dm644 openwrt.service /usr/lib/systemd/system/openwrt.service
sed -i -E "s#(ExecStart=).*#\1`pwd`/run.sh#g" /usr/lib/systemd/system/openwrt.service
systemctl daemon-reload
systemctl enable openwrt.service
@echo "OpenWRT service installed and will be started on next boot automatically."
@echo "To start it now, run 'systemctl start openwrt.service'."
uninstall:
systemctl stop openwrt.service
systemctl disable openwrt.service
rm /usr/lib/systemd/system/openwrt.service
systemctl daemon-reload

9
openwrt.service 100644
View File

@ -0,0 +1,9 @@
[Unit]
Description="OpenWRT"
[Service]
Type=simple
ExecStart=
[Install]
WantedBy=network-online.target