summaryrefslogtreecommitdiffstats
path: root/package/strongswan/patches/200-wakeup-showstatus.patch
blob: 731f83c2e0ac4f0dd31aa5b84bc46176d53f473b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
Index: strongswan-2.8.2/programs/Makefile
===================================================================
--- strongswan-2.8.2.orig/programs/Makefile	2007-06-04 13:23:04.661025312 +0200
+++ strongswan-2.8.2/programs/Makefile	2007-06-04 13:23:06.414758704 +0200
@@ -22,7 +22,7 @@
 SUBDIRS+=_realsetup _secretcensor _startklips _updown _updown_espmark
 SUBDIRS+=auto barf ipsec look manual ranbits secrets starter
 SUBDIRS+=rsasigkey send-pr setup showdefaults showhostkey calcgoo mailkey
-SUBDIRS+=ikeping examples openac scepclient
+SUBDIRS+=ikeping examples openac scepclient _showstatus wakeup
 
 ifeq ($(USE_LWRES),true)
 SUBDIRS+=lwdnsq
Index: strongswan-2.8.2/programs/_showstatus/Makefile
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ strongswan-2.8.2/programs/_showstatus/Makefile	2007-06-04 13:23:06.414758704 +0200
@@ -0,0 +1,22 @@
+# Makefile for miscelaneous programs
+# Copyright (C) 2002  Michael Richardson	<mcr@freeswan.org>
+# 
+# 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.  See <http://www.fsf.org/copyleft/gpl.txt>.
+# 
+# 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 General Public License
+# for more details.
+#
+# RCSID $Id: Makefile,v 1.3 2006/04/17 06:48:49 as Exp $
+
+FREESWANSRCDIR=../..
+include ${FREESWANSRCDIR}/Makefile.inc
+
+PROGRAM=_showstatus
+PROGRAMDIR=${LIBDIR}
+
+include ../Makefile.program
Index: strongswan-2.8.2/programs/_showstatus/_showstatus.8
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ strongswan-2.8.2/programs/_showstatus/_showstatus.8	2007-06-04 13:23:06.414758704 +0200
@@ -0,0 +1,23 @@
+.TH _showstatus 8 "03 Feb 2007"
+.\"
+.\" RCSID $Id: _showstatus.8
+.\"
+.SH NAME
+ipsec _showstatus \- give state feedback via led or other method
+.SH SYNOPSIS
+.I _showstatus
+is invoked by _updown to trigger led's, or other distribution
+or platform specific behavior. Presently, the SES button is
+supported as a status light on OpenWRT platforms. The button
+is configurable by environment variable:
+-B IPSEC_STATUS_LED_START
+defaults to ses_orange, and
+-B IPSEC_STATUS_LED_VALID
+defaults to ses_white.
+.SH "SEE ALSO"
+ipsec(8), ipsec_updown(8).
+.SH HISTORY
+Man page written for the Linux strongSwan project <http://www.strongswan.org/>
+by Kevin Cody Jr. Original manpage for _updown by Michael Richardson.
+Original program written by Henry Spencer. Extended for the Linux strongSwan
+project <http://www.strongswan.org/> by Andreas Steffen.
Index: strongswan-2.8.2/programs/_showstatus/_showstatus.in
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ strongswan-2.8.2/programs/_showstatus/_showstatus.in	2007-06-04 13:23:06.414758704 +0200
@@ -0,0 +1,70 @@
+#! /bin/sh
+#
+# Copyright (C) 2007 Kevin Cody Jr. <kcody@vegaresearch.com>
+# 
+# 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.  See <http://www.fsf.org/copyleft/gpl.txt>.
+# 
+# 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 General Public License
+# for more details.
+#
+# RCSID $Id: _showstatus.in
+
+
+LED_START=$IPSEC_STATUS_LED_START
+LED_VALID=$IPSEC_STATUS_LED_VALID
+
+[ -z "$LED_START" ] && LED_START="ses_orange"
+[ -z "$LED_VALID" ] && LED_VALID="ses_white"
+
+
+setled() {
+	led=$1
+	st=$2
+
+	[ -n "$led" -a -n "$st" ] || return
+	
+	if [ -w "/proc/diag/led/$led" ] ; then
+		echo "$st" > "/proc/diag/led/$led"
+	fi
+
+	# integrate other led control methods here
+
+}
+
+
+case "$1" in
+	'start')
+		[ -n "$LED_VALID" ] && setled "$LED_START" 1
+		[ -z "$LED_VALID" ] && setled "$LED_START" f
+		setled "$LED_VALID" 0
+		;;
+	'stop')
+		setled "$LED_START" 0
+		setled "$LED_VALID" 0
+		;;
+	'valid')
+		setled "$LED_VALID" 1
+		;;
+	'invalid')
+		setled "$LED_VALID" 0
+		;;
+	'up')
+		[ -n "$LED_VALID" ] && setled "$LED_START" 0
+		[ -z "$LED_VALID" ] && setled "$LED_START" 1
+		setled "$LED_VALID" 1
+		;;
+	'down')
+		[ -n "$LED_VALID" ] && setled "$LED_START" 1
+		[ -z "$LED_VALID" ] && setled "$LED_START" f
+		setled "$LED_VALID" f
+		;;
+	*)
+		echo "$0: unknown status $status" >&2
+		;;
+esac
+
Index: strongswan-2.8.2/programs/wakeup/Makefile
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ strongswan-2.8.2/programs/wakeup/Makefile	2007-06-04 13:23:06.415758552 +0200
@@ -0,0 +1,22 @@
+# Makefile for miscelaneous programs
+# Copyright (C) 2002  Michael Richardson	<mcr@freeswan.org>
+# 
+# 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.  See <http://www.fsf.org/copyleft/gpl.txt>.
+# 
+# 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 General Public License
+# for more details.
+#
+# RCSID $Id: Makefile,v 1.3 2006/04/17 06:48:49 as Exp $
+
+FREESWANSRCDIR=../..
+include ${FREESWANSRCDIR}/Makefile.inc
+
+PROGRAM=wakeup
+PROGRAMDIR=${LIBDIR}
+
+include ../Makefile.program
Index: strongswan-2.8.2/programs/wakeup/wakeup.8
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ strongswan-2.8.2/programs/wakeup/wakeup.8	2007-06-04 13:23:06.415758552 +0200
@@ -0,0 +1,16 @@
+.TH wakeup 8 "03 Feb 2007"
+.\"
+.\" RCSID $Id: wakeup.8
+.\"
+.SH NAME
+ipsec wakeup \- stalled and down connection detection
+.SH SYNOPSIS
+.I wakeup
+is invoked by cron and checks ipsec status, whacking as necessary.
+.SH "SEE ALSO"
+ipsec(8), ipsec_whack(8).
+.SH HISTORY
+Man page written for the Linux strongSwan project <http://www.strongswan.org/>
+by Kevin Cody Jr. Original manpage for _updown by Michael Richardson.
+Original program written by Henry Spencer. Extended for the Linux strongSwan
+project <http://www.strongswan.org/> by Andreas Steffen.
Index: strongswan-2.8.2/programs/wakeup/wakeup.in
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ strongswan-2.8.2/programs/wakeup/wakeup.in	2007-06-04 13:23:06.415758552 +0200
@@ -0,0 +1,38 @@
+#! /bin/sh
+# wakeup script
+#
+# Copyright (C) 2007 Kevin Cody Jr. <kcody@vegaresearch.com>
+# 
+# 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.  See <http://www.fsf.org/copyleft/gpl.txt>.
+# 
+# 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 General Public License
+# for more details.
+#
+
+# only applicable when ipsec is running
+[ -e /var/run/pluto.pid ] || exit
+
+# loop through any erouted tunnels in the HOLD state
+for f in  `ipsec status | awk '/erouted HOLD/{ print $2 }' | cut -f1 -d\: | cut -f2 -d\"` ; do
+
+        # only whack if no pending events at all exists
+        ipsec status | grep STATE | grep -q $f ||
+                ipsec whack --name $f --initiate --asynchronous
+
+done
+
+# loop through any tunnels that don't quite exist
+for f in `ipsec status | awk '/prospective erouted/{ print $2 }' | cut -f1 -d: | grep -v \# | cut -f2 -d\"` ; do
+
+        ipsec status | grep STATE_QUICK | grep -q $f || {
+                ipsec status | grep STATE_MAIN | grep -q $f && ipsec down $f
+                ipsec up $f
+        }
+
+done
+