Skip to content
This repository was archived by the owner on Aug 11, 2023. It is now read-only.

Conversation

@lrustand
Copy link

@lrustand lrustand commented May 8, 2022

Makes it possible to specify what config file to use at the command line.

@andreyv
Copy link
Owner

andreyv commented May 13, 2022

Hi,

What is your use case for this feature?

@lrustand
Copy link
Author

I use it in combination with a pacman hook to take a btrfs snapshot before updating the kernel, and generating a unified kernel image with the old kernel and setting the command line to point to the snapshot, then after updating the kernel then sbupdate is run with the normal config for the new kernel

Copy link
Owner

@andreyv andreyv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that you can use optional environment variables in the main config like this:

CMDLINE_DEFAULT="rw something root=${MY_SPECIAL_ROOT:-default_root}"

If you define MY_SPECIAL_ROOT prior to running sbupdate, then it is substituted, otherwise default_root is substituted.

But the proposed changes are fine too, if you want to proceed with them.

case "${opt}" in
k) HOOK=1 ;;
r) REMOVE=1 ;;
c) CONFFILE=${OPTARG} ;;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${OPTARG} should be quoted.

shopt -s extglob

readonly CONFFILE="/etc/sbupdate.conf"
CONFFILE="/etc/sbupdate.conf"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this becomes a command-line option, it should be moved to parse_args.

c) CONFFILE=${OPTARG} ;;
?) exit 1 ;;
esac
done
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CONFFILE should be made readonly again below this line.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants