This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Initialization of a new user from a bash script

Tags: None
(comma "," separated)
User avatar
jcdole
Registered Member
Posts
49
Karma
0
OS
Hello.
When creating a new user
Code: Select all
    useradd --create-home --comment "$WORK_USER" "$WORK_USER"
    passwd "$WORK_USER"
    usermod -aG vboxusers "$WORK_USER"

At this step, only /etc/skel is copied to the new user's home.
.config, .local, .... are not yet installed.
The Initialization of a new user is finished ( by some hidden script(s) ) when the new user log for the first time.

Presently I run a bash script to fully configure any new computer.
I run this script in two step.
After creating the initial user the script wait, I switch (from the application menu 'Switch User') to the new user account. So the new user configuration completed, then log out, then switch to myself.
Then I continue the script to finish the user configuration.

Is it possible to do the same task within the running script
-) switch to new user
-) log out from new user account
-) switch back to previous user
-) if no error continue script.

Any help is welcome.
koffeinfriedhof
Registered Member
Posts
608
Karma
4
OS
Why don't you copy the things you need before first login to /etc/skel?

You may use kwriteconfig5 to set up some configurations, but I never tried out → KDE_System_Administration/Configuration_Files
User avatar
jcdole
Registered Member
Posts
49
Karma
0
OS
koffeinfriedhof wrote:Why don't you copy the things you need before first login to /etc/skel?

You may use kwriteconfig5 to set up some configurations, but I never tried out → KDE_System_Administration/Configuration_Files

I have a user template with some applications already configured ( kate, dolphin, .. ) Favorites, Panel widget, and system settings generally set by using systemsettings.
All that stuff goes in /home/some_user/{.config .local} and in /home/some_user/.bashrc and .profile.
But all the files created during the first login step are not in my template.
If I put the template contains before the new user first log in, the templatewould be either overwriten or leave as is and then many initial config files should missing.

As I said I have a script that do the job, but a human action is needed half way.
koffeinfriedhof
Registered Member
Posts
608
Karma
4
OS
If these settings get overridden it is probably a bug as KDE shows the usage of /etc/skel too → https://userbase.kde.org/Tutorials/Modify_KDE_Software_Defaults

A workaround would be using a default script running via sddm (e.g. /usr/share/sddm/scripts/Xsession) or /etc/profile and checking for settings or a specific file.
User avatar
jcdole
Registered Member
Posts
49
Karma
0
OS
I’m looking for a method for switching user from script (Like the KDE Button switch user in application launcher).


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], q.ignora, watchstar