]>
Commit | Line | Data |
---|---|---|
917f3e4d HH |
1 | #!/bin/bash |
2 | # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- | |
3 | # ex: ts=8 sw=4 sts=4 et filetype=sh | |
4 | # | |
5 | # Copyright 2013 Red Hat, Inc. All rights reserved. | |
6 | # | |
7 | # This program is free software; you can redistribute it and/or modify | |
8 | # it under the terms of the GNU General Public License as published by | |
9 | # the Free Software Foundation; either version 2 of the License, or | |
10 | # (at your option) any later version. | |
11 | # | |
12 | # This program is distributed in the hope that it will be useful, | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | # GNU General Public License for more details. | |
16 | # | |
17 | # You should have received a copy of the GNU General Public License | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | # | |
20 | ||
21 | __contains_word () { | |
22 | local word=$1; shift | |
23 | for w in $*; do [[ $w = $word ]] && return 0; done | |
24 | return 1 | |
25 | } | |
26 | ||
27 | _dracut() { | |
28 | local field_vals= cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} | |
29 | local -A OPTS=( | |
30 | [STANDALONE]='-f -v -q -l -H -h -M -N | |
31 | --ro-mnt --force --kernel-only --no-kernel --strip --nostrip | |
32 | --hardlink --nohardlink --noprefix --mdadmconf --nomdadmconf | |
33 | --lvmconf --nolvmconf --debug --profile --verbose --quiet | |
34 | --local --hostonly --no-hostonly --fstab --help --bzip2 --lzma | |
35 | --xz --no-compress --gzip --list-modules --show-modules --keep | |
5bbfd484 | 36 | --printsize --regenerate-all --noimageifnotneeded --early-microcode |
1743473b | 37 | --no-early-microcode --print-cmdline' |
917f3e4d HH |
38 | |
39 | [ARG]='-a -m -o -d -I -k -c -L --kver --add --force-add --add-drivers | |
40 | --omit-drivers --modules --omit --drivers --filesystems --install | |
41 | --fwdir --libdirs --fscks --add-fstab --mount --device --nofscks | |
42 | --kmoddir --conf --confdir --tmpdir --stdlog --compress --prefix | |
43 | --kernel-cmdline --sshkey' | |
44 | ) | |
45 | ||
46 | if __contains_word "$prev" ${OPTS[ARG]}; then | |
47 | case $prev in | |
46a885bf | 48 | --kmoddir|-k|--fwdir|--confdir|--tmpdir) |
917f3e4d HH |
49 | comps=$(compgen -d -- "$cur") |
50 | compopt -o filenames | |
51 | ;; | |
46a885bf HH |
52 | -c|--conf|--sshkey|--add-fstab|--add-device|-I|--install) |
53 | comps=$(compgen -f -- "$cur") | |
54 | compopt -o filenames | |
55 | ;; | |
917f3e4d HH |
56 | -a|-m|-o|--add|--modules|--omit) |
57 | comps=$(dracut --list-modules 2>/dev/null) | |
58 | ;; | |
fb05f987 | 59 | --kver) |
46a885bf | 60 | comps=$(cd /lib/modules; echo [0-9]*) |
fb05f987 | 61 | ;; |
917f3e4d HH |
62 | *) |
63 | return 0 | |
64 | ;; | |
65 | esac | |
66 | COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) | |
67 | return 0 | |
68 | fi | |
69 | ||
70 | if [[ $cur = -* ]]; then | |
71 | COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) | |
72 | return 0 | |
73 | fi | |
74 | } | |
75 | ||
76 | complete -F _dracut dracut |