From 0d44eb826a8792b176ca8fd2338fc3a706492536 Mon Sep 17 00:00:00 2001 From: Horea Christian Date: Wed, 22 Jul 2015 03:38:57 +0200 Subject: [PATCH] added new syncthing files --- net-p2p/syncthing/files/conf.d/syncthing | 15 +++++ net-p2p/syncthing/files/init.d/syncthing | 36 ++++++++++++ net-p2p/syncthing/metadata.xml | 8 +++ net-p2p/syncthing/syncthing-0.11.11.ebuild | 67 ++++++++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 net-p2p/syncthing/files/conf.d/syncthing create mode 100755 net-p2p/syncthing/files/init.d/syncthing create mode 100644 net-p2p/syncthing/metadata.xml create mode 100644 net-p2p/syncthing/syncthing-0.11.11.ebuild diff --git a/net-p2p/syncthing/files/conf.d/syncthing b/net-p2p/syncthing/files/conf.d/syncthing new file mode 100644 index 0000000..bedce1a --- /dev/null +++ b/net-p2p/syncthing/files/conf.d/syncthing @@ -0,0 +1,15 @@ +# Config file for /etc/init.d/syncthing + +SYNC_NAME="syncthing" +SYNC_PIDFILE="/var/run/${SYNC_NAME}.pid" + +# If you are going to run syncthing as a user, also uncomment the SYNC_HOME line +SYNC_USER="root" +SYNC_GROUP="root" +#SYNC_HOME="/home/${SYNC_USER}/.config/${SYNC_NAME}" + +# Make sure SYNC_HOME is set to something so we reduce DRY here and in the init script +SYNC_HOME="${SYNC_HOME:-/etc/${SYNC_NAME}}" + +# Any options you want you can set them here +SYNC_OPTS="--home=${SYNC_HOME}" diff --git a/net-p2p/syncthing/files/init.d/syncthing b/net-p2p/syncthing/files/init.d/syncthing new file mode 100755 index 0000000..7a2218b --- /dev/null +++ b/net-p2p/syncthing/files/init.d/syncthing @@ -0,0 +1,36 @@ +#!/sbin/runscript + +# Copyright 2014-2015 Jonathan Vasquez +# Distributed under the terms of the GNU General Public License v2 + +DISPLAY_NAME="SyncThing" + +SYNC_PATH="/usr/bin" +SYNC_BINARY="${SYNC_PATH}/${SYNC_NAME}" +SYNC_USER="${SYNC_USER:-root}" +SYNC_GROUP="${SYNC_GROUP:-root}" +SYNC_HOME="${SYNC_HOME:-/etc/${SYNC_NAME}}" + +start() { + ebegin "Starting ${DISPLAY_NAME}" + + if [[ ${SYNC_USER} == "root" ]]; then + SYNC_NAME="root" + SYNC_GROUP="root" + + einfo "Running ${DISPLAY_NAME} as root:root. Home directory: ${SYNC_HOME}" + fi + + start-stop-daemon -m --pidfile "${SYNC_PIDFILE}" -b \ + --start --user ${SYNC_USER} --group ${SYNC_GROUP} --exec "${SYNC_BINARY}" -- ${SYNC_OPTS} + + eend $? +} + +stop() { + ebegin "Stopping ${DISPLAY_NAME}" + + start-stop-daemon --stop --exec "${SYNC_BINARY}" --pidfile "${SYNC_PIDFILE}" + + eend $? +} diff --git a/net-p2p/syncthing/metadata.xml b/net-p2p/syncthing/metadata.xml new file mode 100644 index 0000000..be647b9 --- /dev/null +++ b/net-p2p/syncthing/metadata.xml @@ -0,0 +1,8 @@ + + + + + jvasquez1011@gmail.com + Jonathan Vasquez + + diff --git a/net-p2p/syncthing/syncthing-0.11.11.ebuild b/net-p2p/syncthing/syncthing-0.11.11.ebuild new file mode 100644 index 0000000..34669cd --- /dev/null +++ b/net-p2p/syncthing/syncthing-0.11.11.ebuild @@ -0,0 +1,67 @@ +# Copyright 2014-2015 Jonathan Vasquez +# Distributed under the terms of the GNU General Public License v2 + +EAPI=5 + +inherit user systemd + +GITHUB_USER="syncthing" +GITHUB_REPO="syncthing" +GITHUB_TAG="${PV}" + +NAME="syncthing" +DESCRIPTION="Open Source Continuous File Synchronization" +HOMEPAGE="http://syncthing.net/" + +SRC_URI="https://github.com/${GITHUB_USER}/${GITHUB_REPO}/archive/v${GITHUB_TAG}.tar.gz -> ${P}.tar.gz" + +RESTRICT="mirror" +LICENSE="MPL-2.0" +SLOT="0" +KEYWORDS="~x86 amd64" + +DEPEND=">=dev-lang/go-1.3.0" + +S="${WORKDIR}" + +configDir="~/.config/syncthing" +config="${configDir}/config.xml" + +src_install() { + # Create directory structure recommended by SyncThing Documentation + # Since Go is "very particular" about file locations. + local newBaseDir="src/github.com/${PN}" + local newWorkDir="${newBaseDir}/${PN}" + + mkdir -p "${newBaseDir}" + mv "${P}" "${newWorkDir}" + + cd "${newWorkDir}" + + # Build SyncThing ;D + go run build.go -version v${PV} -no-upgrade=true + + # Copy compiled binary over to image directory + dobin "bin/${PN}" + + # Install the OpenRC init/conf files + doinitd "${FILESDIR}/init.d/${NAME}" + doconfd "${FILESDIR}/conf.d/${NAME}" + + # Install the systemd unit file + local systemdServiceFile="etc/linux-systemd/system/${PN}@.service" + systemd_dounit "${systemdServiceFile}" +} + +pkg_postinst() { + elog "This is a breaking change release (0.11.X). If you have other devices that are" + elog "running on 0.10.X, you will need to upgrade them as well since these versions" + elog "cannot communicate with each other." + elog "" + elog "In order to be able to view the Web UI remotely (from another machine)," + elog "edit your ${config} and change the 127.0.0.1:8080 to 0.0.0.0:8080 in" + elog "the 'address' section. This file will only be generated once you start syncthing." + elog "" + elog "Modify the /etc/conf.d/${PN} file and set the user/group/ and syncthing home directory" + elog "before launching. Afterwards, you can start ${PN} by doing a: rc-config start ${PN}" +}