summaryrefslogtreecommitdiff
path: root/user
diff options
context:
space:
mode:
Diffstat (limited to 'user')
-rw-r--r--user/mdadm/APKBUILD56
-rw-r--r--user/mdadm/mdadm-raid.initd48
-rw-r--r--user/mdadm/mdadm.confd5
-rw-r--r--user/mdadm/mdadm.initd28
4 files changed, 137 insertions, 0 deletions
diff --git a/user/mdadm/APKBUILD b/user/mdadm/APKBUILD
new file mode 100644
index 000000000..14861aadf
--- /dev/null
+++ b/user/mdadm/APKBUILD
@@ -0,0 +1,56 @@
+# Contributor: Valery Kartel <valery.kartel@gmail.com>
+# Contributor: Carlo Landmeter <clandmeter at gmail>
+# Maintainer:
+pkgname=mdadm
+pkgver=4.0
+pkgrel=1
+pkgdesc="Tool for managing Linux soft RAID arrays"
+url="http://neil.brown.name/blog/mdadm"
+arch="all"
+options="!check" # No test suite.
+license="GPL-2.0-only"
+depends=""
+makedepends="groff linux-headers"
+subpackages="$pkgname-doc $pkgname-misc::noarch $pkgname-openrc
+ $pkgname-udev::noarch"
+source="https://mirrors.kernel.org/pub/linux/utils/raid/$pkgname/$pkgname-$pkgver.tar.gz
+ $pkgname.initd
+ $pkgname.confd
+ $pkgname-raid.initd
+ "
+
+build() {
+ cd "$builddir"
+ make
+}
+
+package() {
+ cd "$builddir"
+ make DESTDIR="$pkgdir" install
+ install -Dm644 $pkgname.conf-example "$pkgdir"/etc/$pkgname.conf
+ install -Dm644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
+ install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+ install -Dm755 "$srcdir"/$pkgname-raid.initd "$pkgdir"/etc/init.d/$pkgname-raid
+}
+
+udev() {
+ pkgdesc="$pkgdesc (udev rules)"
+ install_if="eudev $pkgname=$pkgver-r$pkgrel"
+
+ mkdir -p "$subpkgdir"
+ mv "$pkgdir"/lib "$subpkgdir"/
+}
+
+misc() {
+ pkgdesc="$pkgdesc (misc scripts)"
+ depends="$pkgname bash"
+
+ cd "$builddir"
+ install -Dm755 misc/mdcheck "$subpkgdir"/usr/sbin/mdcheck
+ install -Dm755 misc/syslog-events "$subpkgdir"/usr/sbin/handle-mdadm-events
+}
+
+sha512sums="032218da3e2054571b52c276ada1d9b052c473ed65660c5b58d3105841d5e2e124c573b882b668fb92b512d87f94e6f3bca3b0ce0c09a92696e9cc2f86c9f1d3 mdadm-4.0.tar.gz
+ca5f4e3ff5b284102b44e818d11622e1889066e3d18edce2d62c1a44ee8f4cfdc0979121c0462a916c638423c5ebc706c46aa996a7c4f68e030589adc62803f4 mdadm.initd
+7d45bf489ef93a4f217ffcf72311eb661b8de7fbf63a5344697252c0d3a684b0123ff60efa5f218da4eb4cda7c88d91c2ef3625d5e44a588e3e1210cb60b0ab9 mdadm.confd
+37022593ba090eb0690669b99d6386152242c017c1e608cea7b5420b7a6f754b377e916e4f81e2abf9941e791db78b5820e63db0e706d5de8b35e796678e921c mdadm-raid.initd"
diff --git a/user/mdadm/mdadm-raid.initd b/user/mdadm/mdadm-raid.initd
new file mode 100644
index 000000000..368860ae0
--- /dev/null
+++ b/user/mdadm/mdadm-raid.initd
@@ -0,0 +1,48 @@
+#!/sbin/openrc-run
+
+# script to start raid devices described in /etc/mdadm.conf.
+depend() {
+ before checkfs fsck swap
+ after modules
+}
+
+array_devices() {
+ awk '/^ARRAY/ {print $2}' /etc/mdadm.conf
+}
+
+start() {
+ [ -f /etc/mdadm.conf ] || return 0
+ # start all devices that are not already started
+ [ -f /proc/mdstat ] || modprobe md > /dev/null 2>&1
+ local tostart=
+ for i in $(array_devices); do
+ [ -b "$i" ] && continue
+ tostart="$tostart $i"
+ done
+ [ -z "$tostart" ] && return 0
+
+ ebegin "Starting RAID devices"
+ mdadm --assemble --scan --quiet $tostart
+ eend $?
+}
+
+is_mounted_as() {
+ local mnt
+ for mnt in $(awk "\$1 == \"$1\" {print \$2}" /proc/mounts); do
+ [ "$mnt" = "$2" ] && return 0
+ done
+ return 1
+}
+
+stop() {
+ # stop all raid devices except anything mounted as /
+ [ -f /etc/mdadm.conf ] || return 0
+ ebegin "Stopping RAID devices"
+ local tostop=
+ for i in $(array_devices); do
+ is_mounted_as $i / && continue
+ tostop="$tostop $i"
+ done
+ mdadm --stop --quiet $tostop
+ eend $?
+}
diff --git a/user/mdadm/mdadm.confd b/user/mdadm/mdadm.confd
new file mode 100644
index 000000000..f1ed9c41d
--- /dev/null
+++ b/user/mdadm/mdadm.confd
@@ -0,0 +1,5 @@
+# Misc options to pass to mdadm in monitor mode.
+# For more info, run `mdadm --monitor --help` or see
+# the mdadm(8) manpage.
+
+OPTS="--syslog"
diff --git a/user/mdadm/mdadm.initd b/user/mdadm/mdadm.initd
new file mode 100644
index 000000000..f799dd4d5
--- /dev/null
+++ b/user/mdadm/mdadm.initd
@@ -0,0 +1,28 @@
+#!/sbin/openrc-run
+
+# Sample init.d file for alpine linux.
+
+NAME=mdadm
+DAEMON=/sbin/$NAME
+
+depend() {
+ use logger dns net
+ after firewall
+}
+
+start() {
+ ebegin "Starting ${NAME}"
+ start-stop-daemon --start --quiet --background \
+ --exec ${DAEMON} -- \
+ --monitor --scan \
+ --daemonise ${OPTS}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ${NAME}"
+ start-stop-daemon --stop --quiet \
+ --exec ${DAEMON}
+ eend $?
+}
+