代码拉取完成,页面将自动刷新
同步操作将从 OpenCloudOS Stream/kexec-tools 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/bin/sh
. /lib/dracut-lib.sh
. /lib/kdump-lib-initramfs.sh
DUMP_RETVAL=$1
HOST_IP='127.0.0.1'
if [ "$DUMP_RETVAL" -ne 0 ]; then
echo "Kdump have failed, not purging old dump"
fi
# Copied from kdump.sh
get_host_ip() {
if is_nfs_dump_target || is_ssh_dump_target; then
kdumpnic=$(getarg kdumpnic=)
if [ -z "$kdumpnic" ]; then
derror "failed to get kdumpnic!"
return 1
fi
if ! kdumphost=$(ip addr show dev "$kdumpnic" | grep '[ ]*inet'); then
derror "wrong kdumpnic: $kdumpnic"
return 1
fi
kdumphost=$(echo "$kdumphost" | head -n 1 | awk '{print $2}')
kdumphost="${kdumphost%%/*}"
if [ -z "$kdumphost" ]; then
derror "wrong kdumpnic: $kdumpnic"
return 1
fi
HOST_IP=$kdumphost
fi
return 0
}
# $1: KDUMP_KEEP_OLD_DUMPS
# purge old dump directories if the number of directories
# exceeds KDUMP_KEEP_OLD_DUMPS
purge_old_dumps() {
keep_old_dumps=$1
kdump_mnt=$2
kdump_path=$3
# -2 (delete all dumps) means logic 0 here
if [ "$keep_old_dumps" -eq -2 ]; then
keep_old_dumps=0
fi
if [ -d "$kdump_mnt"/"$kdump_path" ]; then
dump_path="$kdump_mnt"/"$kdump_path"
elif [ -d "/sysroot/$kdump_path" ]; then
dump_path="/sysroot/$kdump_path"
else
echo "Not purging dump: Unsupported dump target."
exit 1
fi
echo "Purging dump in: $dump_path"
dirs="$(find "$dump_path" -maxdepth 1 -type d -name "$HOST_IP-20*-*-*-*:*:*" | sort)"
numdirs=$(echo "$dirs" | wc -l)
echo "$dirs" | while read -r d; do
if [ "$numdirs" -le $keep_old_dumps ]; then
break
fi
echo " Expiring old dump $d"
rm -rf "$d"
numdirs=$((numdirs - 1))
done
}
kdump_target=$(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix\|nfs")
if [ -z "$kdump_target" ]; then
echo "Not purging dump: Unsupported dump target."
exit 1
fi
get_host_ip
kdump_mnt=$(get_mntpoint_from_target "$kdump_target")
kdump_path=$(get_save_path)
KDUMP_KEEP_OLD_DUMPS=$(kdump_get_conf_val "keep_old_dumps")
# special value 0 is used for "do nothing" and -1 is reserved
if [ "$KDUMP_KEEP_OLD_DUMPS" -gt 0 ] || [ "$KDUMP_KEEP_OLD_DUMPS" -lt -1 ]; then
purge_old_dumps "$KDUMP_KEEP_OLD_DUMPS" "$kdump_mnt" "$kdump_path"
fi
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。