Added example openrc init script

Signed-off-by: Russ Magee <rmagee@gmail.com>
This commit is contained in:
Russ Magee 2018-11-13 23:59:34 -08:00
parent d973c83e01
commit d28a4af924
3 changed files with 45 additions and 2 deletions

View File

@ -358,8 +358,12 @@ func parseNonSwitchArgs(a []string) (user, host, path string, isDest bool, other
func launchTuns(conn *hkexnet.Conn, remoteHost string, tuns string) { func launchTuns(conn *hkexnet.Conn, remoteHost string, tuns string) {
remAddrs, _ := net.LookupHost(remoteHost) remAddrs, _ := net.LookupHost(remoteHost)
if tuns == "" {
return
}
tunSpecs := strings.Split(tuns, ",") tunSpecs := strings.Split(tuns, ",")
for _,tunItem := range tunSpecs { for _, tunItem := range tunSpecs {
var lPort, rPort uint16 var lPort, rPort uint16
_, _ = fmt.Sscanf(tunItem, "%d:%d", &lPort, &rPort) _, _ = fmt.Sscanf(tunItem, "%d:%d", &lPort, &rPort)
reqTunnel(conn, lPort, remAddrs[0], rPort) reqTunnel(conn, lPort, remAddrs[0], rPort)

39
hkexshd.initrc Executable file
View File

@ -0,0 +1,39 @@
#!/sbin/openrc-run
SVCNAME=hkexshd
HKEXSHD_PIDFILE=/var/run/hkexshd.pid
HKEXSHD_USER=root
HKEXSHD_HOME=/var/run
INST_PREFIX=/usr/local
COMMAND=$INST_PREFIX/sbin/hkexshd
ARGS=""
depend() {
need net
use dns logger
}
checkconfig() {
if [ ! -f "$COMMAND" ] ; then
eerror "$COMMAND not installed" || return 1
fi
return 0
}
start() {
checkconfig || return 1
ebegin "Starting ${SVCNAME}"
start-stop-daemon \
-d ${HKEXSHD_HOME} \
--make-pidfile --pidfile ${HKEXSHD_PIDFILE} \
--start --quiet --background \
--exec "${COMMAND}" "${ARGS}"
eend $?
}
stop() {
ebegin "Stopping ${SVCNAME}"
start-stop-daemon --stop --quiet --pidfile $HKEXSHD_PIDFILE
eend $?
}

View File

@ -26,9 +26,9 @@ import (
"syscall" "syscall"
"blitter.com/go/goutmp" "blitter.com/go/goutmp"
"blitter.com/go/hkexsh/logger"
hkexsh "blitter.com/go/hkexsh" hkexsh "blitter.com/go/hkexsh"
"blitter.com/go/hkexsh/hkexnet" "blitter.com/go/hkexsh/hkexnet"
"blitter.com/go/hkexsh/logger"
"github.com/kr/pty" "github.com/kr/pty"
) )