Skip to content

Commit

Permalink
Update Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
hmgle committed Dec 27, 2020
1 parent 3198f2b commit d72a9d0
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# "Makefile" for graftcp.
# Copyright (C) 2016, 2018 Hmgle <[email protected]>
# Copyright (C) 2016, 2018, 2020 Hmgle <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -70,6 +70,12 @@ install_graftcp:: graftcp
uninstall_graftcp::
-rm -f $(DESTDIR)$(BINDIR)/graftcp

install_systemd::
$(MAKE) -C graftcp-local install_systemd

uninstall_systemd::
$(MAKE) -C graftcp-local uninstall_systemd

install_graftcp_local::
$(MAKE) -C graftcp-local install

Expand Down
19 changes: 19 additions & 0 deletions graftcp-local/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,25 @@ graftcp-local: .gopath/.created $(wildcard *.go)
install:: graftcp-local
$(INSTALL) $< $(DESTDIR)$(BINDIR)/$<

SYSTEMD_UNIT_DIR:=$(shell pkg-config --variable=systemdsystemunitdir systemd 2>/dev/null)

install_systemd:: install
$(if $(SYSTEMD_UNIT_DIR),,$(error SYSTEMD_UNIT_DIR is not defined))
test -f $(DESTDIR)/etc/graftcp-local/graftcp-local.conf || \
install -Dm644 example-graftcp-local.conf $(DESTDIR)/etc/graftcp-local/graftcp-local.conf
install -Dm644 contrib/systemd/graftcp-local.service ${DESTDIR}/${SYSTEMD_UNIT_DIR}/graftcp-local.service
ifneq ($(PREFIX),/usr/)
sed -i -re 's#/usr/bin/graftcp-local#$(subst #,\#,${PREFIX})/bin/graftcp-local#g' ${DESTDIR}/${SYSTEMD_UNIT_DIR}/graftcp-local.service
endif
@echo "Enable and start the graftcp-local systemd unit"
systemctl daemon-reload && systemctl --now enable graftcp-local.service

uninstall_systemd::
$(if $(SYSTEMD_UNIT_DIR),,$(error SYSTEMD_UNIT_DIR is not defined))
@echo "Disable and stop the graftcp-local systemd unit"
systemctl disable --now graftcp-local.service
rm -f ${DESTDIR}/${SYSTEMD_UNIT_DIR}/graftcp-local.service

uninstall:: graftcp-local
-rm -f $(DESTDIR)$(BINDIR)/$<

Expand Down
15 changes: 15 additions & 0 deletions graftcp-local/contrib/systemd/graftcp-local.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Translate graftcp TCP to SOCKS5 or HTTP proxy
After=network.target

[Service]
StartLimitInterval=5
StartLimitBurst=10
ExecStart=/usr/bin/graftcp-local -config /etc/graftcp-local/graftcp-local.conf


Restart=always
RestartSec=120

[Install]
WantedBy=multi-user.target

0 comments on commit d72a9d0

Please sign in to comment.