Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows the skip of timezone and password dialogs #49

Merged
merged 10 commits into from
May 21, 2019

Conversation

aplanas
Copy link
Contributor

@aplanas aplanas commented May 8, 2019

Add two new variables to jeos-firstboot:

  • TIMEZONE_PRESET
    Based on LOCALE_PRESET and KEYTABLE_PRESET, this new variable will affect the systemd_firstboot_args array if is set, and will skip the time-zone dialog.

  • PASSWORD_ALREADY_SET
    If set to a non-zero value, will skip the root password dialog. Is expected that the user is setting the root password via other means, like config.sh or the Kiwi users XML tag.

Also fix the call of btrfs on non-btrfs file systems.

@aplanas aplanas force-pushed the fix_timezone_password branch 2 times, most recently from e5de2aa to c425ee0 Compare May 8, 2019 12:05
@aplanas
Copy link
Contributor Author

aplanas commented May 8, 2019

Added a new commit to fix a bug in the btrfs call

@aplanas
Copy link
Contributor Author

aplanas commented May 9, 2019

Already tested for my use case.

@lnussel
Copy link
Member

lnussel commented May 13, 2019

how do you set those variables? Maybe jeos-firstboot needs a config nowadays and branding packages for different use cases.

@aplanas
Copy link
Contributor Author

aplanas commented May 13, 2019

@lnussel creating systemd overlays:

#======================================
# Overlay for jeos-firstboot (Yomi)
#--------------------------------------
if [[ "$kiwi_profiles" == *"Live"* ]]; then
	LOCALE="en_US"
	KEYTABLE="jp"
	TIMEZONE="UTC"
	mkdir -p /etc/systemd/system/jeos-firstboot.service.d/
	cat > /etc/systemd/system/jeos-firstboot.service.d/10-presets.conf <<-EOF
		[Service]
		Environment=SYSTEMCTL_OPTIONS=--ignore-dependencies TERM=linux LOCALE_PRESET=$LOCALE KEYTABLE_PRESET=$KEYTABLE TIMEZONE_PRESET=$TIMEZONE PASSWORD_ALREADY_SET=1
		ExecStartPost=/usr/sbin/langset.sh $LOCALE $KEYTABLE
	EOF
fi

@lnussel
Copy link
Member

lnussel commented May 13, 2019

unless you have to meet deadlines so you have to accept hacks I'd recommend to find a better way instead :)

@Vogtinator
Copy link
Member

What I suggested in #44 is to just add

EnvironmentFile=-/usr/share/defaults/jeos-firstboot.conf
EnvironmentFile=-/etc/jeos-firstboot.conf

to the .service file and use that for configuration. Alternatively, just sourcing those files inside jeos-firstboot.

@aplanas
Copy link
Contributor Author

aplanas commented May 13, 2019

@Vogtinator This makes sense to me. I will change the .service, as is a more clear way.

But I wonder if this does not change the current code in this patch.

@aplanas
Copy link
Contributor Author

aplanas commented May 13, 2019

@Vogtinator if I do a source inside the code, am I breaking the usage of LOCALE_PRESET and KEYTABLE_PRESET?

@Vogtinator
Copy link
Member

No - if those variables are set in one of the files, it's skipped as it should be. The name of those variables should be changed though to accommodate for the newly gained external visibility.

files/usr/lib/jeos-firstboot Outdated Show resolved Hide resolved
@aplanas
Copy link
Contributor Author

aplanas commented May 13, 2019

@Vogtinator @lnussel Added the configuration file and renamed the variables. Note that there are two exports for LOCALE_PRESET and KEYTABLE_PRESET that I maintained, as I am not sure if any other process are using them later.

@lnussel
Copy link
Member

lnussel commented May 13, 2019

&& is not -e safe. Use inverse logic or the if variant.

@Vogtinator
Copy link
Member

Vogtinator commented May 13, 2019

&& is not -e safe. Use inverse logic or the if variant.

It actually is:

The ERR trap is not executed if the failed command is part of the command list immediately following a while or until keyword, part of the test in an if statement, part of a command executed in a && or || list except the command following the final && or ||, any command in a pipeline but the last, or if the command's return value is being inverted using !. These are the same conditions obeyed by the errexit (-e) option.

@aplanas
Copy link
Contributor Author

aplanas commented May 13, 2019

I agree with @Vogtinator. Will exit if cannot read the file at the end of the chain (tested locally)

@aplanas
Copy link
Contributor Author

aplanas commented May 13, 2019

Rename the reexport, as is only used in the second virtual console. Not sure why there is a second virtual console involved, tho.

@aplanas aplanas force-pushed the fix_timezone_password branch 2 times, most recently from 22dd4f2 to 03799be Compare May 13, 2019 15:33
@aplanas
Copy link
Contributor Author

aplanas commented May 14, 2019

Partially tested with:

#======================================
# Config for jeos-firstboot (Yomi)
#--------------------------------------
if [[ "$kiwi_profiles" == *"Live"* ]]; then
	cat > /etc/jeos-firstboot.conf <<-EOF
		JEOS_LOCALE="en_US"
		JEOS_KEYTABLE="jp"
		JEOS_TIMEZONE="UTC"
		JEOS_PASSWORD_ALREADY_SET=1
	EOF
fi

Ready for reviews

files/usr/lib/jeos-firstboot Outdated Show resolved Hide resolved
files/usr/lib/jeos-firstboot Outdated Show resolved Hide resolved
files/usr/lib/jeos-firstboot Outdated Show resolved Hide resolved
files/usr/share/defaults/jeos-firstboot.conf Show resolved Hide resolved
In the same way that LOCALE_PRESET and KEYTABLE_PRESET, this patch
introduces a new variable, TIMEZONE_PRESET, that will skip the
time-zone dialog box if is set.
As KIWI allows the creation of users and passwords, sometimes we
want to skip the root password dialog from jeos-firstboot.

This patch introduces a new variable PASSWORD_ALREADY_SET, that if
is non zero, will skip the root password dialog.
The currect code assume that if snapper is installed, the file
system is btrfs.  As both elements are not related, this test
can fail for valid deployments.

This patch will explicitly check for the file system before calling
btrfs cli tools.
Add a configuration file for jeos-firstboot.
Rename the *_PRESET variables and document the re-export in the
second virtual console.
@Vogtinator
Copy link
Member

Yes, those variables can come from two sources, but that won't actually matter. If it's set in the configuration file, the user isn't even asked, so it can't be overwritten.

@aplanas
Copy link
Contributor Author

aplanas commented May 20, 2019

Not very confident of the last PR. I will test it manually, and lets see what openQA says.

files/usr/lib/jeos-firstboot Outdated Show resolved Hide resolved
files/usr/lib/jeos-firstboot Outdated Show resolved Hide resolved
@aplanas aplanas force-pushed the fix_timezone_password branch 2 times, most recently from e68fe09 to 75d1fbb Compare May 21, 2019 07:29
files/usr/share/defaults/jeos-firstboot.conf Outdated Show resolved Hide resolved
files/usr/share/defaults/jeos-firstboot.conf Outdated Show resolved Hide resolved
files/usr/share/defaults/jeos-firstboot.conf Outdated Show resolved Hide resolved
files/usr/share/defaults/jeos-firstboot.conf Outdated Show resolved Hide resolved
files/usr/share/defaults/jeos-firstboot.conf Outdated Show resolved Hide resolved
files/usr/lib/jeos-firstboot Outdated Show resolved Hide resolved
@Vogtinator
Copy link
Member

Found some typos, but will fix them after testing

@Vogtinator Vogtinator merged commit 110bab3 into openSUSE:master May 21, 2019
@aplanas aplanas deleted the fix_timezone_password branch May 21, 2019 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants