~ubuntu-branches/ubuntu/raring/mdadm/raring

« back to all changes in this revision

Viewing changes to debian/initramfs/hook

  • Committer: Package Import Robot
  • Author(s): Michael Tokarev, Sergey B Kirpichev, Michael Tokarev, Dmitrijs Ledkovs
  • Date: 2012-08-25 16:25:37 UTC
  • mto: This revision was merged to the branch mainline in revision 68.
  • Revision ID: package-import@ubuntu.com-20120825162537-3zezwh0cezycilrx
Tags: 3.2.5-2
[ Sergey B Kirpichev ]
* Fix mdadm.lintian-overrides
* Fix spelling in binaries, fix lintian warnings
  manpage-has-errors-from-man and hyphen-used-as-minus-sign
* Drop unused debconf templates
* Implement status option for mdadm-raid init.d script
* Fix lintian info's conflicts-with-version: Conflicts -> Breaks

[ Michael Tokarev ]
* fix spelling mistakes in previous changelog entry
* some cleanups for checkarray:
 - change --help printing and shorten/simplify the text
 - make --quiet cumulative and stop documenting --real-quiet
 - do not prduce help in case of incorrect usage, and exit with 1
* fixes for initramfs integration (Closes: #644389, #678262, #685161):
 - check INITRDSTART=none early
 - do not explicitly load raid level modules (modprobe/kmod does this)
 - do not collect needed raid levels (we include all modules anyway)
 - load md_mod explicitly since we need to change global parameter

[ Dmitrijs Ledkovs ]
* Use dh_installinit with --no-restart-on-upgrade, which will start
  arrays, but will not stop them during upgrade. (Closes: 678971)
* Copy local administrator's modified udev rules as well as the system
  one. (Closes: #678973)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/sh
2
2
#
3
 
# Copyright © 2006-2008 Martin F. Krafft <madduck@debian.org>
 
3
# Copyright © 2006-2008 Martin F. Krafft <madduck@debian.org>,
 
4
#             2012 Michael Tokarev <mjt@tls.msk.ru>
4
5
# based on the scripts in the initramfs-tools package.
5
6
# released under the terms of the Artistic Licence.
6
7
#
74
75
[ -z "$INITRDSTART" ] && INITRDSTART=none
75
76
 
76
77
DESTMDADMCONF=$DESTDIR/etc/mdadm/mdadm.conf
77
 
DESTCONFIG=$DESTDIR/conf/conf.d/md
 
78
DESTCONFIG=$DESTDIR/conf/mdadm
78
79
 
79
80
if [ -f $CONFIG ]; then
80
81
  homehost="$(sed -ne 's,^[[:space:]]*HOMEHOST[[:space:]]*,,p' $CONFIG)"
163
164
  info "letting initramfs assemble auto-detected arrays."
164
165
  exit 0
165
166
else
166
 
  # obtain dev:level pairs from config file, honouring multiline entries
167
 
  devpairs="$(
 
167
  # obtain devices list from config file, honouring multiline entries
 
168
  devices="$(
 
169
    dev=
168
170
    while read line; do
169
171
      case "$line" in
170
172
        (ARRAY*) :;;
173
175
      for atom in $line; do
174
176
        case "$atom" in
175
177
          (/dev*) dev=$atom;;
176
 
          (level=raid*|level=linear|level=multipath) level=${atom#level=};;
177
 
          (level=*)
178
 
            err "invalid level specified in ARRAY statement in $CONFIG:"
179
 
            err "  $line"
180
 
            err "levels should be either raid*, linear, or multipath."
181
 
            warn "falling back to emergency procedure in initramfs."
182
 
            exit 1
183
 
            ;;
184
 
          (*) :;;
185
178
        esac
186
179
      done
187
 
      [ -n "${dev:-}" ] || continue
188
180
 
189
181
      # /dev/mdX and /dev/md/X are the same, really
190
182
      case "$dev" in
 
183
        "") continue ;;
191
184
        (/dev/md/*) alt=/dev/md${dev##*/};;
192
185
        (/dev/md*) alt=/dev/md/${dev#/dev/md};;
193
186
        (*)
200
193
        dev="$alt"
201
194
      fi
202
195
 
203
 
      echo -n "${dev}:"
204
 
      if [ -n "${level:-}" ]; then
205
 
        echo -n "$level"
206
 
      else
207
 
        echo -n "$($MDADM --detail $dev | sed -rne 's,[[:space:]]+Raid Level : ,,p')"
208
 
      fi
209
 
      echo -n ' '
 
196
      echo "$dev"
210
197
    done < $DESTMDADMCONF)" || exit $?
211
198
fi
212
199
 
213
 
uniquify()
214
 
{
215
 
  for i in $@; do echo "$i"; done | sort -u
216
 
}
217
 
 
218
 
if [ "$INITRDSTART" != none ] && [ -n "$devpairs" ]; then
219
 
  echo "MD_DEVPAIRS='${devpairs% }'" >> $DESTCONFIG
220
 
 
221
 
  devs= levels=
222
 
  for i in $devpairs; do
223
 
    dev=${i%:*}
224
 
    level=${i##*:}
225
 
    case "$INITRDSTART" in
226
 
      all|*${dev}*)
227
 
        devs="${devs:+$devs }$dev"
228
 
        levels="${levels:+$levels }$level"
 
200
if [ "$INITRDSTART" != none ] && [ -n "$devices" ]; then
 
201
 
 
202
  devs=
 
203
  for dev in $devices; do
 
204
    case "$INITRDSTART " in
 
205
      all|*${dev}[[:space:]]*)
 
206
        case "$devs " in        # uniquiness
 
207
          (*${dev}\ *) :;;
 
208
          (*) devs="${devs:+$devs }$dev" ;;
 
209
        esac
229
210
        ;;
230
211
      *) :;;
231
212
    esac
244
225
  done
245
226
 
246
227
  for i in $INITRDSTART; do
247
 
    case "$INITRDSTART" in all|none|'') break;; *) :;; esac
 
228
    case "$INITRDSTART" in all) break;; *) :;; esac
248
229
    case "$devs" in
249
230
      *${i}*) continue;;
250
231
      *) :;;
257
238
    break
258
239
  done
259
240
 
260
 
  echo "MD_LEVELS='$levels'" >> $DESTCONFIG
261
241
  if [ "$INITRDSTART" = all ]; then
262
242
    echo "MD_DEVS=all" >> $DESTCONFIG
263
243
  else
264
244
    echo "MD_DEVS='$devs'" >> $DESTCONFIG
265
245
  fi
266
246
 
267
 
  # handle module synonyms
268
 
  modules="$(echo $levels \
269
 
    | sed -re 's,\<[[:digit:]]+\>,raid&,g;   # prefix digits with raid
270
 
               s,stripe,raid0,g;             # striping is raid0
271
 
               s,mirror,raid1,g;             # mirroring is raid1
272
 
               s,raid4,raid5,g;              # use raid5 to handle raid4
273
 
               s,mp,multipath,g              # mp is multipath
274
 
               ')"
275
 
 
276
 
  # if raid456 module is present, use it for raid[456]
277
 
  modprobe --set-version="$version" --show-depends raid456 >/dev/null 2>&1 \
278
 
    && modules="$(echo $modules | sed -e 's,raid[456],raid456,g')"
279
 
 
280
 
  modules="$(uniquify $modules | tr '\n' ' ')"
281
 
  echo "MD_MODULES='${modules% }'" >> $DESTCONFIG
282
 
 
283
247
  if [ "$INITRDSTART" = all ]; then
284
248
    info "will start all available MD arrays from the initial ramdisk."
285
249
  else
289
253
  fi
290
254
 
291
255
  # Copy udev rules, which udev no longer does
292
 
  mkdir -p $DESTDIR/lib/udev/rules.d/
293
 
  cp /lib/udev/rules.d/64-md-raid.rules $DESTDIR/lib/udev/rules.d/
 
256
  UDEV_RULE=64-md-raid.rules
 
257
  for rules_folder in /lib/udev/rules.d /etc/udev/rules.d; do
 
258
      if [ -f $rules_folder/$UDEV_RULE ]; then
 
259
          mkdir -p $DESTDIR$rules_folder
 
260
          cp $rules_folder/$UDEV_RULE $DESTDIR$rules_folder/$UDEV_RULE
 
261
      fi
 
262
  done
294
263
 
295
264
else
296
265
  echo "MD_DEVS=none" >> $DESTCONFIG
297
 
  echo "MD_MODULES=''" >> $DESTCONFIG
298
266
  info "no MD arrays will be started from the initial ramdisk."
299
267
fi
300
268