bash scripts: remove useless cat
upstream: fedora
resolves: bz2003832
conflict:
load_kdump_kernel_key() didn't present in rhel9,
so removed the patch for it.
commit 6d45257cc1
Author: Kairui Song <kasong@redhat.com>
Date: Wed Aug 4 15:14:00 2021 +0800
bash scripts: remove useless cat
Some `cat` calls are useless, remove them to make it cleaner.
See: https://github.com/koalaman/shellcheck/wiki/SC2002
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Philipp Rudo <prudo@redhat.com>
Signed-off-by: Tao Liu <ltao@redhat.com>
This commit is contained in:
parent
6d930905d5
commit
e07098aa14
@ -114,7 +114,7 @@ kdump_setup_dns() {
|
|||||||
_dns=$(echo $_nameserver | cut -d' ' -f2)
|
_dns=$(echo $_nameserver | cut -d' ' -f2)
|
||||||
[ -z "$_dns" ] && continue
|
[ -z "$_dns" ] && continue
|
||||||
|
|
||||||
if [ ! -f $_dnsfile ] || [ ! $(cat $_dnsfile | grep -q $_dns) ]; then
|
if [ ! -f $_dnsfile ] || ! grep -q "$_dns" "$_dnsfile" ; then
|
||||||
echo "nameserver=$_dns" >> "$_dnsfile"
|
echo "nameserver=$_dns" >> "$_dnsfile"
|
||||||
fi
|
fi
|
||||||
done < "/etc/resolv.conf"
|
done < "/etc/resolv.conf"
|
||||||
@ -985,7 +985,9 @@ kdump_configure_fence_kdump () {
|
|||||||
# Install a random seed used to feed /dev/urandom
|
# Install a random seed used to feed /dev/urandom
|
||||||
# By the time kdump service starts, /dev/uramdom is already fed by systemd
|
# By the time kdump service starts, /dev/uramdom is already fed by systemd
|
||||||
kdump_install_random_seed() {
|
kdump_install_random_seed() {
|
||||||
local poolsize=`cat /proc/sys/kernel/random/poolsize`
|
local poolsize
|
||||||
|
|
||||||
|
poolsize=$(</proc/sys/kernel/random/poolsize)
|
||||||
|
|
||||||
if [ ! -d ${initdir}/var/lib/ ]; then
|
if [ ! -d ${initdir}/var/lib/ ]; then
|
||||||
mkdir -p ${initdir}/var/lib/
|
mkdir -p ${initdir}/var/lib/
|
||||||
|
17
kdumpctl
17
kdumpctl
@ -204,8 +204,8 @@ restore_default_initrd()
|
|||||||
# fadump to kdump. Restore the original default initrd.
|
# fadump to kdump. Restore the original default initrd.
|
||||||
if [ -f $DEFAULT_INITRD_BAK ] && [ -f $INITRD_CHECKSUM_LOCATION ]; then
|
if [ -f $DEFAULT_INITRD_BAK ] && [ -f $INITRD_CHECKSUM_LOCATION ]; then
|
||||||
# verify checksum before restoring
|
# verify checksum before restoring
|
||||||
backup_checksum=`sha1sum $DEFAULT_INITRD_BAK | awk '{ print $1 }'`
|
backup_checksum=$(sha1sum "$DEFAULT_INITRD_BAK" | awk '{ print $1 }')
|
||||||
default_checksum=`cat $INITRD_CHECKSUM_LOCATION | awk '{ print $1 }'`
|
default_checksum=$(awk '{ print $1 }' "$INITRD_CHECKSUM_LOCATION")
|
||||||
if [ "$default_checksum" != "$backup_checksum" ]; then
|
if [ "$default_checksum" != "$backup_checksum" ]; then
|
||||||
dwarn "WARNING: checksum mismatch! Can't restore original initrd.."
|
dwarn "WARNING: checksum mismatch! Can't restore original initrd.."
|
||||||
else
|
else
|
||||||
@ -800,8 +800,11 @@ propagate_ssh_key()
|
|||||||
|
|
||||||
show_reserved_mem()
|
show_reserved_mem()
|
||||||
{
|
{
|
||||||
local mem=$(cat /sys/kernel/kexec_crash_size)
|
local mem
|
||||||
local mem_mb=$(expr $mem / 1024 / 1024)
|
local mem_mb
|
||||||
|
|
||||||
|
mem=$(</sys/kernel/kexec_crash_size)
|
||||||
|
mem_mb=$(expr "$mem" / 1024 / 1024)
|
||||||
|
|
||||||
dinfo "Reserved "$mem_mb"MB memory for crash kernel"
|
dinfo "Reserved "$mem_mb"MB memory for crash kernel"
|
||||||
}
|
}
|
||||||
@ -809,8 +812,8 @@ show_reserved_mem()
|
|||||||
check_current_fadump_status()
|
check_current_fadump_status()
|
||||||
{
|
{
|
||||||
# Check if firmware-assisted dump has been registered.
|
# Check if firmware-assisted dump has been registered.
|
||||||
rc=`cat $FADUMP_REGISTER_SYS_NODE`
|
rc=$(<$FADUMP_REGISTER_SYS_NODE)
|
||||||
[ $rc -eq 1 ] && return 0
|
[[ $rc -eq 1 ]] && return 0
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1227,7 +1230,7 @@ do_estimate() {
|
|||||||
# The default pre-reserved crashkernel value
|
# The default pre-reserved crashkernel value
|
||||||
baseline_size=$((baseline * size_mb))
|
baseline_size=$((baseline * size_mb))
|
||||||
# Current reserved crashkernel size
|
# Current reserved crashkernel size
|
||||||
reserved_size=$(cat /sys/kernel/kexec_crash_size)
|
reserved_size=$(</sys/kernel/kexec_crash_size)
|
||||||
# A pre-estimated value for userspace usage and kernel
|
# A pre-estimated value for userspace usage and kernel
|
||||||
# runtime allocation, 64M should good for most cases
|
# runtime allocation, 64M should good for most cases
|
||||||
runtime_size=$((64 * size_mb))
|
runtime_size=$((64 * size_mb))
|
||||||
|
2
mkdumprd
2
mkdumprd
@ -311,7 +311,7 @@ is_unresettable()
|
|||||||
|
|
||||||
if [ -f "$path" ]
|
if [ -f "$path" ]
|
||||||
then
|
then
|
||||||
resettable="$(cat $path)"
|
resettable="$(<"$path")"
|
||||||
[ $resettable -eq 0 -a "$OVERRIDE_RESETTABLE" -eq 0 ] && {
|
[ $resettable -eq 0 -a "$OVERRIDE_RESETTABLE" -eq 0 ] && {
|
||||||
local device=$(udevadm info --query=all --path=/sys/dev/block/$1 | awk -F= '/DEVNAME/{print $2}')
|
local device=$(udevadm info --query=all --path=/sys/dev/block/$1 | awk -F= '/DEVNAME/{print $2}')
|
||||||
derror "Error: Can not save vmcore because device $device is unresettable"
|
derror "Error: Can not save vmcore because device $device is unresettable"
|
||||||
|
Loading…
Reference in New Issue
Block a user