Added a NO_BOLD option to disable bold text manually, also suppressed some error messages by rcorder and ls if local-etc/rc.d is not present inside the jail

This commit is contained in:
Culsu
2021-01-25 00:22:54 +01:00
parent f0a325ee53
commit 0b32f9e34b

51
jaildk
View File

@@ -70,15 +70,19 @@ err () {
} }
bold() { bold() {
if [ -z "$BOLD_ON" ]; then if [ -z "$NO_BOLD" ]; then
BOLD_ON=`tput -T ${TERM:-cons25} md` if [ -z "$BOLD_ON" ]; then
export BOLD_ON BOLD_ON=`tput -T ${TERM:-cons25} md`
BOLD_OFF=`tput -T ${TERM:-cons25} me` export BOLD_ON
export BOLD_OFF BOLD_OFF=`tput -T ${TERM:-cons25} me`
export BOLD_OFF
fi
echo -n "$BOLD_ON"
echo "$@"
echo -n "$BOLD_OFF"
else
echo "$@"
fi fi
echo -n "$BOLD_ON"
echo "$@"
echo -n "$BOLD_OFF"
} }
fin() { fin() {
@@ -1053,13 +1057,14 @@ jaildk_jail() {
get_rc_scripts() { get_rc_scripts() {
jail="$1" jail="$1"
jailpath=`get_jail_path $jail`
files=$(ls $j/run/$jail/usr/local/etc/rc.d/* $j/run/$jail/etc/rc.d/*) files=$(ls $j/run/$jailpath/usr/local/etc/rc.d/* $j/run/$jailpath/etc/rc.d/* 2>/dev/null)
rcorder $files | while read SCRIPT; do rcorder $files 2>/dev/null | while read SCRIPT; do
rcvar=`egrep "^rcvar=" $SCRIPT | cut -d= -f2 | sed 's/"//g' | tail -1` rcvar=`egrep "^rcvar=" $SCRIPT | cut -d= -f2 | sed 's/"//g' | tail -1`
if egrep -iq "^${rcvar}=.*yes" $j/run/$jail/usr/local/etc/rc.conf; then if egrep -iq "^${rcvar}=.*yes" $j/run/$jailpath/usr/local/etc/rc.conf; then
echo $SCRIPT | sed "s|$j/run/$jail||" echo $SCRIPT | sed "s|$j/run/$jailpath||"
fi fi
done done
} }
@@ -1099,16 +1104,22 @@ jaildk_rc() {
rcs=`get_rc_scripts $jail` rcs=`get_rc_scripts $jail`
jid=`get_jid $jail`
jailpath=`get_jail_path $jail`
if test $rcd = "all"; then if test $rcd = "all"; then
bold "Jail $jail rc status:" if [ "$jail" == "$jailpath" ]; then
bold "Jail $jail rc status:"
else
bold "Jail $jail/$jailpath rc status:"
fi
for script in $rcs; do for script in $rcs; do
jexec $jail $script $mode jexec $jid $script $mode
done done
else else
ok='' ok=''
for script in $rcs; do for script in $rcs; do
if echo "$script" | egrep -q "/${rcd}\$"; then if echo "$script" | egrep -q "/${rcd}\$"; then
jexec $jail $script $mode jexec $jid $script $mode
ok=1 ok=1
fi fi
done done
@@ -1119,6 +1130,16 @@ jaildk_rc() {
fi fi
} }
get_jail_path() {
jail="$1"
echo "$(jls |grep -E "^ +[0-9]+ +[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ *${jail} +" | awk '{print $4}' | xargs basename)"
}
get_jid() {
jail="$1"
echo "$(jls | grep -E "^ +[0-9]+ +[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ *${jail} +" | awk '{print $1}' | xargs basename)"
}
usage_blogin() { usage_blogin() {
err "Usage: $file <jail> err "Usage: $file <jail>
Chroot into a build jail. Chroot into a build jail.