summaryrefslogtreecommitdiff
path: root/net-p2p
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss123next@list.ru>2015-12-29 10:36:32 +0300
committerGluzskiy Alexandr <sss123next@list.ru>2015-12-29 10:36:32 +0300
commit22b6e21eb98f1cbac3ac71e58acf19d4a2d9eedf (patch)
tree1f02090f0df87ce7116b6c27b0d2cbc259878d96 /net-p2p
parent79c5a71569059b40c622948fb41ee48a9daf1069 (diff)
syncthing from nightmare repo
Diffstat (limited to 'net-p2p')
-rw-r--r--net-p2p/syncthing/files/rc/conf3
-rw-r--r--net-p2p/syncthing/files/rc/init22
-rw-r--r--net-p2p/syncthing/files/syncthing.service12
-rw-r--r--net-p2p/syncthing/syncthing-scm.ebuild69
4 files changed, 106 insertions, 0 deletions
diff --git a/net-p2p/syncthing/files/rc/conf b/net-p2p/syncthing/files/rc/conf
new file mode 100644
index 0000000..1580cae
--- /dev/null
+++ b/net-p2p/syncthing/files/rc/conf
@@ -0,0 +1,3 @@
+SYNCTHING_USER="syncthing"
+SYNCTHING_ADDRESS="127.0.0.1:8080"
+SYNCTHING_ARGS="" \ No newline at end of file
diff --git a/net-p2p/syncthing/files/rc/init b/net-p2p/syncthing/files/rc/init
new file mode 100644
index 0000000..029e567
--- /dev/null
+++ b/net-p2p/syncthing/files/rc/init
@@ -0,0 +1,22 @@
+#!/sbin/runscript
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+depend() {
+ need net
+}
+
+start() {
+ ebegin "Starting syncthing"
+ start-stop-daemon --start --make-pidfile --pidfile /var/run/syncthing.pid \
+ --background --user ${SYNCTHING_USER} --name syncthing \
+ --exec /usr/bin/syncthing -- -gui-address=${SYNCTHING_ADDRESS} ${SYNCTHING_ARGS}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping syncthing"
+ start-stop-daemon --stop --pidfile /var/run/syncthing.pid --user ${SYNCTHING_USER}
+ eend $?
+} \ No newline at end of file
diff --git a/net-p2p/syncthing/files/syncthing.service b/net-p2p/syncthing/files/syncthing.service
new file mode 100644
index 0000000..e5ff0ae
--- /dev/null
+++ b/net-p2p/syncthing/files/syncthing.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Syncthing service for %i
+After=network.target
+
+[Service]
+User=%i
+Environment=STNORESTART=yes
+ExecStart=/usr/bin/syncthing
+Restart=always
+
+[Install]
+WantedBy=multi-user.target \ No newline at end of file
diff --git a/net-p2p/syncthing/syncthing-scm.ebuild b/net-p2p/syncthing/syncthing-scm.ebuild
new file mode 100644
index 0000000..5910dd5
--- /dev/null
+++ b/net-p2p/syncthing/syncthing-scm.ebuild
@@ -0,0 +1,69 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+inherit eutils base git-r3 systemd
+
+DESCRIPTION="Open, trustworthy and decentralized syncing engine"
+HOMEPAGE="http://${PN}.net"
+
+EGIT_REPO_URI="https://github.com/${PN}/${PN}.git"
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS=""
+IUSE="systemd"
+
+DEPEND="
+ >=dev-lang/go-1.3
+ dev-go/godep
+"
+RDEPEND="${DEPEND}"
+
+DOCS=( README.md AUTHORS LICENSE CONTRIBUTING.md )
+
+export GOPATH="${S}"
+
+GO_PN="github.com/${PN}/${PN}"
+EGIT_CHECKOUT_DIR="${S}/src/${GO_PN}"
+S=${EGIT_CHECKOUT_DIR}
+
+src_compile() {
+ # XXX: All the stuff below needs for "-version" command to show actual info
+ local version="$(git describe --always | sed 's/\([v\.0-9]*\)\(-\(beta\|alpha\)[0-9]*\)\?-/\1\2+/')";
+ local date="$(git show -s --format=%ct)";
+ local user="$(whoami)"
+ local host="$(hostname)"; host="${host%%.*}";
+ local lf="-w -X main.Version ${version} -X main.BuildStamp ${date} -X main.BuildUser ${user} -X main.BuildHost ${host}"
+
+ godep go build -ldflags "${lf}" -tags noupgrade ./cmd/syncthing || die
+}
+
+src_install() {
+ dobin syncthing
+ base_src_install_docs
+ if use systemd; then
+ systemd_newunit "${FILESDIR}"/${PN}.service ${PN}@.service
+ else
+ newinitd ${FILESDIR}/rc/init ${PN}
+ newconfd ${FILESDIR}/rc/conf ${PN}
+ fi
+}
+
+pkg_postinst() {
+ if use systemd; then
+ ECHO_1="systemctl start ${PN}@<user>"
+ ECHO_2="systemctl enable ${PN}@<user>"
+ else
+ ECHO_1="/etc/init.d/${PN} start"
+ ECHO_2="rc-update add ${PN} default"
+ fi
+
+ einfo
+ elog "To run syncthing as a service:"
+ elog " ${ECHO_1}"
+ elog "To enable it at startup:"
+ elog " ${ECHO_2}"
+ einfo
+} \ No newline at end of file