We just changed the way our login banners are supposed to occur.
Before, they appeared prior to login, so I could just use the
sshd_config file and specify an banner in the file. Now, I need
to present the banner after login. In order to do this, I need to
restart sshd. But, I don't want to restart sshd during the
middle of the day or when the sshd_config file hasn't changed.
Paul
How are you updating sshd_config? If it is via a cfengine copy action,
you can define a class in that statement and then make your processes or
shellcommands action conditional upon that class. If you are updating
the file with a system that is not under cfengine control, you can
maintain a datestamp file separate from the sshd_config file, and
restart sshd (along with updating the datestamp file) if the last
modified time of the sshd_config file is more recent than the last
modified time of the datestamp file. If you choose that strategy, you
will probably want to use the IsNewerThan evaluated class. You can
find details on that at:
http://www.cfengine.org/docs/cfengine-Reference.html#Evaluated-classes-and-special-functions
Let me know if you want some example cfengine code for this.
Best,
Brendan
--
Senior System Administrator
The University of Chicago
Department of Computer Science
http://www.cs.uchicago.edu/people/brendan
http://praksys.blogspot.com/
Use a copy command that copies this specific file, and then use define
to add the box to a "restart_ssh" class, that you use later with in a
shellcommand.
From the manual:
define
This option is followed by a list of classes which are to be
`switched on' if and only if the named file was copied. In multiple
(recursive) copy operations the classes become defined if any of the
files in the file tree were copied. This feature is useful for switching
on other actions which are to be performed after the installation of key
files (e.g. package installation scripts etc).
Regards,
Marco
PAUL WILLIAMSON wrote:
> How can I tell a process to restart only if a certain file has changed?
>
> We just changed the way our login banners are supposed to occur.
> Before, they appeared prior to login, so I could just use the
> sshd_config file and specify an banner in the file. Now, I need
> to present the banner after login. In order to do this, I need to
> restart sshd. But, I don't want to restart sshd during the
> middle of the day or when the sshd_config file hasn't changed.
>
> Paul
>
>
>
> _______________________________________________
> Help-cfengine mailing list
> Help-c...@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-cfengine
>
What I did was to use DefineClasses in the editfiles section. this sets
the class only if the file is edited..
eg..
linux::
{ /etc/ssh/sshd_config
ReplaceAll "#Banner /some/path" With "Banner
/etc/issue"
DefineClasses "HUPsshd"
}
shellcommands:
linux.HUPsshd::
"/sbin/service sshd restart" useshell=false
this would only run the shellcommands if the class is defined, and that
only happens if the file is edited. you could then add the
time.class.hup doo-hickie and all should be well..
hth.
-luis
PAUL WILLIAMSON wrote:
>How can I tell a process to restart only if a certain file has changed?
>
>We just changed the way our login banners are supposed to occur.
>Before, they appeared prior to login, so I could just use the
>sshd_config file and specify an banner in the file. Now, I need
>to present the banner after login. In order to do this, I need to
>restart sshd. But, I don't want to restart sshd during the
>middle of the day or when the sshd_config file hasn't changed.
>
>Paul
>
>
>
>_______________________________________________
>Help-cfengine mailing list
>Help-c...@gnu.org
>http://lists.gnu.org/mailman/listinfo/help-cfengine
>
>
--
Luis E. Cerezo
copy:
any::
/some/file
dest=/other/file
define=restart_sshd
processes:
restart_sshd::
"sshd" signal=kill restart "/etc/init.d/sshd start"
!restart_sshd::
"sshd" restart "/etc/init.d/sshd start"
Or something along those lines.
-Jason Martin
--
"Apple" (c) 6024 b.c., Adam & Eve
This message is PGP/MIME signed.
How can I tell a process to restart only if a certain file has changed?
We just changed the way our login banners are supposed to occur.
Before, they appeared prior to login, so I could just use the
sshd_config file and specify an banner in the file. Now, I need
to present the banner after login. In order to do this, I need to
restart sshd. But, I don't want to restart sshd during the
middle of the day or when the sshd_config file hasn't changed.
Paul
_______________________________________________
Help-cfengine mailing list
Help-c...@gnu.org
http://lists.gnu.org/mailman/listinfo/help-cfengine
shellcommands:
newsshd::
"${restart_scripts}/sshd restart"
--
On 1/26/06, PAUL WILLIAMSON <pwill...@mandtbank.com> wrote:
> How can I tell a process to restart only if a certain file has changed?
>
> We just changed the way our login banners are supposed to occur.
> Before, they appeared prior to login, so I could just use the
> sshd_config file and specify an banner in the file. Now, I need
> to present the banner after login. In order to do this, I need to
> restart sshd. But, I don't want to restart sshd during the
> middle of the day or when the sshd_config file hasn't changed.
>
> Paul
>
>
>
> _______________________________________________
> Help-cfengine mailing list
> Help-c...@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-cfengine
>
--
--
Perfection is just a word I use occasionally with mustard.
--Atom Powers--
Here's arough sketch:
classes:
restart = ( IsNewerThan() )
or
files:
/file checksum=md5 define=xxx
processes:
restart||xxx::
"process" signal=term restart "/...."
This method is fairly universal. I have been in Sun environments that
didn't have a great set of standards for the /etc/init.d/ restart
script. Since packagers like SMC didn't provide them. Or maybe they
installed by source.
As far as the timing, I would just use a class of when you want it
check like Hr01 before the statement that is going to do the file
alternation. Whether it is a copy, editfiles, or shellcommand. Then
use define=sshd_config_modified to trigger the restart.
Christian
On 1/26/06, PAUL WILLIAMSON <pwill...@mandtbank.com> wrote:
> How can I tell a process to restart only if a certain file has changed?
>
> We just changed the way our login banners are supposed to occur.
> Before, they appeared prior to login, so I could just use the
> sshd_config file and specify an banner in the file. Now, I need
> to present the banner after login. In order to do this, I need to
> restart sshd. But, I don't want to restart sshd during the
> middle of the day or when the sshd_config file hasn't changed.
>
> Paul
>
>
>
> _______________________________________________
> Help-cfengine mailing list
> Help-c...@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-cfengine
>
--
Christian Pearce