#!/usr/bin/sh #---------------------------------------------------------------------------- # /var/install/bin/setup-system-filesystems-mdadm-create-conf # # Creation: 2011-10-02 hbfl # Last Update: $Id$ # # Copyright (c) 2011-@@YEAR@@ Holger Bruenjes, holgerbruenjes(at)gmx(dot)net # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- # include eislib . /var/install/include/eislib package_name='mdadm' VERSION=3.0.1 #exec 2> /tmp/mdadm-create-conf$$ #set -x # --------------------------------------------------------------------------- # create header # --------------------------------------------------------------------------- create_conf_file() { cat > ${mdadm_conf} </dev/null | sort -u) if [ -n "${md_devices}" ] then md_devices_n=$(echo "${md_devices}" | wc -l) retvar=0 else if ! "${quiet:-false}" then echo mecho --error " No RAID(MD) devices found " echo anykey fi retvar=1 fi } # --------------------------------------------------------------------------- # get RAID(MD) discs # --------------------------------------------------------------------------- get_md_discs() { echo "DEVICE partitions" >>${mdadm_conf} # get devices mdadm --detail --scan >>${mdadm_conf} echo "PROGRAM ${mdadm_event_handler}" >>${mdadm_conf} for i in 0 1 2 3 4 do if grep -q "dev/md${i} " /etc/mdadm/mdadm.conf then sed -i "s|dev/md${i}|dev/md/${i}|" /etc/mdadm/mdadm.conf fi done } # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- main() { if [ "${1}" = "--quiet" ] then quiet=true fi mdadm_event_handler=/usr/libexec/mdadm/mdadm-event-handler.sh mdadm_conf=/etc/${package_name}/${package_name}.conf get_md_devices if [ ${retvar:-1} -eq 0 ] then mkdir -p /etc/${package_name} create_conf_file get_md_discs ${md_devices} else rm -f ${mdadm_conf} exit 1 fi exit 0 } # --------------------------------------------------------------------------- # call function main # --------------------------------------------------------------------------- main "${@}" # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------