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

feat: detect os version and upgrade userconf-pi first (#163) #167

Merged
merged 2 commits into from
Jun 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/modules/base/start_chroot_script
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ if [ "${BASE_DISTRO}" == "ubuntu" ]; then

fi

#Helper Function for create_userconf
function get_os_version {
local os_version
grep -c "buster" /etc/os-release
}

if [ "${BASE_ADD_USER}" == "yes" ]; then
if [ "${BASE_DISTRO}" == "raspbian" ]; then
# Setup first user, reference:
Expand All @@ -46,7 +52,10 @@ if [ "${BASE_ADD_USER}" == "yes" ]; then
if [ -n "${BASE_USER}" ] || [ -n "${BASE_USER_PASSWORD}" ]; then
pw_encrypt="$(echo "${BASE_USER_PASSWORD}" | openssl passwd -6 -stdin)"
echo "${BASE_USER}:${pw_encrypt}" > /boot/userconf.txt


# Upgrade pkg first, make sure latest version will be patched
apt install --yes --only-upgrade userconf-pi

# Patch cancel-rename due to https://github.com/RPi-Distro/userconf-pi/issues/2
# And https://github.com/guysoft/CustomPiOS/issues/163
unpack /filesystem/patches /patches root
Expand All @@ -59,7 +68,12 @@ if [ "${BASE_ADD_USER}" == "yes" ]; then
exit 1
fi
}
create_userconf
# Do not patch if raspian="buster"
if [ "$(get_os_version)" == "0" ]; then
create_userconf
else
echo "Base Image use Version 'buster' no patching of userconf-pi needed"
fi
else
if id -u "${BASE_USER}" >/dev/null 2>&1; then
echo "Base user exists, not adding"
Expand Down