new: app-misc/tmuxservice

This commit is contained in:
Joerg Deckert 2019-04-13 17:56:27 +02:00
parent e46119b90c
commit 0630855f4f
6 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,5 @@
AUX tmux-confd 149 BLAKE2B a330772d67df5f2ee1938588c277faf7252466c6d14b65abf5f3c8006812d38ac3142eae35d933c3f750da6412274de2992339917dac580e98f67678735392b9 SHA512 445a40bea4a48cfb7709ded0a09ada154d6657f030955f3a9b0ddf6cd9d7526da31c7bc7fb1e5f023746ac8a9adf8e22056187d502e977f050a1d6b72082e253
AUX tmux-initd 971 BLAKE2B 4b206e0b544e169cb04f9cdfcf717c47c2e56765838227c829b71eee0bc055db717a0e7e240ea8a31069b5cf1ba5a67d4e61e18561c2849839a3e4f0a97704a7 SHA512 cb2e9ecb7bfa2a49b6d30040b03a172a59cf6880ddc306de476b81b75af4d1cd0eac4a1a5fbb88b3f9e391d6a163305af414743135d6add320e815ff00365c64
AUX tmux.service 258 BLAKE2B 9b2520515c84e8fed625e00d13a26cccdbe0b7e25bd50e9464b4b024e02e63e6fc81e2cf5331c62ca7add0aa15c069333905d1d35e9e09dd9bf70d83be9e4945 SHA512 819332d56f43d2f0b6e7818d34b6e0589a27ef658bff489783538536f743cfbf7434b0e1ce4de42bf1bc280ea202d2535a29859e54c8331c3deec066d4a06a5a
AUX tmux.service.conf 152 BLAKE2B d5bb66310c2d4338bea3ad9034014dc391361ef28e6f4f4282aeceab208955a5108e9f5fdf99771cdaa04322b841465f6335d66ee8e495e6c330ebcbdd5acff4 SHA512 9bfaf1c1c9f60f7a76685e75f779e34be00c1a1fc65f10713f3f8bf8fbe3e265c0c7b1b10f787b2ccfefc5a46eca0a667611f65e622995384ba0931504c25cdc
EBUILD tmuxservice-1.0.ebuild 670 BLAKE2B 6f28864bd78d26a05a01e406b41d21b40a96b66fbc64400406749d488b3447697c2d51e9e95bd6e06cddbc39649a3c321753ecacf09f8ee98bbf323f6d95c11a SHA512 ce1319c329701f83de7af348ea4d105fd018aa1fd267e4a9b46ce3461efea0653872690f3c35fac21958e2c14ad04d0488b19dfce9e2ea5b8f81b1c8d9eab52a

View File

@ -0,0 +1,3 @@
# /etc/conf.d/tmux: config file for /etc/init.d/tmux
TMUX_CL_EXTEND="; split-window -v ; split-window -h /usr/bin/mc ; set status-left-length 20 ;"

View File

@ -0,0 +1,34 @@
#!/sbin/openrc-run
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
TMUXUSER=${SVCNAME#*.}
if [ ! -n "${TMUXUSER}" ] || [ ${SVCNAME} == "tmux" ]; then
TMUXUSER="root"
fi
depend() {
use logger net
}
start() {
ebegin "Starting tmux for ${TMUXUSER}"
TMUXSHELL="$(getent passwd ${TMUXUSER} | cut -d: -f7)"
start-stop-daemon \
--env TERM="rxvt" \
--env HOME="~${TMUXUSER}" \
--env SHELL="${TMUXSHELL}" \
--user $TMUXUSER \
--chdir "~${TMUXUSER}" \
--background \
--exec /usr/bin/tmux -- new-session -s ts-${TMUXUSER} -d $TMUX_CL_EXTEND
eend $?
}
stop() {
ebegin "Stopping tmux for ${TMUXUSER}"
start-stop-daemon \
--user $TMUXUSER \
--exec /usr/bin/tmux -- kill-session -t ts-${TMUXUSER}
eend $?
}

View File

@ -0,0 +1,13 @@
[Unit]
Description=Start tmux in detached session
[Service]
Type=forking
User=%I
ExecStart=/usr/bin/tmux new-session -s ts-%I -d $TMUX_CL_EXTEND
ExecStop=/usr/bin/tmux kill-session -t ts-%I
Restart=always
RestartSec=5s
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,3 @@
# extended tmux parameters
[Service]
Environment="TMUX_CL_EXTEND=\\; split-window -v \\; split-window -h /usr/bin/mc \\; set status-left-length 20 \\;"

View File

@ -0,0 +1,22 @@
EAPI="6"
inherit systemd
DESCRIPTION="Start tmux sessions as a service"
LICENSE="LGPL-2.1"
SLOT="0"
KEYWORDS="alpha amd64 arm hppa ia64 m68k mips ppc ppc64 s390 sh sparc x86 sparc-fbsd x86-fbsd hppa-hpux amd64-linux x86-linux ppc-macos x64-macos x86-macos sparc-solaris sparc64-solaris x64-solaris x86-solaris"
RDEPEND="app-misc/tmux
app-misc/mc"
DEPEND="${RDEPEND}"
S=${WORKDIR}
src_install() {
einfo "Install systemd service"
systemd_newunit "${FILESDIR}"/tmux.service tmux@.service
systemd_install_serviced "${FILESDIR}"/tmux.service.conf
einfo "Install init scripts"
newinitd "${FILESDIR}"/tmux-initd tmux
newconfd "${FILESDIR}"/tmux-confd tmux
}