commit ddbf1d2555beb8ef1435b23b5e19733c16cbe5ca Author: Gregory Colpart Date: Sun Sep 13 15:29:22 2015 +0200 init diff --git a/README b/README new file mode 100644 index 0000000..d61af76 --- /dev/null +++ b/README @@ -0,0 +1,7 @@ +script for Evolix maintenance +============================= + +script evomaintenance.sh which sends a mail +for each intervention on a Pack Evolix server. + +* Pb quand '&' dans le msg d'evomaintenance... diff --git a/changelog b/changelog new file mode 100644 index 0000000..4d33cbc --- /dev/null +++ b/changelog @@ -0,0 +1,5 @@ +0.2.7 : Correction d'un bug lors de l'utilisation de '&' dans le texte +0.2.6 : Precision du charset dans les entetes du mail +0.2.5 : Correction d'un bug avec le path de sendmail sous OpenBSD +0.2.4 : Correction d'un bug lors de l'utilisation de '/' dans le texte +0.2.3 : Correction d'un bug avec $REALM diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..0536d34 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,47 @@ +evomaintenance (0.2.7-1) UNRELEASED; urgency=low + + * New upstream release. + * This version fixes bug when text contains a character '&'. + + -- Gregory Colpart Thu, 11 Mar 2010 16:14:19 +0100 + +evomaintenance (0.2.6-1) UNRELEASED; urgency=low + + * New upstream release. + * This version fixes the bug for charset in mail. + * Add Build-Depends on debhelper. + + -- Gregory Colpart Mon, 01 Jun 2009 15:57:32 +0200 + +evomaintenance (0.2.4-1) UNRELEASED; urgency=low + + * New upstream release. + * This version fixes annoying bug when text contains a character '/'. + + -- Gregory Colpart Wed, 26 Nov 2008 01:03:26 +0100 + +evomaintenance (0.2.3-1) UNRELEASED; urgency=low + + * New upstream release. + * This version corrects a bug with $REALM var. + + -- Gregory Colpart Mon, 10 Nov 2008 01:37:06 +0100 + +evomaintenance (0.2.2-1) UNRELEASED; urgency=low + + * New upstream release. + * Fix debian/rules to have correct permissions. + + -- Gregory Colpart Mon, 10 Nov 2008 00:09:39 +0100 + +evomaintenance (0.2.1-1) UNRELEASED; urgency=low + + * New upstream release. + + -- Gregory Colpart Sun, 9 Nov 2008 22:37:20 +0100 + +evomaintenance (0.2-1) UNRELEASED; urgency=low + + * Initial release. + + -- Gregory Colpart Sun, 9 Nov 2008 19:53:16 +0100 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..e812ff9 --- /dev/null +++ b/debian/control @@ -0,0 +1,14 @@ +Source: evomaintenance +Section: misc +Priority: optional +Maintainer: Gregory Colpart +Build-Depends: debhelper (>= 5) +Standards-Version: 3.8.0 + +Package: evomaintenance +Architecture: all +Depends: postgresql-client, sudo +Description: script for Evolix maintenance + This package contains the script evomaintenance.sh + which sends a mail for each intervention on a Pack Evolix server. + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..ed0c87d --- /dev/null +++ b/debian/copyright @@ -0,0 +1 @@ +It's a "private" package, then no real copyright for now... diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..8cf209e --- /dev/null +++ b/debian/rules @@ -0,0 +1,45 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +build: build-stamp +build-stamp: + dh_testdir + touch $@ +clean: + dh_testdir + dh_testroot + rm -f build-stamp + dh_clean +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + install -m 700 -d $(CURDIR)/debian/evomaintenance/usr/share/scripts + install -m 700 evomaintenance.sh $(CURDIR)/debian/evomaintenance/usr/share/scripts/ + install -m 600 evomaintenance.tpl $(CURDIR)/debian/evomaintenance/usr/share/scripts/ + install -m 755 -d $(CURDIR)/debian/evomaintenance/etc + install -m 600 evomaintenance.cf $(CURDIR)/debian/evomaintenance/etc/ +# Build architecture-independent files here. +binary-arch: build install +# We have nothing to do by default. +# Build architecture-dependent files here. +binary-indep: build install + dh_testdir + dh_testroot + dh_installchangelogs changelog + dh_compress + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/evomaintenance.cf b/evomaintenance.cf new file mode 100644 index 0000000..f388238 --- /dev/null +++ b/evomaintenance.cf @@ -0,0 +1,15 @@ +# Configuration for evomaintenance + +#HOSTNAME=your-host +#EVOMAINTMAIL=evomaintenance-your-host@example.com + +export PGPASSWORD=your-passwd + +PGDB=your-db +PGTABLE=your-table +PGHOST=your-pg-host +FROM=jdoe@example.com +FULLFROM="John Doe " +URGENCYFROM=mama.doe@example.com +URGENCYTEL="06.00.00.00.00" +REALM=example.com diff --git a/evomaintenance.sh b/evomaintenance.sh new file mode 100644 index 0000000..0c27bff --- /dev/null +++ b/evomaintenance.sh @@ -0,0 +1,55 @@ +#!/bin/sh + +# EvoMaintenance script +# install packages postgresql-client and sudo (Debian) +# or port postgresql-client (*BSD) + +# version 0.2 +# Copyright 2007-2008 Gregory Colpart , Evolix + +test -f /etc/evomaintenance.cf && . /etc/evomaintenance.cf + +[ $HOSTNAME ] || HOSTNAME=`hostname` +[ $EVOMAINTMAIL ] || EVOMAINTMAIL=evomaintenance-$(echo $HOSTNAME | cut -d- -f1)@$REALM + +# get ipaddress +IP=`LC_ALL=C who -m | grep $SUDO_USER | head -1 | tr -s ' ' | cut -d" " -f6 | sed -e "s/^(// ; s/)$//"` + +# get begin_date +BEGIN_YEAR=`date "+%Y"` +BEGIN_DATE=`LC_ALL=C who -m | grep $SUDO_USER | head -1 | tr -s ' ' | cut -d" " -f3,4,5` + +# end_date +#now() + +# details +echo "Please, enter details about your maintenance" +read TEXTE + +if [ "$TEXTE" = "" ]; then + echo "no value..." + exit 1 +fi + +# SQL +TEXTE=`echo "$TEXTE" | sed "s/'/\\\\\\'/g ; s@/@\\\\\/@g ; s@\\&@et@g"` + +# recapitulatif +echo "hostname = $HOSTNAME" +echo "user = $SUDO_USER" +echo "IP = $IP" +echo "begin date = $BEGIN_YEAR $BEGIN_DATE" +echo "details = $TEXTE" + +echo "To cancel, [Ctrl+C] else press [Enter]" +read enter + +echo " +INSERT INTO evomaint(hostname,userid,ipaddress,begin_date,end_date,details) +VALUES ('$HOSTNAME','$SUDO_USER','$IP','$BEGIN_YEAR $BEGIN_DATE',now(),'$TEXTE') " | \ +psql $PGDB $PGTABLE -h $PGHOST + +cat /usr/share/scripts/evomaintenance.tpl | \ + sed -e "s/__TO__/$EVOMAINTMAIL/ ; s/__HOSTNAME__/$HOSTNAME/ ; s/__USER__/$SUDO_USER/ ; s/__BEGIN_DATE__/$BEGIN_YEAR $BEGIN_DATE/ ; s/__TEXTE__/$TEXTE/ ; s/__IP__/$IP/ ; s/__FULLFROM__/$FULLFROM/ ; s/__FROM__/$FROM/ ; s/__URGENCYFROM__/$URGENCYFROM/ ; s/__URGENCYTEL__/$URGENCYTEL/"| \ + sendmail -oi -t -f $FROM + diff --git a/evomaintenance.tpl b/evomaintenance.tpl new file mode 100644 index 0000000..952a7fc --- /dev/null +++ b/evomaintenance.tpl @@ -0,0 +1,27 @@ +From: __FULLFROM__ +Content-Type: text/plain; charset=UTF-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +To: __TO__ +Subject: [evomaintenance] Intervention sur __HOSTNAME__ (__USER__) + +Bonjour, + +Une intervention vient de se terminer sur votre serveur. +Voici les renseignements sur l'intervention : + +Nom du serveur : __HOSTNAME__ +Personne ayant réalisée l'intervention : __USER__ +Intervention réalisée depuis : __IP__ +Date/heure du début de l'intervention : __BEGIN_DATE__ +Renseignements sur l'intervention : +__TEXTE__ + +Pour réagir à cette intervention, vous pouvez répondre à ce message +(sur l'adresse mail __FROM__). En cas d'urgence, utilisez +l'adresse __URGENCYFROM__ ou notre téléphone portable d'astreinte +(__URGENCYTEL__) + +Cordialement, +-- +__FULLFROM__