Menu Driven UNIX Admin

I need to have a script that can do an automated IPL function (how to reboot the box). I think �reboot� would do the trick.

However, how would I go about doing it, for example if the user states from a menu script that I would like to reboot now. The problem is when I do the �reboot� command I get a message (obviously) because I am not the super user. But I do have another gem network in which I have root superuser access.

So how would I from the below script which I need to write whilst I am not in super user mode do the �reboot� command from the normal user mode. Is there a way of having, for example when the user chooses option 1, then it states enter the other gem network root username and password (so i am the superuser) and then be able to do the �reboot� command?

I hope I have not made it difficult to understand for you.

......Code carries on for the other 3 options

If the user which has privileges is on the same machine, just start the script when you are logged with this username. Otherwise, switching the user can be done with "su -user -c command" where command can be replaced by "shutdown -r now" or "reboot" but you have to provide the password. Consider sudo as well.

There's also another possibility, though I would not recommend it.
chgrp reboot command to a "reboot group", SETUID reboot command (chmod 4750), and add those "reboot allowed users" to that "reboot group".
Take into account that:
1- This is very dangerous, so consider using what sysgage suggests first.
2- reboot must be a binary file.
Regards.

Im getting 'Invalid Option'

Is this correct:

echo "Would you like to reboot the box?"
        echo "Ok to procede?"; read ans

                                        case "$ans" in
                                        n*|N*)
                                        echo "-------------------------------------"
                                        echo "Machine has not been rebooted"
                                        echo "Machine has not been rebooted">>report.txt
                                        exit 0   ;;

                                        esac
                                        su -user -c shutdown -r reboot
                                        echo "-------------------------------------"
                                        echo "Machine has been rebooted"
                                        echo "Machine has been rebooted">>report.txt

Notice the white space :slight_smile:

Wouldn�t work ... but messed about with it ... and it worked! Thanks.

One last help.... how do i:
1) Add and delete a user (I know 'deluser' and 'adduser' does it), but in a menu type system how would I implement it? Is choosing from another submenu OK? e.g. 1.Add User 2. Delete User ... (I already have a menu, and one option is User Management, so I need to put the 'adduser/deluser' and no.2 within this option)
2) Check a user exists on the system then change a password.

Any hints of how it would be done greatly appreciated or guidance to some good online help books.

Kind Regards to all especially sysgate & grial.

apropos is your friend.