I want to run my system configuration script (written in python) after boot. System should ask for password for user USER and run my script. After that system should reboot, eventually run gui.

I would like to know what is best method to do something like that. User should not have access to bash... this is just for base configuration. I would like this to be option in grub, so user can run normal system or configuration script.

  • Just add init=path_to_my_script in grub entry and then in script: os.execv('/sbin/init', ['/sbin/init']) -to run normal session :) – marcinpz Jan 9 '12 at 13:05

You can't really add this as an option in grub, but I can tell you how to make the script run on login or when you open a terminal, but if you are not allowing someone to run the bash software, it should not be a problem.

Just add the line to your ~/.bashrc:

python SCRIPT_FILE_HERE (any arguments should also be added here)

and all should be sorted :)

  • Thank you. Generally I know that and I need something more: I can add grub entry to start session in runlevel=1 (for example), or maybe add some additional flag to existing grub entry, and during boot check if configuration should be run. – marcinpz Dec 28 '11 at 14:16

I think this is what you're looking for, though it's very old (6.10).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.