return 1
}
-# Prints value of given option. If option is a flag and it's present,
-# it just returns 0. Otherwise 1 is returned.
-# $1 = options separated by commas
-# $2 = option we are interested in
-#
-# Example:
-# $1 = cipher=aes-cbc-essiv:sha256,hash=sha256,verify
-# $2 = hash
-# Output:
-# sha256
-getoptcomma() {
- local line=",$1,"
- local opt="$2"
- local tmp
-
- case "${line}" in
- *,${opt}=*,*)
- tmp="${line#*,"${opt}"=}"
- echo "${tmp%%,*}"
- return 0
- ;;
- *,${opt},*) return 0 ;;
- esac
- return 1
-}
-
# Splits given string 'str' with separator 'sep' into variables 'var1', 'var2',
# 'varN'. If number of fields is less than number of variables, remaining are
# not set. If number of fields is greater than number of variables, the last
fi
}
-check_occurances() {
- # Count the number of times the character $ch occurs in $str
- # Return 0 if the count matches the expected number, 1 otherwise
- local str="$1"
- local ch="$2"
- local expected="$3"
- local count=0
-
- while [ "${str#*"$ch"}" != "${str}" ]; do
- str="${str#*"$ch"}"
- count=$((count + 1))
- done
-
- [ $count -eq "$expected" ]
-}
-
incol2() {
debug_off
local check
mv -f "/tmp/$$-${_job}.sh" "$hookdir/${_hookname}/${_job}.sh"
}
-# inst_mount_hook <mountpoint> <prio> <name> <script>
-#
-# Install a mount hook with priority <prio>,
-# which executes <script> as soon as <mountpoint> is mounted.
-inst_mount_hook() {
- local _prio="$2" _jobname="$3" _script="$4"
- local _hookname
- _hookname="mount-$(str_replace "$1" '/' '\\x2f')"
- [ -d "$hookdir/${_hookname}" ] || mkdir -p "$hookdir/${_hookname}"
- inst_hook --hook "$_hookname" --unique --name "${_prio}-${_jobname}" "$_script"
-}
-
-# wait_for_mount <mountpoint>
-#
-# Installs a initqueue-finished script,
-# which will cause the main loop only to exit,
-# if <mountpoint> is mounted.
-wait_for_mount() {
- local _name
- _name="$(str_replace "$1" '/' '\\x2f')"
- printf '. /lib/dracut-lib.sh\nismounted "%s"\n' "$1" \
- >> "$hookdir/initqueue/finished/ismounted-${_name}.sh"
- {
- printf 'ismounted "%s" || ' "$1"
- printf 'warn "\"%s\" is not mounted"\n' "$1"
- } >> "$hookdir/emergency/90-${_name}.sh"
-}
-
killproc() {
debug_off
local _exe