View previous topic :: View next topic |
Author |
Message |
etnull Guru

Joined: 26 Mar 2019 Posts: 487 Location: Russia
|
Posted: Thu Oct 15, 2020 3:39 pm Post subject: [S] Proper way of managing a new regular user under chroot |
|
|
At the end of Gentoo install you usually create a regular user, assign groups, passwords and make other small finishing edits. Creating user under chroot is not a problem, but making edits for that user turned out to be more tricky than I expected, I can't just edit files in ~/ of the regular user from root, it will mess up ownership of these files, so I did all my edits with something like this:
Code: | runuser -l *USER* -c '*command*' |
I created basic folder structure:
Code: | runuser -l *USER* -c 'mkdir ~/{desktop,documents,downloads,music,pictures,public,videos}' |
edited .bash_profile, .xinitrc and .Xresources in similar way. After all of that I rebooted, logged-in as that user, but all my edits were gone... no folders, .bash_profile and the rest were like if they were copied from some default location. Also during login I noticed that the last login was mentioned as pts/0, so I assume for the first login of a user these files are copied from somewhere to make defaults?.. At some point I'm going to make an installation script and I need to figure out this user creation step to properly finish the install.
Last edited by etnull on Thu Oct 15, 2020 9:45 pm; edited 1 time in total |
|
Back to top |
|
 |
sabayonino l33t


Joined: 03 Jan 2012 Posts: 833
|
Posted: Thu Oct 15, 2020 9:20 pm Post subject: |
|
|
You can run "chroot" commands inside your script without any prompt
Code: |
#/bin/bash
<your script part>
# Entering in your chroot environment without any prompt : just execute all commands between EOF strings
cat << EOF | chroot ${ROOT} /bin/bash
<do anything as gentoo wiki explain or according your needs>
EOF
<continue your script>
|
Where ${ROOT} is your gentoo mountpoint (/mnt/gentoo or something else)
so :
Code: |
#/bin/bash
<start your script here>
# Now you can run commands inside your chroot
# Entering in your chroot environment without any prompt : just execute all commands between EOF string
cat << EOF | chroot ${ROOT} /bin/bash
mkdir -p /home/<user>/{Desktop,Downloads,...}
# change the <user> permisisions
# <do something else : emerge , install a program , remove directories and so on>
EOF
# The script exit from chroot after last comm.
<continue your script>
|
Cheers _________________ BOINC ed il calcolo distribuito
My LRecoverySystem Repo |
|
Back to top |
|
 |
etnull Guru

Joined: 26 Mar 2019 Posts: 487 Location: Russia
|
Posted: Thu Oct 15, 2020 9:44 pm Post subject: |
|
|
Using "su - *USER*" to swith to that user and execute everything uder it was the proper way, or at least it was persistent after I logged in properly with that user. I don't know what was wrong with runuser commands, but those were my findings. I'm not yet writing the script, not sure if it gonna work in that case, but that's for later to discover. |
|
Back to top |
|
 |
sabayonino l33t


Joined: 03 Jan 2012 Posts: 833
|
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|