Launching firefox browser just after dhcp request on Linux

I'm developing linux based application. After entering into init 5 level, system make dhcp request to assign ip address to ethernet card. Just after that I need to launch firefox browser before any other service comes up. After Im done(after closing the browser), then I would like network service initailization continued.
I don't know what extact command or sequence of commands I need to execute to launch the browser.
and where extactly (file and place)I need to call these commands.

Please advise.
Who is Participating?
agriesserConnect With a Mentor Commented:
Use `startx`. It starts the X server plus the first X client mentioned in a file called xinitrc. xinitrc usually resides in $HOME of the user starting `startx`, so if you're going to run `startx` as root, make sure you have a file /.xinitrc that contains the following lines:

The only problem with this approach is that the X server stops after the last X client has finished.
The invocation of firefox drops you immediately back to the command line which would cause the X server to shutdown right after it started firefox.

You need to add a program in the last line of xinitrc that either never quits or stays active as long as the user doesn't quit this application.

Depending on your needs you could even start a tiny window manager first (e.g. icewm) and start firefox right after icewm has started.

What's appropriate for your environment? What do you want to achieve?

Open in new window

What distribution are you using?  You'd have to launch a window manager before you can launch firefox...
pkgoyalAuthor Commented:
I'm using fedora core 6. Yeah I know that I need to launch window manager.. but how should I do that...
what command should I issue to launch both window manager as well browser...
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

What are you trying to do?  

You really should not be using a browser (or any other user-mode UI program)  in the middle of system initialization.  It has far too many dependencies on other services which may not yet be started.  

The init scripts which are part of system startup are run as root.  You really don't want to run user applications, such as firefox, as root.  There are just too many security holes.

If there is specific information which you need from a web server, look at using wget and other command line tools to obtain that info. This can be used to create a script which can be added to /etc/init.d.
pkgoyalAuthor Commented:
This is a kind of thin client... it will have very limited resouces and authentication will be done by server.
User bowser will be launched as root just after client gets ip via dhcp. and user is supposed to enter user name and password and after this only I need to start rest of required services.
So kindly tell me where (source code or script,) where  ip assignmnet via dhcp takes place so that just after that I can write code to launch the browser.
That depends on the linux distribution you're using. Usually, there are init scripts in /etc/init.d, one of them might be called "networking" or "network" or something like this.
After this script has completed, you should got an IP address and can start the browser/X Server then.
eagerConnect With a Mentor Commented:
Why start a browser to get username and password?  What did you expect your browser to do if you enter the right or wrong username/password?   When (or if)  the user closes the browser, your system will continue to initialize.  

As I said, running a browser as root is an invitation for security troubles.  The browser is controlled by the user, not by the system.

It's easy to write a small bash script which can prompt for username/password and use any of several different ways to validate this with the server.  SOAP is one way.  

The sequence of startup operations is controlled by /etc/rc?.d, where ? is the init mode.  Normal graphical startup is mode 5.  In each directory there are links to scripts in /etc/init.d which start with an S if the script is to be run when entering the mode, and K if it is to be run when exiting the mode.  Entries are run in ascending order.  
pkgoyalAuthor Commented:
I just tried startx /usr/bin/firefox (as suggested by agriesser )after booting my system in init level 3 after login into the system as root.
It started the window manager and launched the browser as well. But when I closed the brwoser window I did not get  the same command prompt(why ?) from where I invoked the command rather I got blank screen and I had to restart my machine.
pkgoyalAuthor Commented:
For eager question: to start brwoser is requirement from my customer. I've to do that....
Are you booting in framebuffer mode? That usually happens when the console framebuffer is enabled and the Xorg driver has troubles to get the framebuffer mode back up after the X Server has quit.

@eager: As far as I understand, it's a thinclient, so no data on it, no security stuff.
Besides that, when the browser has been quit at the end of the initialization process, there's still the console login which needs to be passed to get access to this system.

I could even think of a script that shuts down the thinclient when the browser has quit.
pkgoyalAuthor Commented:
Are you booting in framebuffer mode?
What is framebuffer mode.
The framebuffer mode on the console allows for having fancy graphics while booting (e.g. your distribution's logo, a progress bar, etc.) and gets you highter resolutions (you're not limited to the 80x25 lines in plain text mode).

To see if you're booting in framebuffer mode, issue the command `cat /proc/cmdline` and check for the existance of a "vga=" parameter. If it's set to something else than "normal", you're booting in framebuffer mode.

To make your system boot in console mode, edit your bootloaders configuration file (/boot/grub/menu.lst usually) and replace the "vga=something" with "vga=normal" or simply remove the "vga=..." option at all.
Any updates on this one?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.