build icon indicating copy to clipboard operation
build copied to clipboard

[RFC]add automatic support to armbian-firstlogin

Open amazingfate opened this issue 1 year ago • 10 comments

Description

Add preset variables so that image can do first login automaticly without user interaction. I store variables like username/password in /root/.not_logged_in_yet so that it will get deleted after firstlogin. We can add set these variables by extension post_family_tweaks in board config:

function post_family_tweaks__firstlogin_preset_configs() {
	display_alert "$BOARD" "preset configs for firstlogin" "info"
	echo "PRESET_USER_SHELL=bash" > "${SDCARD}"/root/.not_logged_in_yet
	echo "PRESET_CONNECT_WIRELESS=n" > "${SDCARD}"/root/.not_logged_in_yet
	echo "SET_LANG_BASED_ON_LOCATION=y" >> "${SDCARD}"/root/.not_logged_in_yet
	echo "PRESET_LOCALE=zh_CN.UTF-8" >> "${SDCARD}"/root/.not_logged_in_yet
	echo "PRESET_TIMEZONE=Asia/Shanghai" >> "${SDCARD}"/root/.not_logged_in_yet
	echo "PRESET_ROOT_PASSWORD=Armbian" >> "${SDCARD}"/root/.not_logged_in_yet
	echo "PRESET_USER_NAME=jfliu" >> "${SDCARD}"/root/.not_logged_in_yet
	echo "PRESET_USER_PASSWORD=Armbian" >> "${SDCARD}"/root/.not_logged_in_yet
	echo "PRESET_DEFAULT_REALNAME=Jfliu" >> "${SDCARD}"/root/.not_logged_in_yet
}

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Please also note any relevant details for your test configuration.

  • [x] Build command ./compile.sh BOARD=fl700n BRANCH=edge DEB_COMPRESS=xz KERNEL_GIT=shallow BUILD_DESKTOP=yes BUILD_MINIMAL=no KERNEL_CONFIGURE=no RELEASE=bookworm DESKTOP_ENVIRONMENT=xfce DESKTOP_ENVIRONMENT_CONFIG_NAME=config_base DESKTOP_APPGROUPS_SELECTED=''
  • [x] Boot image with or without ethernet network, board boots into xfce desktop environment without user interaction
  • [x] ~Haven't tested on board with wireless. I haven't implement automatic Connect via wireless? [Y/n]. I will do it later.~ Tested on orangepi 3b with wireless. ./compile.sh BOARD=orangepi3b BRANCH=edge DEB_COMPRESS=xz KERNEL_GIT=shallow BUILD_DESKTOP=yes BUILD_MINIMAL=no KERNEL_CONFIGURE=no RELEASE=bookworm DESKTOP_ENVIRONMENT=xfce DESKTOP_ENVIRONMENT_CONFIG_NAME=config_base DESKTOP_APPGROUPS_SELECTED=''

Checklist:

  • [x] My code follows the style guidelines of this project
  • [x] I have performed a self-review of my own code
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [x] My changes generate no new warnings
  • [ ] Any dependent changes have been merged and published in downstream modules

amazingfate avatar Jan 23 '24 16:01 amazingfate

Not quite the same but many of those configuration values can be set through other config vars as well.

https://github.com/lanefu/armbian-userpatches-example-indiedroid-nova/blob/a42f7b71d111e52d797a892f3807fefd6acd3ab3/config-opinionated.conf#L9-L25

I believe root password can be set via declare -g ROOTPWD=

Barbaric example of removing firstrun

Example of pre-installing ssh key

lanefu avatar Jan 23 '24 20:01 lanefu

Not quite the same but many of those configuration values can be set through other config vars as well.

https://github.com/lanefu/armbian-userpatches-example-indiedroid-nova/blob/a42f7b71d111e52d797a892f3807fefd6acd3ab3/config-opinionated.conf#L9-L25

I believe root password can be set via declare -g ROOTPWD=

These configs are set at build time, I think armbian-fisrtlogin will still do the user/password creation process.

Barbaric example of removing firstrun

This just disable the firstrun service. I want to run firstrun service with preconfig so people don't have to connect a keyboard to do some manual operations. I like the process of firstrun service, so my code are integreted in its script.

amazingfate avatar Jan 24 '24 01:01 amazingfate

Add variable PRESET_CONNECT_WIRELESS to skip connecting wireless.

In manual root password creation process, script will kill other logged in sessions after root password is typed. But this kill action will exit the automatic script. So in automatic process, if PRESET_ROOT_PASSWORD is set, script will exit if it is not running in tty1. So automatic firstlogin script will only run in tty1.

amazingfate avatar Jan 25 '24 07:01 amazingfate

If this is being reworked ... one additional idea.

/boot/armbian_first_run.txt.template and all this mechanism hasn't been touched for past 8 years. It was more or less merged by mistake and left there to rot.

However 1st run predefined wireless / network connect seems to be useful and I would say we extend this PR to include this functionality and remove: packages/bsp/common/usr/lib/armbian/armbian-firstrun-config packages/bsp/common/lib/systemd/system/armbian-firstrun-config.service packages/bsp/armbian_first_run.txt.template

What do you think?

igorpecovnik avatar Jan 25 '24 09:01 igorpecovnik

I haven't tried the old armbian-firstrun-config service to preconfig ethernet/wireless networks. I guess it will run before the firstlogin script. I will test the old service to see if it works. PRESET_CONNECT_WIRELESS in this PR only works when there is a wireless device and the board is not connected to internet. So if the old armbian-firstrun-config service works before the service in this PR, we can keep it.

amazingfate avatar Jan 25 '24 09:01 amazingfate

service works before the service in this PR, we can keep it.

It feels we have some redundancy.

I want to get rid of it and have wireless setup also a part of your config. Does it makes sense?

igorpecovnik avatar Jan 25 '24 10:01 igorpecovnik

Let me try it.

amazingfate avatar Jan 25 '24 15:01 amazingfate

If you have time to complete and test this within a week, we can merge it into 02 ...

igorpecovnik avatar Feb 10 '24 08:02 igorpecovnik

I come back to my hometown with no board to test and will be back to my boards at 18th, Feb. But I can do some coding these days and test it when I can reach my boards.

amazingfate avatar Feb 10 '24 11:02 amazingfate

Thanks. No problem, we will merge this after release then.

igorpecovnik avatar Feb 10 '24 13:02 igorpecovnik

FR_* network configs are moved from armbian-firstrun-config and armbian-firstrun-config related files are deleted. Add an extension preset_firstrun to do these preconfig. Just add one line enable_extension "preset-firstrun" to apply it.

amazingfate avatar Feb 21 '24 12:02 amazingfate

Thanks Igor, I didn't have time to change and test.

amazingfate avatar Mar 03 '24 15:03 amazingfate

Thanks Igor, I didn't have time to change and test.

I know ;)

igorpecovnik avatar Mar 03 '24 15:03 igorpecovnik