summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilly Tarreau <w@1wt.eu>2007-10-01 11:51:37 +0200
committerWilly Tarreau <w@1wt.eu>2007-10-01 11:51:37 +0200
commitf8e1bbf8a86244ae7eafcc299b4b4f91cf5d26e6 (patch)
treee3d44b7ba9c9225b8b918430bb7a8c95908fbc08
parent* functions: do not report an error if an instance is not declared (diff)
downloadinit-scripts-f8e1bbf8a86244ae7eafcc299b4b4f91cf5d26e6.tar.gz
* added bootmodules, autoraid, listpart, service
-rw-r--r--.flxfiles4
-rw-r--r--.flxpkg/build.cfg3
-rwxr-xr-xsbin/autoraid75
-rwxr-xr-xsbin/bootmodules31
-rwxr-xr-xsbin/listpart54
-rwxr-xr-xsbin/service8
6 files changed, 175 insertions, 0 deletions
diff --git a/.flxfiles b/.flxfiles
index 4b8f063..218c6f7 100644
--- a/.flxfiles
+++ b/.flxfiles
@@ -24,6 +24,10 @@ sbin/rc.K
sbin/rc.M
sbin/rc.S
sbin/initscript
+sbin/autoraid
+sbin/bootmodules
+sbin/listpart
+sbin/service
etc/init.d
etc/initscript
etc/startup.rc
diff --git a/.flxpkg/build.cfg b/.flxpkg/build.cfg
index 9407901..2a5d64c 100644
--- a/.flxpkg/build.cfg
+++ b/.flxpkg/build.cfg
@@ -14,6 +14,9 @@ function do_prepack {
# non-root monitors which use them to check a service status.
set_default_perm $ROOTDIR
chmod 740 $ROOTDIR/.preinit $ROOTDIR/etc/startup.rc
+
+ # just in case it would not exist
+ mkdir -p $PKGDIR/compiled
}
function do_strip {
diff --git a/sbin/autoraid b/sbin/autoraid
new file mode 100755
index 0000000..e0a72b7
--- /dev/null
+++ b/sbin/autoraid
@@ -0,0 +1,75 @@
+#!/bin/bash
+
+# /sbin/autoraid - Formilux RAID starter - v0.1 - 2006-07-03
+#
+# Copyright (C) 2001-2006 Benoit Dolez & Willy Tarreau
+# mailto: benoit@ant-computing.com,willy@ant-computing.com
+#
+# This program is licenced under GPLv2 ( http://www.gnu.org/licenses/gpl.txt )
+
+# This script looks for *real* partitions in /proc/partitions (those belonging
+# to another device) and passes their names to mdadm to startt he RAID devices.
+# This operation can be bound to one disk only if needed by passing its name on
+# the command line.
+
+MDADM=/sbin/mdadm
+
+usage() {
+ echo "Usage: ${0##*/} [ disk ]"
+ echo " Will start raid for all the partitions found in /proc/partitions,"
+ echo " possibly limited to those attached to <disk>."
+ exit 1
+}
+
+if [ $# -gt 0 ]; then
+ [ "$1" == "-h" -o "$1" == "--help" ] && usage
+ disk="${1#/dev/}"
+ shift
+fi
+
+# Note: this script expects that the input file is sorted by device name,
+# or at least that the MBRs are ALWAYS before the partitions !
+
+list=( )
+while read maj min blo name stats; do
+ [ -n "$name" ] || continue
+ [ "$maj" != "major" ] || continue
+ [ "$name" != "$mbr" ] || continue
+
+ if [ -n "$mbr" -a -z "${name##$mbr*}" ]; then
+ [ -z "$disk" -o "$mbr" = "$disk" ] && list[${#list[@]}]="/dev/$name";
+ else
+ mbr="$name"
+ fi
+done </proc/partitions
+
+dev_list=( )
+$MDADM -Q "${list[@]}" 2>/dev/null | { \
+ while read dev dum1 num dum2 tot device dum4 type mddev rest; do
+ dev="${dev%:}"
+ mddev="${mddev%.}"
+ [ "$dum1" == "device" ] || continue
+ # we have dev and mddev. We'll look for an association in the dev_list
+ idx=0
+ while [ $idx -lt ${#dev_list[@]} ]; do
+ # try to reuse /dev/md entry
+ if [ -n "${dev_list[idx]}" -a -z "${dev_list[idx]##$mddev *}" ]; then
+ dev_list[idx]="${dev_list[idx]} $dev"
+ break;
+ fi
+ ((idx++))
+ done
+ # create a new entry
+ if [ $idx -ge ${#dev_list[@]} ]; then
+ dev_list[${#dev_list[@]}]="$mddev $dev"
+ fi
+ done
+
+ idx=0
+ while [ $idx -lt ${#dev_list[@]} ]; do
+ $MDADM --assemble ${dev_list[idx]}
+ ((idx++))
+ done
+}
+
+exit 0
diff --git a/sbin/bootmodules b/sbin/bootmodules
new file mode 100755
index 0000000..9b9b9e8
--- /dev/null
+++ b/sbin/bootmodules
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+# sbin/bootmodules - Formilux early modules loader - v0.1 - 2006-06-30
+#
+# Copyright (C) 2001-2006 Benoit Dolez & Willy Tarreau
+# mailto: benoit@ant-computing.com,willy@ant-computing.com
+#
+# This program is licenced under GPLv2 ( http://www.gnu.org/licenses/gpl.txt )
+
+# This script looks for strings beginning with 'load=' in /proc/modules.
+# It accepts modules lists of the form :
+# module_name[:arg=value[,value]*]*[;module_name[:....]]
+
+args=( $(< /proc/cmdline) )
+
+argn=0
+while [ $argn -lt ${#args[@]} ]; do
+ arg="${args[argn]}"
+ ((argn++))
+ [ -n "${arg##load=*}" ] && continue;
+ arg="${arg#load=}"
+ while [ -n "$arg" ]; do
+ str="${arg%%;*}"
+ arg="${arg#$str}"; arg="${arg#;}"
+ str="${str//:/ }"
+ if [ -n "$str" ]; then
+ echo "# Loading module '${str%% *}' from kernel command line..."
+ /sbin/modprobe ${str//:/ }
+ fi
+ done
+done
diff --git a/sbin/listpart b/sbin/listpart
new file mode 100755
index 0000000..c6784fe
--- /dev/null
+++ b/sbin/listpart
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+# reads input formated like /proc/partitions, and can output the list of
+# MBR devices which do have partitions and the list of those partitions.
+#
+# It should be used to discover RAID devices with mdadm this way :
+# mdadm --examine --scan $(/tmp/listpart.sh -p </proc/partitions ) /dev/null
+# (the /dev/null is there to avoid mdadm doing a full scan if no device is
+# reported).
+#
+# mdadm -Q $(/tmp/listpart.sh -p </proc/partitions ) | grep device | tr -d ':.'| awk '{print $9 FS $1}'|sort
+
+# Use "-m" [part] to list the MBRs which have partitions (or the one
+# which has <part>).
+# Use "-p" [mbr] to list the partitions, or the partitions of <mbr>.
+
+usage() {
+ echo "Usage: ${0##*/} {-m|-p} [ part | mbr ] < /proc/partitions"
+ echo " - with '-m', will list the Master Boot Records found in the file"
+ echo " and for which a partition exists, or partition <part> exists."
+ echo " - with '-p', will list the partitions found in the file, with the"
+ echo " ability to filter only those attached to MBR <mbr>."
+ exit 1
+}
+
+if [ $# -gt 0 ]; then
+ arg1="$1"
+ [ "$arg1" == "-m" -o "$arg1" == "-p" ] || usage
+ shift
+else
+ usage
+fi
+
+if [ $# -gt 0 ]; then arg2="${1#/dev/}"; shift; fi
+
+# Note: this script expects that the input file is sorted by device name,
+# or at least that the MBRs are ALWAYS before the partitions !
+
+while read maj min blo name stats; do
+ [ -n "$name" ] || continue
+ [ "$maj" != "major" ] || continue
+ [ "$name" != "$mbr" ] || continue
+
+ if [ -n "$mbr" -a -z "${name##$mbr*}" ]; then
+ [ "$arg1" = "-m" ] && [ -z "$arg2" -o "$name" = "$arg2" ] && partfound=1
+ [ "$arg1" = "-p" ]&&[ -z "$arg2" -o "$mbr" = "$arg2" ] && echo "/dev/$name"
+ else
+ [ -n "$mbr" -a "$arg1" = "-m" -a "$partfound" == "1" ] && echo "/dev/$mbr"
+ partfound=0
+ mbr="$name"
+ fi
+done
+[ -n "$mbr" -a "$arg1" = "-m" -a "$partfound" == "1" ] && echo "/dev/$mbr"
+exit 0
diff --git a/sbin/service b/sbin/service
new file mode 100755
index 0000000..39b44b4
--- /dev/null
+++ b/sbin/service
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+svc="$1" ; shift
+if [ ! -x "/sbin/init.d/$svc" ]; then
+ echo "Service not found : $svc"
+ exit 1
+fi
+exec "/sbin/init.d/$svc" "$@"