diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2017-10-09 18:53:29 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2017-10-09 18:53:29 +0100 |
commit | 4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch) | |
tree | ba5f07bf3f9d22d82e54a462313f5d244036c768 /sys-block/vblade/files |
reinit the tree, so we can have metadata
Diffstat (limited to 'sys-block/vblade/files')
-rw-r--r-- | sys-block/vblade/files/conf.d-vblade | 25 | ||||
-rw-r--r-- | sys-block/vblade/files/init.d-vblade.vblade0 | 120 | ||||
-rw-r--r-- | sys-block/vblade/files/init.d-vblade.vblade0-r1 | 125 | ||||
-rw-r--r-- | sys-block/vblade/files/vbladed | 19 |
4 files changed, 289 insertions, 0 deletions
diff --git a/sys-block/vblade/files/conf.d-vblade b/sys-block/vblade/files/conf.d-vblade new file mode 100644 index 000000000000..4948543ee6e2 --- /dev/null +++ b/sys-block/vblade/files/conf.d-vblade @@ -0,0 +1,25 @@ +# Copyright 1999-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +# If you intent to run only one vblade, you should edit config_vblade0 +# SYNTAX: SHELF SLOT NETIF SOURCE +config_vblade0="0 0 eth0 /root/test.img" + +# SHELF is a numeric value >= 0 +# SLOT is a numeric value 0 <= X <= 15 +# NETIF is a network interface name +# SOURCE is a file or block device + +# For additional vblades, run: +# ln -s /etc/init.d/vblade.vblade0 /etc/init.d/vblade.$NAME +# and define config_$NAME in this file. + +# Note that the combination of SHELF:SLOT:NETIF should be unique for your +# network. + +# Some additional examples +# config_vblade1="0 1 eth0 /root/test2.img" +# config_foobar="0 1 eth1 /dev/md0" + +# vim: ft=filetype=gentoo-conf-d syntax=filetype=gentoo-conf-d : +# vim: ai sw=2 sts=2 ts=2 : diff --git a/sys-block/vblade/files/init.d-vblade.vblade0 b/sys-block/vblade/files/init.d-vblade.vblade0 new file mode 100644 index 000000000000..253304dc187a --- /dev/null +++ b/sys-block/vblade/files/init.d-vblade.vblade0 @@ -0,0 +1,120 @@ +#!/sbin/openrc-run +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License, v2 or later + +extra_commands="checkconfig" + +depend() { + need net +} + +# bug #218043 +if [ ! -f /etc/init.d/sysfs ]; then + conf="$(add_suffix /etc/conf.d/vblade)" + [[ -e "${conf}" ]] && source "${conf}" + vblade_name="${myservice#*.}" +else + conf="/etc/conf.d/vblade" + [[ -e "${conf}" ]] && source "${conf}" + vblade_name="${RC_SVCNAME#*.}" +fi + +vblade_conf_variable="config_${vblade_name}" +vblade_conf="${!vblade_conf_variable}" +pidfile="/var/run/vblade-${vblade_name}.pid" +srvname="vblade.${vblade_name}" + +getconfig() { + tmp="${vblade_conf}" + shelf="${tmp/ *}" + tmp="${tmp#* }" + slot="${tmp/ *}" + tmp="${tmp#* }" + netif="${tmp/ *}" + tmp="${tmp#* }" + src="${tmp}" + export shelf slot netif src +} + +checkconfig() { + if [ -z "${vblade_conf}" ]; then + eerror "vblade configuration not specified for ${vblade_name}" + return 1 + fi + getconfig + + is_valid_numeric "${shelf}" 0 + if [[ $? -ne 0 ]]; then + eerror "Shelf '${shelf}' is non-numeric or less than zero." + return 1 + fi + is_valid_numeric "${slot}" 0 15 + if [[ $? -ne 0 ]]; then + eerror "Slot '${slot}' is outside the valid range [0..15]." + return 1 + fi + + sysfs_base="/sys/class/net/" + procfs_base="/proc/sys/net/ipv4/conf/" + if test ! \( -e "${sysfs_base}${netif}" -o -e "${procfs_base}${netif}" \); then + eerror "Network interface '${netif}' does not exist" + return 1 + fi + + if test ! \( -f "${src}" -o -b "${src}" \) ; then + eerror "Source '${src}' must be a file or block device" + return 1 + fi + + if test ! \( -e "${src}" -a -r "${src}" \) ; then + eerror "Source '${src}' is not readable." + return 1 + fi + + return 0 +} + +is_valid_numeric() { + num="${1}" + min="${2}" + max="${3}" + # non-numeric + test "$num" -ge "0" 2>/dev/null + rc=$? + test "$rc" -eq 2 && return 2 + # check for min + test -z "$min" && return 0 + test "$num" -lt "$min" && return 1 + # check for max + test -z "$max" && return 0 + test "$num" -gt "$max" && return 1 + # done + return 0 +} + +start() { + checkconfig || return 1 + getconfig + ebegin "Starting ${srvname}: e${shelf}.${slot} on ${netif} using '${src}'" + export LOGTAG="${srvname}" + start-stop-daemon --start --quiet \ + --pidfile ${pidfile} --background \ + --make-pidfile --exec /usr/sbin/vbladed -- \ + ${shelf} ${slot} ${netif} "${src}" + eend $? + + #${shelf} ${slot} ${netif} "${src}" 2>&1 | logger -t ${srvname} & +} + +stop() { + ebegin "Stopping ${srvname}" + #start-stop-daemon --stop --quiet --pidfile ${pidfile} + getconfig + ps -Ao pid,args | egrep "^[[:space:]]*[[:digit:]]+ /usr/sbin/vbladed? ${shelf} ${slot}" | awk '{print $1}' | xargs kill + eend $? + + #start-stop-daemon --stop --quiet --exec /usr/sbin/vblade +} + +# vim: ft=gentoo-init-d syntax=gentoo-init-d : +# vim: ai sw=4 sts=4 ts=4 : diff --git a/sys-block/vblade/files/init.d-vblade.vblade0-r1 b/sys-block/vblade/files/init.d-vblade.vblade0-r1 new file mode 100644 index 000000000000..174e473ffc17 --- /dev/null +++ b/sys-block/vblade/files/init.d-vblade.vblade0-r1 @@ -0,0 +1,125 @@ +#!/sbin/openrc-run +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License, v2 or later + +extra_commands="checkconfig" + +depend() { + need net +} + +# bug #218043 +if [ ! -f /etc/init.d/sysfs ]; then + conf="$(add_suffix /etc/conf.d/vblade)" + [[ -e "${conf}" ]] && source "${conf}" + vblade_name="${myservice#*.}" +else + conf="/etc/conf.d/vblade" + [[ -e "${conf}" ]] && source "${conf}" + vblade_name="${RC_SVCNAME#*.}" +fi + +vblade_conf_variable="config_${vblade_name}" +vblade_conf="${!vblade_conf_variable}" +pidfile="/var/run/vblade-${vblade_name}.pid" +srvname="vblade.${vblade_name}" + +getconfig() { + args="" + while getopts b:dsrm: FLAG; do + case "${FLAG}" in + b) is_valid_numeric "${OPTARG}" && args="${args} -b ${OPTARG}" || ewarn "vblade block size argument is non-numeric IGNORING";; + + d|s|r) args="${args} -${FLAG}";; + + # FIXME: there is no sanity checking on the MAC address...we'll leave that up to vblade + m) args="${args} -m ${OPTARG}";; + esac + done + + shift $(( OPTIND - 1 )) + + shelf=${1} + slot=${2} + netif=${3} + src=${4} + + export args shelf slot netif src +} + +checkconfig() { + if [ -z "${vblade_conf}" ]; then + eerror "vblade configuration not specified for ${vblade_name}" + return 1 + fi + getconfig ${vblade_conf} + + is_valid_numeric "${shelf}" 0 + if [[ $? -ne 0 ]]; then + eerror "Shelf '${shelf}' is non-numeric or less than zero." + return 1 + fi + is_valid_numeric "${slot}" 0 15 + if [[ $? -ne 0 ]]; then + eerror "Slot '${slot}' is outside the valid range [0..15]." + return 1 + fi + + sysfs_base="/sys/class/net/" + procfs_base="/proc/sys/net/ipv4/conf/" + if test ! \( -e "${sysfs_base}${netif}" -o -e "${procfs_base}${netif}" \); then + eerror "Network interface '${netif}' does not exist" + return 1 + fi + + if test ! \( -f "${src}" -o -b "${src}" \) ; then + eerror "Source '${src}' must be a file or block device" + return 1 + fi + + if test ! \( -e "${src}" -a -r "${src}" \) ; then + eerror "Source '${src}' is not readable." + return 1 + fi + + return 0 +} + +is_valid_numeric() { + num="${1}" + min="${2}" + max="${3}" + # non-numeric + test "$num" -ge "0" 2>/dev/null + rc=$? + test "$rc" -eq 2 && return 2 + # check for min + test -z "$min" && return 0 + test "$num" -lt "$min" && return 1 + # check for max + test -z "$max" && return 0 + test "$num" -gt "$max" && return 1 + # done + return 0 +} + +start() { + checkconfig || return 1 + ebegin "Starting ${srvname}: e${shelf}.${slot} on ${netif} using '${src}'" + export LOGTAG="${srvname}" + start-stop-daemon --start --quiet \ + --pidfile ${pidfile} --background \ + --make-pidfile --exec /usr/sbin/vbladed -- \ + ${args} ${shelf} ${slot} ${netif} "${src}" + eend $? +} + +stop() { + ebegin "Stopping ${srvname}" + getconfig ${vblade_conf} + ps -Ao pid,args | egrep "^[[:space:]]*[[:digit:]]+ /usr/sbin/vblade.* ${shelf} ${slot} " | awk '{print $1}' | xargs kill + eend $? +} + +# vim: ft=gentoo-init-d syntax=gentoo-init-d : +# vim: ai sw=4 sts=4 ts=4 : diff --git a/sys-block/vblade/files/vbladed b/sys-block/vblade/files/vbladed new file mode 100644 index 000000000000..5822d677843a --- /dev/null +++ b/sys-block/vblade/files/vbladed @@ -0,0 +1,19 @@ +#!/bin/sh +# Copyright 1999-2004 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# +# run a vblade daemon using a logger process +# output is directed to syslogd +# +# Although logging goes to syslog, let's going to +# protect ourselves against the most common way or +# calling vbladed: without arguments. +if [ -z "$*" ] +then + echo "Usage: vbladed <shelf> <slot> <ethn> <device>" >&2 + exit 1 +fi + +[ -z "${LOGTAG}" ] && LOGTAG=vbladed + +/usr/sbin/vblade "${@}" </dev/null 2>&1 | /usr/bin/logger -t "${LOGTAG}" |