|
Home > Archive > Red Hat General > April 2004 > Scripts
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| Newbie: How do I create logon scripts, and/or scripts that run whne the
system boots? I want to mount an smb network path to a directory and start
a couple of applications.
Thanks in advance,
....kurt
| |
|
| Kurt wrote:
> Newbie: How do I create logon scripts, and/or scripts that run whne the
> system boots? I want to mount an smb network path to a directory and start
> a couple of applications.
First thing to do: search the web to see if anyone's already done the same
thing. It cuts down on the workload.
If you want to write a script, you just make up a file with the commands in
it that you want to run, and put
#!/bin/sh
at the beginning.
Save it, chmod +x it, copy it to /etc/init.d, then put a link to it in the
relevant rc directory, /etc/rc3.d for instance. That link has to be named
S<number><name> or K<number><name> in order for it to be picked up as part
of the startup/shutdown sequence - S for start, K for kill.
In order for it to have any relevance to starting a process or killing a
process, you'll have to put in some conditionals and logic in the script,
getting on to things like case, if, elif and so on. They should all be in
the man pages.
But first, just do the basic script and run it from the command line.
Putting in logic won't do any good if it doesn't do what you wanted it to
do in the first place.
Pip
| |
| Alexander Dalloz 2004-04-12, 11:44 am |
| On Sun, 11 Apr 2004 22:18:58 -0700 Kurt wrote:
> Newbie: How do I create logon scripts, and/or scripts that run whne the
> system boots? I want to mount an smb network path to a directory and start
> a couple of applications.
>
> Thanks in advance,
>
> ...kurt
Read /usr/share/doc/initscripts-$version/sysvinitfiles and the manpages
for chkconfig and service.
Alexander
--
Alexander Dalloz | Enger, Germany
PGP key valid: made 13.07.1999
PGP fingerprint: 2307 88FD 2D41 038E 7416 14CD E197 6E88 ED69 5653
| |
|
| Pip wrote:
> Kurt wrote:
>
>
> First thing to do: search the web to see if anyone's already done the same
> thing. It cuts down on the workload.
> If you want to write a script, you just make up a file with the commands
> in it that you want to run, and put
>
> #!/bin/sh
>
> at the beginning.
> Save it, chmod +x it, copy it to /etc/init.d, then put a link to it in the
> relevant rc directory, /etc/rc3.d for instance. That link has to be named
> S<number><name> or K<number><name> in order for it to be picked up as part
> of the startup/shutdown sequence - S for start, K for kill.
> In order for it to have any relevance to starting a process or killing a
> process, you'll have to put in some conditionals and logic in the script,
> getting on to things like case, if, elif and so on. They should all be in
> the man pages.
> But first, just do the basic script and run it from the command line.
> Putting in logic won't do any good if it doesn't do what you wanted it to
> do in the first place.
>
>
> Pip
Thanks, I've actually done quite a bit of scripting, java, etc. just
couldn't figure out how to assign scripts to user logons, system startups,
shutdowns, etc. I'll take what both replys have given and give it a go.
Thanks,
....kurt
| |
|
| OK, this is great. I get from exploring those directories that /etc/init.d
contains daemons that start when the system is initialized? And from your
post that I also need to add a reference to it in one of the rc?.d
directories? I see they all start with S or K + a number (all less than 100
as far as I can tell), then the name of a file in init.d. So, what is the
significance of the ? in rc?.d And how about the number in the file
within rc?.d (i.e. S35somefile)? What is the 35, and how do I know which
directory is appropriate and what number to put behind the S or K?
Thanks again,
...kurt
| |
| Kevin D. Snodgrass 2004-04-14, 2:39 pm |
| Kurt wrote:
> OK, this is great. I get from exploring those directories that /etc/init.d
> contains daemons that start when the system is initialized? And from your
> post that I also need to add a reference to it in one of the rc?.d
> directories? I see they all start with S or K + a number (all less than 100
'S' for start, 'K' for kill. When you boot your computer it
will execute the 'S' scripts to start each "service". When
you shutdown it runs the 'K' scripts to kill each "service".
> as far as I can tell), then the name of a file in init.d. So, what is the
> significance of the ? in rc?.d And how about the number in the file
Run level. Try:
$ man init
for more info...
> within rc?.d (i.e. S35somefile)? What is the 35, and how do I know which
> directory is appropriate and what number to put behind the S or K?
The number is for sequencing. *Something* has to specify
the order that these scripts are executed, since some will
depend on the services of others.
There are 'K' scripts in all (I think) rc?.d directories to
make sure that services that aren't supposed to be running
at that runlevel are shutdown. (You can also issue the command:
$ init 3
to change to runlevel 3 from any other runlevel)
For the most part all of this is handled by either GUI or
CLI tools, like chkconfig. Be careful playing around with
this stuff on your own. The tools exist for a reason.
| |
|
| Kevin D. Snodgrass wrote:
> Kurt wrote:
>
> 'S' for start, 'K' for kill. When you boot your computer it
> will execute the 'S' scripts to start each "service". When
> you shutdown it runs the 'K' scripts to kill each "service".
>
>
> Run level. Try:
>
> $ man init
>
> for more info...
>
>
> The number is for sequencing. *Something* has to specify
> the order that these scripts are executed, since some will
> depend on the services of others.
>
> There are 'K' scripts in all (I think) rc?.d directories to
> make sure that services that aren't supposed to be running
> at that runlevel are shutdown. (You can also issue the command:
>
> $ init 3
>
> to change to runlevel 3 from any other runlevel)
>
>
> For the most part all of this is handled by either GUI or
> CLI tools, like chkconfig. Be careful playing around with
> this stuff on your own. The tools exist for a reason.
Thanks again, I'll look into those commands for runlevel and sequencing. I
appreciate you taking the time to explain, I'm kinda shotgunning all of
this (but having a real good time doing it).
....kurt
|
|
|
|
|