public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Robin H. Johnson" <robbat2@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/netifrc:master commit in: sh/
Date: Fri,  9 Jan 2015 17:17:49 +0000 (UTC)	[thread overview]
Message-ID: <1420815985.55f4303617ecd81f8729e8f45a64d14a4a0df41b.robbat2@OpenRC> (raw)

commit:     55f4303617ecd81f8729e8f45a64d14a4a0df41b
Author:     Rabi Shanker Guha <guha.rabishankar <AT> gmail <DOT> com>
AuthorDate: Fri Jan  9 15:06:25 2015 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Fri Jan  9 15:06:25 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/netifrc.git;a=commit;h=55f43036

Systemd Wrapper: to be called from unit file

---
 sh/systemd-wrapper.sh.in | 91 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)

diff --git a/sh/systemd-wrapper.sh.in b/sh/systemd-wrapper.sh.in
new file mode 100644
index 0000000..d931200
--- /dev/null
+++ b/sh/systemd-wrapper.sh.in
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+CONFDIR="@CONFDIR@"
+LIBEXECDIR="@LIBEXECDIR@/sh"
+INITDIR="@INITDIR@"
+INIT=systemd
+
+usage() {
+  echo "netifrc systemd wrapper"
+  echo "Usage:"
+  echo "  systemd-wrapper.sh -i <interface> <command>"
+  echo "  where command is start|stop"
+}
+
+die() {
+  echo "$@"
+  exit -1
+}
+
+while getopts "i:" opt; do
+  case $opt in
+	i)
+		RC_IFACE=$OPTARG;;
+  esac
+done
+shift $((OPTIND -1))
+
+[ -z "$RC_IFACE" ] && die "Missing Parameter Interface"
+
+RC_SVCPREFIX="net"
+RC_SVCNAME="$RC_SVCPREFIX"."$RC_IFACE"
+RC_UNAME=$(uname)
+# XXX Find out the systemd way of doing this
+RC_GOINGDOWN=no
+
+# In Openrc systems this has value /run/openrc
+SVCDIR="/run/netifrc"
+# OpenRC saves values in $SVCDIR/options/$SVCNAME/$OPTION
+# In non OpenRC setting this is saved in /run/netifrc/options/$SVCNAME/$OPTION
+OPTIONSDIR="${SVCDIR}/options/${RC_SVCNAME}"
+STATEDIR="${SVCDIR}/${RC_SVCNAME}"
+
+# Source the config file
+if [ -f "$CONFDIR/$RC_SVCPREFIX" ]; then
+	. "$CONFDIR/$RC_SVCPREFIX"
+fi
+
+# Source the actual runscript
+if [ -f "$INITDIR/${RC_SVCPREFIX}.lo" ]; then
+	. "$INITDIR/${RC_SVCPREFIX}.lo"
+else
+	echo "$INITDIR/${RC_SVCPREFIX}.lo : Init file missing or invalid path"
+	exit -1
+fi
+
+netifrc_init() {
+	# Ensure OPTIONSDIR is present and writeable
+	mkdir -p "$OPTIONSDIR"
+	if [ ! -w "$OPTIONSDIR" ]; then
+		eerror "${OPTIONSDIR} does not exist or is not writeable"
+		exit -1;
+	fi
+	# Ensure STATEDIR is present and writeable
+	mkdir -p "$STATEDIR"
+	if [ ! -w "$STATEDIR" ]; then
+		eerror "${STATEDIR} does not exist or is not writeable"
+		exit -1;
+	fi
+}
+
+netifrc_cleanup() {
+	# Delete all the saved values
+	rm -f ${OPTIONSDIR}/*
+}
+
+rc=0
+case $1 in
+	start)
+		netifrc_init
+		start
+		rc=$?;;
+	stop)
+		stop
+		netifrc_cleanup
+		rc=$?;;
+	*)
+		die "Unrecognised command $1";;
+esac
+exit $rc
+
+# vi: ts=4 sw=4 noexpandtab


             reply	other threads:[~2015-01-09 17:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-09 17:17 Robin H. Johnson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-03-25  0:45 [gentoo-commits] proj/netifrc:master commit in: sh/ Patrick McLean
2019-04-21  5:34 Robin H. Johnson
2019-04-21  4:17 Robin H. Johnson
2016-10-24 22:26 Robin H. Johnson
2016-07-19 19:59 Robin H. Johnson
2015-01-22 23:01 Robin H. Johnson
2015-01-16 18:16 Robin H. Johnson
2015-01-16 18:16 Robin H. Johnson
2015-01-09 17:17 Robin H. Johnson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1420815985.55f4303617ecd81f8729e8f45a64d14a4a0df41b.robbat2@OpenRC \
    --to=robbat2@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox