Browse Source

Merge pull request #122 from scop/fixes

Various shell script improvements
master
Harald Hoyer 9 years ago
parent
commit
c395993eaf
  1. 102
      dracut-init.sh
  2. 2
      install/dracut-install.c
  3. 10
      modules.d/00systemd/module-setup.sh
  4. 8
      modules.d/02systemd-networkd/module-setup.sh
  5. 2
      modules.d/40network/dhclient-script.sh
  6. 2
      modules.d/40network/ifup.sh
  7. 2
      modules.d/95debug/module-setup.sh
  8. 2
      modules.d/95fcoe/fcoe-edd.sh
  9. 10
      modules.d/95nfs/module-setup.sh
  10. 2
      modules.d/95nfs/nfs-lib.sh
  11. 4
      modules.d/95udev-rules/module-setup.sh
  12. 4
      modules.d/99base/module-setup.sh
  13. 2
      test/TEST-04-FULL-SYSTEMD/test.sh

102
dracut-init.sh

@ -275,71 +275,61 @@ rev_lib_symlinks() { @@ -275,71 +275,61 @@ rev_lib_symlinks() {
inst_rule_programs() {
local _prog _bin

if grep -qE 'PROGRAM==?"[^ "]+' "$1"; then
for _prog in $(grep -E 'PROGRAM==?"[^ "]+' "$1" | sed -r 's/.*PROGRAM==?"([^ "]+).*/\1/'); do
_bin=""
if [ -x ${udevdir}/$_prog ]; then
_bin=${udevdir}/$_prog
elif [[ "${_prog/\$env\{/}" == "$_prog" ]]; then
_bin=$(find_binary "$_prog") || {
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
continue;
}
fi
for _prog in $(sed -nr 's/.*PROGRAM==?"([^ "]+).*/\1/p'); do
_bin=""
if [ -x ${udevdir}/$_prog ]; then
_bin=${udevdir}/$_prog
elif [[ "${_prog/\$env\{/}" == "$_prog" ]]; then
_bin=$(find_binary "$_prog") || {
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
continue;
}
fi

[[ $_bin ]] && inst_binary "$_bin"
done
fi
if grep -qE 'RUN[+=]=?"[^ "]+' "$1"; then
for _prog in $(grep -E 'RUN[+=]=?"[^ "]+' "$1" | sed -r 's/.*RUN[+=]=?"([^ "]+).*/\1/'); do
_bin=""
if [ -x ${udevdir}/$_prog ]; then
_bin=${udevdir}/$_prog
elif [[ "${_prog/\$env\{/}" == "$_prog" ]] && [[ "${_prog}" != "/sbin/initqueue" ]]; then
_bin=$(find_binary "$_prog") || {
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
continue;
}
fi
[[ $_bin ]] && inst_binary "$_bin"
done
for _prog in $(sed -nr 's/.*RUN[+=]=?"([^ "]+).*/\1/p'); do
_bin=""
if [ -x ${udevdir}/$_prog ]; then
_bin=${udevdir}/$_prog
elif [[ "${_prog/\$env\{/}" == "$_prog" ]] && [[ "${_prog}" != "/sbin/initqueue" ]]; then
_bin=$(find_binary "$_prog") || {
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
continue;
}
fi

[[ $_bin ]] && inst_binary "$_bin"
done
fi
if grep -qE 'IMPORT\{program\}==?"[^ "]+' "$1"; then
for _prog in $(grep -E 'IMPORT\{program\}==?"[^ "]+' "$1" | sed -r 's/.*IMPORT\{program\}==?"([^ "]+).*/\1/'); do
_bin=""
if [ -x ${udevdir}/$_prog ]; then
_bin=${udevdir}/$_prog
elif [[ "${_prog/\$env\{/}" == "$_prog" ]]; then
_bin=$(find_binary "$_prog") || {
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
continue;
}
fi
[[ $_bin ]] && inst_binary "$_bin"
done
for _prog in $(sed -nr 's/.*IMPORT\{program\}==?"([^ "]+).*/\1/p'); do
_bin=""
if [ -x ${udevdir}/$_prog ]; then
_bin=${udevdir}/$_prog
elif [[ "${_prog/\$env\{/}" == "$_prog" ]]; then
_bin=$(find_binary "$_prog") || {
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
continue;
}
fi

[[ $_bin ]] && dracut_install "$_bin"
done
fi
[[ $_bin ]] && dracut_install "$_bin"
done
}

# attempt to install any programs specified in a udev rule
inst_rule_group_owner() {
local i

if grep -qE 'OWNER=?"[^ "]+' "$1"; then
for i in $(grep -E 'OWNER=?"[^ "]+' "$1" | sed -r 's/.*OWNER=?"([^ "]+).*/\1/'); do
if ! egrep -q "^$i:" "$initdir/etc/passwd" 2>/dev/null; then
egrep "^$i:" /etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
fi
done
fi
if grep -qE 'GROUP=?"[^ "]+' "$1"; then
for i in $(grep -E 'GROUP=?"[^ "]+' "$1" | sed -r 's/.*GROUP=?"([^ "]+).*/\1/'); do
if ! egrep -q "^$i:" "$initdir/etc/group" 2>/dev/null; then
egrep "^$i:" /etc/group 2>/dev/null >> "$initdir/etc/group"
fi
done
fi
for i in $(sed -nr 's/.*OWNER=?"([^ "]+).*/\1/p'); do
if ! grep -Eq "^$i:" "$initdir/etc/passwd" 2>/dev/null; then
grep -E "^$i:" /etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
fi
done
for i in $(sed -nr 's/.*GROUP=?"([^ "]+).*/\1/p' "$1"); do
if ! grep -Eq "^$i:" "$initdir/etc/group" 2>/dev/null; then
grep -E "^$i:" /etc/group 2>/dev/null >> "$initdir/etc/group"
fi
done
}

inst_rule_initqueue() {

2
install/dracut-install.c

@ -287,7 +287,7 @@ static int library_install(const char *src, const char *lib) @@ -287,7 +287,7 @@ static int library_install(const char *src, const char *lib)

/* Also try to install the same library from one directory above.
This fixes the case, where only the HWCAP lib would be installed
# ldconfig -p|fgrep libc.so
# ldconfig -p|grep -F libc.so
libc.so.6 (libc6,64bit, hwcap: 0x0000001000000000, OS ABI: Linux 2.6.32) => /lib64/power6/libc.so.6
libc.so.6 (libc6,64bit, hwcap: 0x0000000000000200, OS ABI: Linux 2.6.32) => /lib64/power6x/libc.so.6
libc.so.6 (libc6,64bit, OS ABI: Linux 2.6.32) => /lib64/libc.so.6

10
modules.d/00systemd/module-setup.sh

@ -179,11 +179,11 @@ install() { @@ -179,11 +179,11 @@ install() {

# install adm user/group for journald
inst_multiple nologin
egrep '^systemd-journal:' /etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
egrep '^adm:' /etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
egrep '^systemd-journal:' /etc/group >> "$initdir/etc/group"
egrep '^wheel:' /etc/group >> "$initdir/etc/group"
egrep '^adm:' /etc/group >> "$initdir/etc/group"
grep '^systemd-journal:' /etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
grep '^adm:' /etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
grep '^systemd-journal:' /etc/group >> "$initdir/etc/group"
grep '^wheel:' /etc/group >> "$initdir/etc/group"
grep '^adm:' /etc/group >> "$initdir/etc/group"

ln_r $systemdutildir/systemd "/init"
ln_r $systemdutildir/systemd "/sbin/init"

8
modules.d/02systemd-networkd/module-setup.sh

@ -48,10 +48,10 @@ install() { @@ -48,10 +48,10 @@ install() {

# inst_dir /var/lib/systemd/clock

egrep '^systemd-network:' /etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
egrep '^systemd-network:' /etc/group >> "$initdir/etc/group"
# egrep '^systemd-timesync:' /etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
# egrep '^systemd-timesync:' /etc/group >> "$initdir/etc/group"
grep '^systemd-network:' /etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
grep '^systemd-network:' /etc/group >> "$initdir/etc/group"
# grep '^systemd-timesync:' /etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
# grep '^systemd-timesync:' /etc/group >> "$initdir/etc/group"

_arch=$(uname -m)
inst_libdir_file {"tls/$_arch/",tls/,"$_arch/",}"libnss_dns.so.*" \

2
modules.d/40network/dhclient-script.sh

@ -95,7 +95,7 @@ setup_interface6() { @@ -95,7 +95,7 @@ setup_interface6() {
[ -n "$hostname" ] && echo "echo ${hostname%.$domain}${domain:+.$domain} > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
}

function parse_option_121() {
parse_option_121() {
while [ $# -ne 0 ]; do
mask="$1"
shift

2
modules.d/40network/ifup.sh

@ -277,7 +277,7 @@ if [ -z "$NO_TEAM_MASTER" ]; then @@ -277,7 +277,7 @@ if [ -z "$NO_TEAM_MASTER" ]; then
for slave in $teamslaves ; do
ip link set $slave up 2>/dev/null
if wait_for_if_up $slave; then
working_slaves+="$slave "
working_slaves="$working_slaves$slave "
fi
done
# Do not add slaves now

2
modules.d/95debug/module-setup.sh

@ -18,6 +18,6 @@ install() { @@ -18,6 +18,6 @@ install() {
tcpdump cp less hostname mkdir \
fsck fsck.ext2 fsck.ext4 fsck.ext3 fsck.ext4dev fsck.vfat e2fsck

egrep '^tcpdump:' /etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
grep '^tcpdump:' /etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
}


2
modules.d/95fcoe/fcoe-edd.sh

@ -29,7 +29,7 @@ for disk in /sys/firmware/edd/int13_*; do @@ -29,7 +29,7 @@ for disk in /sys/firmware/edd/int13_*; do
driver=${driver##*/}
fi
# i40e uses dev_port 1 for a virtual fcoe function
if [ "${driver}" == "i40e" ]; then
if [ "${driver}" = "i40e" ]; then
dev_port=1
fi
for nic in "${disk}"/pci_dev/net/*; do

10
modules.d/95nfs/module-setup.sh

@ -105,14 +105,14 @@ install() { @@ -105,14 +105,14 @@ install() {

# Rather than copy the passwd file in, just set a user for rpcbind
# We'll save the state and restart the daemon from the root anyway
egrep '^nfsnobody:|^rpc:|^rpcuser:' /etc/passwd >> "$initdir/etc/passwd"
egrep '^nogroup:|^rpc:|^nobody:' /etc/group >> "$initdir/etc/group"
grep -E '^nfsnobody:|^rpc:|^rpcuser:' /etc/passwd >> "$initdir/etc/passwd"
grep -E '^nogroup:|^rpc:|^nobody:' /etc/group >> "$initdir/etc/group"

# rpc user needs to be able to write to this directory to save the warmstart
# file
chmod 770 "$initdir/var/lib/rpcbind"
egrep -q '^rpc:' /etc/passwd \
&& egrep -q '^rpc:' /etc/group \
&& chown rpc.rpc "$initdir/var/lib/rpcbind"
grep -q '^rpc:' /etc/passwd \
&& grep -q '^rpc:' /etc/group \
&& chown rpc:rpc "$initdir/var/lib/rpcbind"
dracut_need_initqueue
}

2
modules.d/95nfs/nfs-lib.sh

@ -110,7 +110,7 @@ nfsroot_from_dhcp() { @@ -110,7 +110,7 @@ nfsroot_from_dhcp() {
[ -f $f ] && . $f
done
[ -n "$new_root_path" ] && nfsroot_to_var "$nfs:$new_root_path"
[ -z "$path" ] && [ "$(getarg root=)" == "/dev/nfs" ] && path=/tftpboot/%s
[ -z "$path" ] && [ "$(getarg root=)" = "/dev/nfs" ] && path=/tftpboot/%s
[ -z "$server" ] && server=$srv
[ -z "$server" ] && server=$new_dhcp_server_identifier
[ -z "$server" ] && server=$new_next_server

4
modules.d/95udev-rules/module-setup.sh

@ -63,8 +63,8 @@ install() { @@ -63,8 +63,8 @@ install() {

{
for i in cdrom tape dialout floppy; do
if ! egrep -q "^$i:" "$initdir/etc/group" 2>/dev/null; then
if ! egrep "^$i:" /etc/group 2>/dev/null; then
if ! grep -q "^$i:" "$initdir/etc/group" 2>/dev/null; then
if ! grep "^$i:" /etc/group 2>/dev/null; then
case $i in
cdrom) echo "$i:x:11:";;
dialout) echo "$i:x:18:";;

4
modules.d/99base/module-setup.sh

@ -27,8 +27,8 @@ install() { @@ -27,8 +27,8 @@ install() {
fi

#add common users in /etc/passwd, it will be used by nfs/ssh currently
egrep '^root:' "$initdir/etc/passwd" 2>/dev/null || echo 'root:x:0:0::/root:/bin/sh' >> "$initdir/etc/passwd"
egrep '^nobody:' /etc/passwd >> "$initdir/etc/passwd"
grep '^root:' "$initdir/etc/passwd" 2>/dev/null || echo 'root:x:0:0::/root:/bin/sh' >> "$initdir/etc/passwd"
grep '^nobody:' /etc/passwd >> "$initdir/etc/passwd"

# install our scripts and hooks
inst_script "$moddir/init.sh" "/init"

2
test/TEST-04-FULL-SYSTEMD/test.sh

@ -197,7 +197,7 @@ EOF @@ -197,7 +197,7 @@ EOF
ln -fs /proc/self/mounts $initdir/etc/mtab

# install any Execs from the service files
egrep -ho '^Exec[^ ]*=[^ ]+' $initdir/lib/systemd/system/*.service \
grep -Eho '^Exec[^ ]*=[^ ]+' $initdir/lib/systemd/system/*.service \
| while read i || [ -n "$i" ]; do
i=${i##Exec*=}; i=${i##-}
inst_multiple -o $i

Loading…
Cancel
Save