Page 1 of 2

Are there/where are the configuration scripts?

Posted: 17. Jan 2010, 05:22
by Mol_Bolom
I've got a computer prepared to sell and I just need to do one more thing, force the user to configure root password and user account, but haven't had any luck. Well, that's not entirely true, I've started working on a script using dialog, and have plans on starting another script using xdialog that would run when X starts up first. However while preparing the section for creating the user groups I realized that it's going to take me at least a week to get that part figured out, then another week to spruce up the code. I'm not too scared of figuring it out on my own, hell, I'd prefer the groups being a checkbox rather than an edit box like the installs have. That way a person installing it can look over and see what all of the groups are, oh, and add a help button so they would know what all the groups are, too (This is why it'd take me so bloody long to code it...Hmm...Probably take a whole month)...

Either way, where are the configuration scripts located? or Is it even possible to use only the root/user config scripts so this system would force the purchaser to configure them? or Any other ideas?

Thanks...

<Edit> Someone just asked this question earlier today at linuxquestions, so posting it on the iffy side someone comes across this one...
http://www.linuxquestions.org/questions ... de-783616/

Re: Are there/where are the configuration scripts?

Posted: 17. Jan 2010, 13:39
by gapan
I'm not really sure what you're asking. If you're talking about usersetup, that's in /usr/sbin.

You can add an rc script in /etc/rc.d/ that will ask for the root password, then display a message that the user needs to create a non-privileged account, then run usersetup, and have the script delete itself after everything is done.

Re: Are there/where are the configuration scripts?

Posted: 18. Jan 2010, 18:19
by Mol_Bolom
gapan wrote:I'm not really sure what you're asking. If you're talking about usersetup, that's in /usr/sbin.
Was able to test it today, and yep that's what I was looking for.
You can add an rc script in /etc/rc.d/ that will ask for the root password, then display a message that the user needs to create a non-privileged account, then run usersetup, and have the script delete itself after everything is done.
Ah, if it was only that easy. If I put it in rc.4 before gdm starts, usersetup then has issues, or quits, and gdm goes ahead and starts. If I put it at the end of rc.inet2 then the splash screen never ends. Looks like I'll have to change vga to normal and write a whole new script that will run lilo and reset back to 751. Hopefully I can find a way around that...

Anyway...Thanks...

Re: Are there/where are the configuration scripts?

Posted: 18. Jan 2010, 18:29
by gapan
I think it really is easy. You can add something like:

Code: Select all

if [ -x /path/to/your/script ]; then
  . /path/to/your/script
fi
at the end of rc.S, change the default init to 3 by editing /etc/inittab, and then have that script first shut down the bootsplash, ask for new root password, run usersetup, set the init back to 4 using sed and then have it delete itself. :ugeek:

Re: Are there/where are the configuration scripts?

Posted: 18. Jan 2010, 18:34
by Shador
Mol_Bolom wrote: Ah, if it was only that easy. If I put it in rc.4 before gdm starts, usersetup then has issues, or quits, and gdm goes ahead and starts. If I put it at the end of rc.inet2 then the splash screen never ends. Looks like I'll have to change vga to normal and write a whole new script that will run lilo and reset back to 751. Hopefully I can find a way around that...
Put it into rc.M. At least that's where zenwalk puts it postinstall script.
rc.postinstall of Zenwalk: http://pastebin.org/78275
rc.M of Zw: http://pastebin.org/78276

Instead of splash you might have to put splashy into verbose mode.

Re: Are there/where are the configuration scripts?

Posted: 18. Jan 2010, 21:40
by Mol_Bolom
Shador wrote: Put it into rc.M. At least that's where zenwalk puts it postinstall script.
rc.postinstall of Zenwalk: http://pastebin.org/78275
rc.M of Zw: http://pastebin.org/78276

Instead of splash you might have to put splashy into verbose mode.
After trying it out in rc.M I found how to get around splashy. Before calling the script I used chvt 8, for some reason at the beginning of rc.M the system would hang, after the exit script for splashy, then it would load only on vt 8 no matter where I put it. Either way, it works now...

in rc.M

Code: Select all

#After exiting splashy...
if [ -f /etc/rc.d/configusers ]; then
     /usr/bin/chvt 8
     /etc/rc.d/configusers
fi
configusers script. (I'm terrible with words, but hopefully the msgbox's are enough)

Code: Select all

#!/bin/bash

dialog --msgbox "Before running the system you need to setup a password
for your root account and create one or more user accounts.\n\nPress enter to
continue." 15 45

passwd

dialog --title "Note:" --msgbox "/home is a seperate partition for all
users. If you wish to change the user directory, then there will be an
extra partition that is not being used." 15 30

usersetup

rm /etc/rc.d/configusers
Unfortunately, I couldn't figure out how to use passwd or change the roots password from scripts, as of yet.

Also, the usersetup script is different than the setup scripts in the install, so I might as well remove the last dialog I added. It seems to automatically use the /home directory for users. Though just in case someone might want to change it, probably would be a good idea to leave it in there.

Anyway, thanks for all yer help...;)...

Re: Are there/where are the configuration scripts?

Posted: 18. Jan 2010, 21:44
by gapan
Look in the SeTpasswd script used in the installer to get an idea. It's in svn: http://sourceforge.net/apps/trac/salix/ ... /SeTpasswd
You don't have to chroot as that does, you're already using that partition.

Re: Are there/where are the configuration scripts?

Posted: 18. Jan 2010, 22:42
by Mol_Bolom
Thanks gapan...takk gapan...wado gagwan...kolaval kapan...

Worked like a charm... :mrgreen:

Basically the same script, just modified a little.

Code: Select all

#!/bin/sh

  dialog --title "Password setup" --msgbox \
"You will be presented with some dialogs to setup a password for the \
root user. Make sure that this is a strong password.\n\nAfter that you \
will be presented with a menu that allows you to setup user accounts. \
You are advised to create at least one non-privileged user account for \
everyday use.\n\nUsing the system as the root user is highly not \
recommended. \
disabled by default." 0 0

# Password dialog
passbox(){
        DIALOG='dialog --stdout --insecure --fixed-font --no-cancel --smooth --passwordbox'
        pw="$(${DIALOG} "${1}" 12 80)"
        echo -n "$pw"
}


# Password checking
changepw(){

minlength=5

count=1 ; pw='_'
while [ "${pw}" != "${password}" ]; do
        password="" ; pw='_'

        message="Enter password for the root user:"
        [ $count -ge 2 ] && message="Passwords don't match, enter password for the root user:"
        while [ ${#pw} -lt ${minlength} ]; do
                pw="$(passbox "${message}")"
                message="Password is too short (${minlength} chars minimum), please try another one:"
        done
        password="$pw" ; pw='_'
        message="Enter password for the root user again:"
        pw="$(passbox "${message}")"

        count=$((count+1))

done

echo -n $password
}

# Change password
setpw() {
        pass="$(changepw root)"
        if [ ! "$pass" ] ; then
                dialog --msgbox "Failed to set password for the root user" 8 75
        else
                echo "root:${pass}" | chpasswd
        fi
}

setpw

dialog --title "Note:" --msgbox "You are now ready to add users to your
system.  /home is a seperate partition set aside for this
purpose.\n\nPress enter to add users." 15 30

/usr/sbin/usersetup

rm /etc/rc.d/configusers


Re: Are there/where are the configuration scripts?

Posted: 19. Jan 2010, 09:04
by JRD
Yes splashy is a bit sloooow to respond to the exit command.

Re: Are there/where are the configuration scripts?

Posted: 19. Jan 2010, 14:49
by thenktor
JRD wrote:Yes splashy is a bit sloooow to respond to the exit command.
killall splashy
killall -9 splashy
:?: