PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > linux.debian.user > Where to put a custom system cleanup script?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
linux.debian.user debian-user@lists.debian.org.

Where to put a custom system cleanup script?

Réponse
 
LinkBack Outils de la discussion
Vieux 28/01/2008, 14h30   #1
Dan H.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Where to put a custom system cleanup script?

Hello,

for a home computer that gets shutdown daily, I'd like to implement a
function which:

1. makes sure that all pending outgoing mails are sent off. The system uses
its local exim to send mail over the (slow) net, and I don't want to pull
the plug on longish emails that are being sent. Essentially the shutdown
process should stop and proceed only after exim is finished with its
business. Is running "exim -q" enough for that?

2. makes backups of all user home directories. For this I'd prefer the
system to be in single-user mode so that no files can change dureing
backup (in reality this is not so important because nobody does anything
on this machine after X has shut down.

While I know how to properly write an init script (I'm going to rely on the
Debian policy for this) I'm unsure as to the runlevel these actions should
be taken. The exim thing of course must happen before the network shuts down
and the backup should be the last thing before the disks are unmounted.

Suggestions, anyone?

--D.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHneUxGdM4FB223AcRAmIjAJ9K2J2VGB/xbpWQpqT4q36fTuibCwCfTdm7
WHfSRJxN2Kg6XVsFjalO/t0=
=cv8H
-----END PGP SIGNATURE-----

  Réponse avec citation
Vieux 28/01/2008, 15h00   #2
Dan H.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Where to put a custom system cleanup script?

On Mon, Jan 28, 2008 at 03:22:41PM +0100, Dan H. wrote:
> for a home computer that gets shutdown daily, I'd like to implement a
> function which:
>
> 1. makes sure that all pending outgoing mails are sent off.


Here's what I've come up with. Anything not to like?

#!/bin/sh

# install with this as root:
# # update-rc.d flushmail defaults 21 19
# assuming that exim has sequence number 20 on startup and shutdown.


### BEGIN INIT INFO
# Provides: flushmail
# Required-Start:
# Required-Stop: exim4 mail-transport-agent
# Should-Start:
# Default-Start:
# Default-Stop: 0 1 6
# Short-Description: Flush mail queue
### END INIT INFO

set -e

QUEUERUNNER="/usr/sbin/runq"

if [ ! -x $QUEUERUNNER ] ; then exit 1 ; fi

case "$1" in
start)
echo "Not flushing on startup"
;;

restart|stop)
echo -n "Flushing mail queue..."
$QUEUERUNNER
echo "done."
;;
esac

exit 0

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHne1ZGdM4FB223AcRArezAJ9at3+MQbIFJqenflWGyF H9X28YDgCfXl/L
F+fwf6V/6WJ5zdhNCUPgq/w=
=HqOd
-----END PGP SIGNATURE-----

  Réponse avec citation
Vieux 28/01/2008, 19h30   #3
Douglas A. Tutty
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Where to put a custom system cleanup script?

On Mon, Jan 28, 2008 at 03:57:29PM +0100, Dan H. wrote:
> On Mon, Jan 28, 2008 at 03:22:41PM +0100, Dan H. wrote:
> > for a home computer that gets shutdown daily, I'd like to implement a
> > function which:
> >
> > 1. makes sure that all pending outgoing mails are sent off.

>
> Here's what I've come up with. Anything not to like?
>
> #!/bin/sh
>
> # install with this as root:
> # # update-rc.d flushmail defaults 21 19
> # assuming that exim has sequence number 20 on startup and shutdown.
>
>
> ### BEGIN INIT INFO
> # Provides: flushmail
> # Required-Start:
> # Required-Stop: exim4 mail-transport-agent
> # Should-Start:
> # Default-Start:
> # Default-Stop: 0 1 6
> # Short-Description: Flush mail queue
> ### END INIT INFO
>
> set -e
>
> QUEUERUNNER="/usr/sbin/runq"
>
> if [ ! -x $QUEUERUNNER ] ; then exit 1 ; fi
>
> case "$1" in
> start)
> echo "Not flushing on startup"
> ;;
>
> restart|stop)
> echo -n "Flushing mail queue..."
> $QUEUERUNNER
> echo "done."
> ;;
> esac
>
> exit 0


You may want to touch /etc/nologin while this happens, then remove it at
the end of the script. It can also include the backup scripts he
wishes.

Doug.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h23.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08868 seconds with 11 queries