fi
# Generic substring function. If $2 is in $1, return 0.
-strstr() { [[ $1 = *$2* ]]; }
+strstr() { [[ $1 = *"$2"* ]]; }
+# Generic glob matching function. If glob pattern $2 matches anywhere in $1, OK
+strglobin() { [[ $1 = *$2* ]]; }
+# Generic glob matching function. If glob pattern $2 matches all of $1, OK
+strglob() { [[ $1 = $2 ]]; }
# helper function for check() in module-setup.sh
# to check for required installed binaries
# Handle static ip configuration
do_static() {
- strstr $ip '*:*:*' && load_ipv6
+ strglobin $ip '*:*:*' && load_ipv6
linkup $netif
[ -n "$macaddr" ] && ip link set address $macaddr dev $netif
[ -n "$mtu" ] && ip link set mtu $mtu dev $netif
- if strstr $ip '*:*:*'; then
+ if strglobin $ip '*:*:*'; then
# note no ip addr flush for ipv6
ip addr add $ip/$mask ${srv:+peer $srv} dev $netif
wait_for_ipv6_dad $netif
# ip=<ipv4-address> means anaconda-style static config argument cluster:
# ip=<ip> gateway=<gw> netmask=<nm> hostname=<host> mtu=<mtu>
# ksdevice={link|bootif|ibft|<MAC>|<ifname>}
- if strstr "$autoconf" "*.*.*.*"; then
+ if strglob "$autoconf" "*.*.*.*"; then
ip="$autoconf"
gw=$(getarg gateway=)
mask=$(getarg netmask=)
netif=${netup%%.did-setup}
netif=${netif##*/net.}
- strstr "$netif" ":*:*:*:*:" && continue
+ strglobin "$netif" ":*:*:*:*:" && continue
[ -e /tmp/ifcfg/ifcfg-$netif ] && continue
unset bridge
unset bond
else
# If we've booted with static ip= lines, the override file is there
[ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override
- if strstr "$ip" '*:*:*'; then
+ if strglobin "$ip" '*:*:*'; then
echo "IPV6INIT=yes"
echo "IPV6_AUTOCONF=no"
echo "IPV6ADDR=\"$ip/$mask\""
fi
fi
fi
- if strstr "$gw" '*:*:*'; then
+ if strglobin "$gw" '*:*:*'; then
echo "IPV6_DEFAULTGW=\"$gw\""
elif [ -n "$gw" ]; then
echo "GATEWAY=\"$gw\""
IFCFGFILE=/run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-$DEVICE
- strstr "$IPADDR" '*:*:*' && ipv6=1
+ strglobin "$IPADDR" '*:*:*' && ipv6=1
# to please NetworkManager on startup in loader before loader reconfigures net
cat > /etc/sysconfig/network << EOF
. /tmp/cms.conf
-strstr "$IPADDR" '*:*:*' && ipv6=1
+strglobin "$IPADDR" '*:*:*' && ipv6=1
if [ "$ipv6" ] && ! str_starts "$IPADDR" "["; then
IPADDR="[$IPADDR]"
arg="${arg##$nfs:}"
# check if we have a server
- if strstr "$arg" ':/*' ; then
+ if strstr "$arg" ':/' ; then
server="${arg%%:/*}"
arg="/${arg##*:/}"
fi
[ "$RD_DEBUG" = "yes" ] && set -x
}
-# returns OK if $1 contains $2
+# returns OK if $1 contains literal string $2 (and isn't empty)
strstr() {
- [ "${1#*$2*}" != "$1" ]
+ [ "${1##*"$2"*}" != "$1" ]
}
-# returns OK if $1 contains $2 at the beginning
+# returns OK if $1 matches (completely) glob pattern $2
+# An empty $1 will not be considered matched, even if $2 is * which technically
+# matches; as it would match anything, it's not an interesting case.
+strglob() {
+ [ -n "$1" -a -z "${1##$2}" ]
+}
+
+# returns OK if $1 contains (anywhere) a match of glob pattern $2
+# An empty $1 will not be considered matched, even if $2 is * which technically
+# matches; as it would match anything, it's not an interesting case.
+strglobin() {
+ [ -n "$1" -a -z "${1##*$2*}" ]
+}
+
+# returns OK if $1 contains literal string $2 at the beginning, and isn't empty
str_starts() {
- [ "${1#$2*}" != "$1" ]
+ [ "${1#"$2"*}" != "$1" ]
}
-# returns OK if $1 contains $2 at the end
+# returns OK if $1 contains literal string $2 at the end, and isn't empty
str_ends() {
- [ "${1%*$2}" != "$1" ]
+ [ "${1%*"$2"}" != "$1" ]
}
if [ -z "$DRACUT_SYSTEMD" ]; then
local out=''
while strstr "${in}" "$s"; do
- chop="${in%%$s*}"
+ chop="${in%%"$s"*}"
out="${out}${chop}$r"
- in="${in#*$s}"
+ in="${in#*"$s"}"
done
echo "${out}${in}"
}
arg="${arg##$nfs:}"
# check if we have a server
- if strstr "$arg" ':/*' ; then
+ if strstr "$arg" ':/' ; then
server="${arg%%:/*}"
arg="/${arg##*:/}"
fi
#!/bin/sh
>/dev/watchdog
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
-strstr() { [ "${1#*$2*}" != "$1" ]; }
+strstr() { [ "${1#*"$2"*}" != "$1" ]; }
CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
plymouth --quit
exec >/dev/console 2>&1
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
-strstr() { [ "${1#*$2*}" != "$1" ]; }
+strstr() { [ "${1#*"$2"*}" != "$1" ]; }
CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
plymouth --quit
exec </dev/console >/dev/console 2>&1
#!/bin/sh
>/dev/watchdog
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
-strstr() { [ "${1#*$2*}" != "$1" ]; }
+strstr() { [ "${1#*"$2"*}" != "$1" ]; }
CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
plymouth --quit
exec </dev/console >/dev/console 2>&1
#!/bin/sh
>/dev/watchdog
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
-strstr() { [ "${1#*$2*}" != "$1" ]; }
+strstr() { [ "${1#*"$2"*}" != "$1" ]; }
CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
plymouth --quit
exec </dev/console >/dev/console 2>&1
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
-strstr() { [ "${1#*$2*}" != "$1" ]; }
+strstr() { [ "${1#*"$2"*}" != "$1" ]; }
CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
command -v plymouth >/dev/null && plymouth --quit
exec >/dev/console 2>&1
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
-strstr() { [ "${1#*$2*}" != "$1" ]; }
+strstr() { [ "${1#*"$2"*}" != "$1" ]; }
CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
plymouth --quit
exec >/dev/console 2>&1
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
-strstr() { [ "${1#*$2*}" != "$1" ]; }
+strstr() { [ "${1#*"$2"*}" != "$1" ]; }
CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
command -v plymouth >/dev/null && plymouth --quit
exec >/dev/console 2>&1
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
-strstr() { [ "${1#*$2*}" != "$1" ]; }
+strstr() { [ "${1#*"$2"*}" != "$1" ]; }
CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
plymouth --quit
exec >/dev/console 2>&1
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
-strstr() { [ "${1#*$2*}" != "$1" ]; }
+strstr() { [ "${1#*"$2"*}" != "$1" ]; }
CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
plymouth --quit
exec >/dev/console 2>&1
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
-strstr() { [ "${1#*$2*}" != "$1" ]; }
+strstr() { [ "${1#*"$2"*}" != "$1" ]; }
CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
plymouth --quit
exec >/dev/console 2>&1
export TERM=linux
export PS1='initramfs-test:\w\$ '
CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
-strstr() { [ "${1#*$2*}" != "$1" ]; }
+strstr() { [ "${1#*"$2"*}" != "$1" ]; }
stty sane
strstr "$CMDLINE" "rd.shell" && sh -i
exec >/dev/console 2>&1
set -x
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
-strstr() { [ "${1#*$2*}" != "$1" ]; }
+strstr() { [ "${1#*"$2"*}" != "$1" ]; }
+strglobin() { [ -n "$1" -a -z "${1#*$2*}" ]; }
CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
export TERM=linux
export PS1='initramfs-test:\w\$ '
stty sane
echo "made it to the rootfs! Powering down."
for i in /run/initramfs/net.*.did-setup; do
- strstr "$i" ":*:*:*:*:" && continue
+ strglobin "$i" ":*:*:*:*:" && continue
i=${i%.did-setup}
IFACES+="${i##*/net.} "
done