I'm customizing an Ubuntu 22.04 installation, and using "pressed" I entered some information such as time zone (which works when you want hehehe), username and password, as well as groups to add this user, hostname suggestion, network suffix, which initially suits me well.
After that, after rebooting the machine, an operator would have to log in and click on a script to make some final adjustments, among which would be the creation of a second user.
Thinking about reducing the space and operation of this Operator, I came up with the idea of putting this part - creating an additional user and installing a local package - inside "ubuntu.seed" using the entry "d-i preseed/late_command".
Then the doubts begin:
The function - to run something after installation - is fine, and there are examples everywhere;
Existing examples always speak of copying from one place to another. In my case, it is already inside the installed image, in a certain folder without problems.
- I have already used the following options:
d-i preseed/late_command string chroot /target sh -c "/bin/sh /usr/local/bin/MYFOLDER/install/inst-end.sh" d-i preseed/late_command string in-target /bin/sh /usr/local/bin/MYFOLDER/install/inst-end.sh in-target /bin/sh /usr/local/bin/MYFOLDER/install/inst-end.sh d-i preseed/late_command string chroot /target sh -c "/bin/sh /usr/local/bin/MYFOLDER/install/inst-end.sh"And in others I solved by the entire script:
d-i preseed/late_command string \ sudo useradd -m -d /home/NEWUSER -p $(openssl passwd PASSWORD) -c adm_procergs -s /bin/bash adm_procergs; \ sudo addgroup NEWUSER sudo; \ sudo addgroup NEWUSER root; \ sudo addgroup NEWUSER administrator; \ sudo addgroup NEWUSER adm; \ sudo addgroup NEWUSER cdrom; \ sudo addgroup NEWUSER dip; \ sudo addgroup NEWUSER plugdev; \ sudo addgroup NEWUSER lpadmin; \ sudo addgroup NEWUSER sambashare; \ sudo cp /usr/local/bin/MYFOLDER/install/adm_procergs /var/lib/AccountsService/users/FILE01; \ sudo cp /usr/local/bin/MYFOLDER/install/FILE02 /var/lib/AccountsService/users/FILE02 \ sudo sed -i "/^root/ a NEWUSER ALL=(ALL:ALL) ALL" /etc/sudoers; \ sudo chown NEWUSER:USERROOT/var/log/out-install; \All unsuccessful.
The doubts are:
Is there a place where I should store these Scripts to be copied?
Is there a need to be copied?
If I can make them run on the installed system and not on the live running, what would be the secret?
What's my mistake in writing when using "d-i preseed/late_command" if I wanted it to run the Script on the target machine now; In the execution of the commands and finally, that copies files and executes from one side to another.