Unattended usage improvements

- When in batch mode, don't wait for <enter> after kernel upgrade,
  so Slackpkg will not wait forever.
- Also in batch mode, allow to set a default action about what to
  do with .new config files
This commit is contained in:
piterpunk 2021-12-28 20:36:41 -03:00 committed by Robby Workman
parent f8dfb7722f
commit 9d5166d13b
2 changed files with 16 additions and 4 deletions

View file

@ -1,4 +1,4 @@
# You can list here the .new files and the default action # You can list here the .new files and the default action
# to do for each file. The list format is: # to do for each file. The list format is:
# #
# /full/path/of/dot/new/file.new:action # /full/path/of/dot/new/file.new:action
@ -9,6 +9,11 @@
# R to Remove the new file # R to Remove the new file
# K to Keep the current and the .new files # K to Keep the current and the .new files
# #
# Using "default" as file name, you'll set the action for
# the .new files in batch mode. The action for each file
# takes precedence over the "default" one.
#
# E.g: # E.g:
#/etc/slackpkg/mirrors.new:K #/etc/slackpkg/mirrors.new:K
#/etc/ntp.conf.new:R #/etc/ntp.conf.new:R
#default:O

View file

@ -152,6 +152,7 @@ looknew() {
-name "*.new" \ -name "*.new" \
${ONLY_NEW_DOTNEW} \ ${ONLY_NEW_DOTNEW} \
-not -name "rc.inet1.conf.new" \ -not -name "rc.inet1.conf.new" \
-not -name "rc.wireless.conf.new" \
-not -name "group.new" \ -not -name "group.new" \
-not -name "passwd.new" \ -not -name "passwd.new" \
-not -name "shadow.new" \ -not -name "shadow.new" \
@ -248,6 +249,9 @@ EOF
answer answer
if [ "${BATCH}" = "on" ] && [ -n "${NEWCONFIG}" ]; then if [ "${BATCH}" = "on" ] && [ -n "${NEWCONFIG}" ]; then
ANSWER=P ANSWER=P
# This allows to have a default behaviour for all .new files in batch mode.
DEF_AUTOANSWER="$(sed -ne 's#^default:\([ORK]\)#\1#p' $NEWCONFIG 2>/dev/null)"
fi fi
case $ANSWER in case $ANSWER in
K|k) K|k)
@ -277,7 +281,7 @@ EOF
echo $ANSWER echo $ANSWER
else else
if [ "${BATCH}" = "on" ]; then if [ "${BATCH}" = "on" ]; then
ANSWER=K ANSWER=${DEF_AUTOANSWER:-K}
echo $ANSWER echo $ANSWER
else else
read ANSWER read ANSWER
@ -340,7 +344,10 @@ Your kernel image was updated, and lilo does not appear to be used on
your system. You may need to adjust your boot manager (like GRUB) to your system. You may need to adjust your boot manager (like GRUB) to
boot the appropriate kernel (after generating an initrd if required)." boot the appropriate kernel (after generating an initrd if required)."
fi fi
echo -e "Press the \"Enter\" key to continue...\n "
read _junk if [ "${BATCH}" != "on" ]; then
echo -e "Press the \"Enter\" key to continue...\n "
read _junk
fi
fi fi
} }