MEPIS This forum is for the discussion of MEPIS Linux. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
11-22-2006, 10:24 AM
|
#1
|
LQ Newbie
Registered: Nov 2006
Posts: 15
Rep:
|
How Do I Create A Startup Script?
How do I create a startup script to run an application in background during/after booting up? The application in question is already installed. I presently use a desktop icon to launch it immediately after booting up, but I really would rather have it launch itself automatically. Does this have anything to do with "daemons" and such?? Please provide a step-by-step example of how to do this, since I am quite new to Linux and need a lot of hand holding at this stage!
Thanx
|
|
|
11-22-2006, 10:34 AM
|
#2
|
Member
Registered: Oct 2006
Location: Utah
Posts: 520
Rep:
|
What is the application?
What distro are you using?
|
|
|
11-22-2006, 12:01 PM
|
#3
|
LQ Newbie
Registered: Nov 2006
Posts: 15
Original Poster
Rep:
|
Startup Script
fordeck,
I'm using Mepis, which I believe is a variation of Debian, and the application I want to launch is VMware-Toolbox.
|
|
|
11-22-2006, 01:27 PM
|
#4
|
Member
Registered: Oct 2006
Location: Utah
Posts: 520
Rep:
|
I'm not real familiar with Mepis. However I believe you could append the VMware-Toolbox statement into your user's ~/.profile file so that every time you login it is run.
Last edited by fordeck; 11-22-2006 at 01:29 PM.
|
|
|
11-22-2006, 02:12 PM
|
#5
|
LQ Newbie
Registered: Nov 2006
Posts: 15
Original Poster
Rep:
|
fordeck,
Thanks for getting back to me. I opened a terminal and typed "locate .profile" and got hits on a number of files in the form *.profile, including one named "/usr/share/base-files/dot.profile"
When I open the file in a text editor, there is a header that says:
"# ~/.profile: executed by Bourne-compatible login shells."
Is this the file I should try to append? What is the proper syntax for a line of script that starts an application from this file? For example, if the terminal command to start the application is "vmware-tools," is that all I need to append to the script? Or should the syntax be: "vmware-tools start" in the script?
I'm sorry for asking such stupid questions, but as I said earlier, I need a lot of help at this stage.
Thanks in advance for your help ...
|
|
|
11-22-2006, 04:21 PM
|
#6
|
Member
Registered: Oct 2006
Location: Utah
Posts: 520
Rep:
|
The .profile I spoke of would be in your user's home directory for example:
/home/joany/.profile
This file is ran everytime you login. You could append something like this to the bottom of .profile:
Code:
if [ -x /<path-to-vmware-tools>/vmware-tools ]; then
/<path-to-vmware-tool>/vmware-tools
fi
However this approach could cause problems. Like I said earlier .profile gets executed everytime you login. A better approach would be to create a PID or process id file when vmware-tools starts, and have the script check for its existence. I'll have to see if I can create something that would do that.
Last edited by fordeck; 11-22-2006 at 04:22 PM.
|
|
|
11-23-2006, 09:48 AM
|
#7
|
LQ Newbie
Registered: Nov 2006
Posts: 15
Original Poster
Rep:
|
fordeck,
Thanks for your time and trouble. I log in as "username", but unfortunately, I cannot locate a file named /home/username/.profile on my system.
It may be that Mepis uses a different naming convention for the profile file than the distro you're using. I'll try adding the lines of code you suggested in your last post into the /usr/share/base-file/dot.profile file and see what happens. Having the code run every time I log in should not be a problem.
As you might have guessed I'm running Mepis on a virtual machine (VMware) instead of from a full install, so there's no harm in trying this out. I'm presently taking Mepis for an extended "test drive" before doing a full install. So I'll back up my virtual file system and if things get out of hand and "blow up," I can easily restore everyting back to normal from the back up copy.
Thanks again...
|
|
|
11-23-2006, 10:10 AM
|
#8
|
Member
Registered: Oct 2006
Location: Utah
Posts: 520
Rep:
|
Your right, I don't use Mepis so maybe they do it differently. You could also create one in your home directory and see if that works. The file you mentioned above /usr/share/base-file/dot.profile is probably a template file for users personal .profile files. You probalbly already know this but just in case. Files that begin with a "." are hidden files and can be listed by:
ls -a
or you can view the contents like this:
cat ~/.profile
Last edited by fordeck; 11-23-2006 at 10:18 AM.
|
|
|
11-24-2006, 12:55 PM
|
#9
|
LQ Newbie
Registered: Nov 2006
Posts: 15
Original Poster
Rep:
|
fordeck,
You may be quite right about the /usr/share/base-file/dot.profile being only a "template" file. I'll try creating a new hidden file named /home/username/.profile containing the lines of code you suggested in your 11-22-06 5:22PM post. I'm at a friend's house and will get back to testing Mepis on my computer next Monday. I'll post the results early next week.
Thanks once again and cheers.
|
|
|
11-27-2006, 05:53 AM
|
#10
|
LQ Newbie
Registered: Nov 2006
Posts: 15
Original Poster
Rep:
|
fordeck,
Following your suggestion, I created a file named /home/username/.profile and wrote the following lines of code using a text editor:
if [ -x /usr/bin/vmware-tools ]; then
/usr/bin/vmware-tools
fi
I verified that the .profile file had been saved in the proper folder, then I rebooted the machine and logged in as username. Unfortunately, it seems that the script I wrote in the .profile file failed to execute during the sign-on sequence, because vmware-tools wasn't running and I had to start it manually.
|
|
|
11-27-2006, 10:00 AM
|
#11
|
Member
Registered: Oct 2006
Location: Utah
Posts: 520
Rep:
|
One other possibility might be to use "/etc/rc.d/rc.local". This path is relative to a Fedora installation. Your rc.local might be in another location. The rc.local file is executed after all other runlevel scripts have run at bootup. Again this file only runs at system bootup. Also it would probably be a good idea to run vmware-tools in the background so one small modification to the code:
Code:
if [ -x /usr/bin/vmware-tools ]; then
/usr/bin/vmware-tools &
fi
The ampersand added to run it in the background.
|
|
|
11-27-2006, 04:20 PM
|
#12
|
LQ Newbie
Registered: Nov 2006
Posts: 15
Original Poster
Rep:
|
fordeck,
Thanks once again for your trouble. I agree that it would be preferable to run vmware-tools in the background, and I'll add the "&" to the code to do that.
I did some research and learned that by default, VMware is supposed to automatically launch while the Linux guest OS boots. But it seems that Mepis doesn't fully support all of VMware's features, which is why I'm having this problem. It could be that Mepis uses different startup files than the other distros.
I won't have time to try out your most recent suggestion until tomorrow -- I'll post the result then.
Cheers
Last edited by joany; 11-28-2006 at 07:25 AM.
|
|
|
11-28-2006, 07:21 AM
|
#13
|
LQ Newbie
Registered: Nov 2006
Posts: 15
Original Poster
Rep:
|
Okay...
I located a file named /etc/rc.local. The file header states that the script is executed, "At the end of each multiuser run level."
There is another file named /etc/init.d/rc.local. The script contained in that file calls /etc/rc.local, so I thought the logical choice was to insert the script that launches vmware-tools into /etc/rc.local. Using root privileges, I edited /etc/rc.local, saved the file, rebooted, and logged in under username. As before, vmware-tools was not running after I logged in and I had to start it manually.
Finally, I said, "What the heck," and inserted the script to launch vmware-tools into /etc/init.d/rc.local, saved the file, rebooted and logged in. Same result: Vmware-tools was not running.
At this point, I'm not at all sure that my script is even being accessed during boot-up or logging in. Is there some way to display some sort of message or banner that would verify that the script I added is actually being read? That could help pinpoint whether there is a problem with the script itself or if the script simply is being ignored.
This has been quite educational for me, even though we haven't solved the problem!
|
|
|
11-28-2006, 12:58 PM
|
#14
|
LQ Newbie
Registered: Nov 2006
Posts: 15
Original Poster
Rep:
|
... Continued
It seems that with Mepis, any executable files that are saved in the folder /home/username/.kde/Autostart will start automatically when "username" logs in.
Now my question is how can I create a script file (from scratch) that launches itself from that folder? Can one use any text editor (like GEDIT) to create such a script file, or is a special editor required? How should I save such a file; i.e., what is the convention for naming executable script files?
I used GEDIT to create a file named "vmware" with script code in it. Then I saved this file into the Autostart folder. However, when I logged in, GEDIT launched itself and displayed the text in the "vmware" file, instead of executing the script that I wrote in the file.
I think I'm close to finding the solution to this problem and I'm sure the solution will turn out to be fairly simple, but I could definitely use some more help at this point.
|
|
|
11-29-2006, 10:15 AM
|
#15
|
Member
Registered: Oct 2006
Location: Utah
Posts: 520
Rep:
|
Joany,
Sorry for the delay, I think your on the right track. I think all you would have to do in /home/username/.kde/Autostart is create a symbolic link to vmware-tools. For example:
Code:
ln -s /usr/bin/vmware-tools /home/username/.kde/Autostart/vmware
This will create the symbolic link, similar to a shortcut in windows. I haven't tested this yet but I will and I'll get back to you.
|
|
|
All times are GMT -5. The time now is 07:16 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|