summaryrefslogtreecommitdiffstats
path: root/system-autodeath.sh
diff options
context:
space:
mode:
Diffstat (limited to 'system-autodeath.sh')
-rw-r--r--system-autodeath.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/system-autodeath.sh b/system-autodeath.sh
new file mode 100644
index 0000000..4c46282
--- /dev/null
+++ b/system-autodeath.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# (c) Copyright 2008 Red Hat, Inc, Written by Seth Vidal skvidal at fedoraproject.org
+
+ipcmd="/sbin/ip"
+loggercmd="/usr/bin/logger -p syslog.alert -t autodeath"
+diecmd="$ipcmd route delete default"
+bccmd="/usr/bin/bc -l"
+DEATHDATE=2038-01-20
+conffile="/etc/sysconfig/system-autodeath.conf"
+
+
+if [ -f $conffile ]; then
+ . $conffile
+fi
+
+typeset -i todiesec=`date -d $DEATHDATE +"%s"`
+typeset -i nowsec=`date +"%s"`
+
+
+if [ $todiesec -le $nowsec ]; then
+ $loggercmd "Default route disabled by autodeath cron job. See: man system-autodeath for more information."
+ $diecmd
+else
+ typeset -i timediff=`echo $todiesec - $nowsec | $bccmd`
+ if [ $timediff -le 604800 ]; then
+ $loggercmd "Default route will be disabled by autodeath cron job on $DEATHDATE. See: man system-autodeath for more information."
+ fi
+fi
+
+