Skip to content

Instantly share code, notes, and snippets.

@seifertm
Last active October 24, 2017 09:06
Show Gist options
  • Save seifertm/75f79b95b36dfbf623ac0887c1b84cf9 to your computer and use it in GitHub Desktop.
Save seifertm/75f79b95b36dfbf623ac0887c1b84cf9 to your computer and use it in GitHub Desktop.
Gentoo ebuild for laminar CI with support for OpenRC. Knonw issue: If using a unix socket for http connections, the unix socket will be recreated upon restarting laminard, potentially resetting user/group permissions on the socket.
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
EAPI=6
inherit cmake-utils user systemd
DESCRIPTION="A lightweight continuous integration server"
HOMEPAGE="http://laminar.ohwg.net/"
LICENSE="GPLv3"
SLOT="0"
KEYWORDS="~amd64 ~x86"
if [ "${PV}" = "9999" ]; then
inherit git-r3
EGIT_REPO_URI="https://github.com/ohwgiles/${PN}.git"
KEYWORDS=""
else
SRC_URI="https://github.com/ohwgiles/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz"
fi
IUSE=""
DEPEND=""
RDEPEND="${DEPEND}
>=dev-libs/capnproto-9999
>=dev-libs/rapidjson-1.1.0
>=dev-cpp/websocketpp-0.7.0
>=dev-libs/boost-1.62
dev-db/sqlite:3"
pkg_setup() {
enewuser laminar -1 -1 /var/lib/laminar
}
src_configure() {
local mycmakeargs=(
-DCMAKE_INSTALL_PREFIX="${EPREFIX}/"
)
cmake-utils_src_configure
}
src_install() {
newinitd "${FILESDIR}"/laminar.initd laminar
newconfd "${FILESDIR}"/laminar.confd laminar
systemd_newunit "${S}/laminar.service" ${PN}.service
cmake-utils_src_install
}
# The group of laminar's unix socket for HTTP connections, if LAMINAR_HTTP_BIND specifies a unix socket.
LAMINAR_GROUP="web"
#!/sbin/openrc-run
logfile=/var/log/laminard
pidfile=/var/run/laminard.pid
depend() {
need net
}
start() {
ebegin "Starting ${SVCNAME}"
source "/etc/laminar.conf"
laminar_opts=(
$(test -n "$LAMINAR_HOME" && echo --env=LAMINAR_HOME="$LAMINAR_HOME")
$(test -n "$LAMINAR_BIND_HTTP" && echo --env=LAMINAR_BIND_HTTP="$LAMINAR_BIND_HTTP")
$(test -n "$LAMINAR_BIND_RPC" && echo --env=LAMINAR_BIND_RPC="$LAMINAR_BIND_RPC")
$(test -n "$LAMINAR_TITLE" && echo --env=LAMINAR_TITLE="$LAMINAR_TITLE")
$(test -n "$LAMINAR_KEEP_RUNDIR" && echo --env=LAMINAR_KEEP_RUNDIR="$LAMINAR_KEEP_RUNDIR")
$(test -n "$LAMINAR_ARCHIVE_URL" && echo --env=LAMINAR_ARCHIVE_URL="$LAMINAR_ARCHIVE_URL")
)
touch $logfile
chmod g+w $logfile
chgrp laminar $logfile
start-stop-daemon --start --user laminar --group $LAMINAR_GROUP --exec /usr/bin/laminard --background --make-pidfile --pidfile $pidfile --stdout $logfile --stderr $logfile ${laminar_opts[*]}
laminar_http_socket=${LAMINAR_BIND_HTTP#unix:}
if [ -e $laminar_http_socket ]; then
chgrp $LAMINAR_GROUP $laminar_http_socket
chmod g+w $laminar_http_socket
fi
eend $?
}
stop() {
ebegin "Stopping ${SVCNAME}"
start-stop-daemon --stop --exec /usr/bin/laminard --pidfile $pidfile
eend $?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment