[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] [https-everywhere/master 1/2] make-trivial-rule script to help create simplest rules automatically
Author: Seth Schoen <schoen@xxxxxxx>
Date: Mon, 1 Nov 2010 00:59:57 -0700
Subject: make-trivial-rule script to help create simplest rules automatically
Commit: af5fb64737ac912eccd4f7a29c6aa1b941d08d67
---
pending-rules/make-trivial-rule | 38 ++++++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
create mode 100755 pending-rules/make-trivial-rule
diff --git a/pending-rules/make-trivial-rule b/pending-rules/make-trivial-rule
new file mode 100755
index 0000000..bce277c
--- /dev/null
+++ b/pending-rules/make-trivial-rule
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# create $1.xml, mapping $1 and www.$1 to https://www.$1
+
+if [ -z "$1" ]
+then
+ echo "syntax: $0 example.com" >&2
+ exit 1
+fi
+
+dest="$1".xml
+if [ -f "$dest" ]
+then
+ echo "error: $dest already exists." >&2
+ exit 1
+fi
+
+if echo "$1" | grep -i '^www' >/dev/null
+then
+ echo "error: omit leading www" >&2
+ exit 1
+fi
+
+if echo "$1" | grep -v '\.' >/dev/null
+then
+ echo "error: domain should probably contain a dot" >&2
+ exit 1
+fi
+
+escaped=$(echo "$1" | sed 's/\./\\./g' )
+
+cat > "$dest" <<END
+<ruleset name="$1">
+ <rule from="^http://(www\.)?$escaped/" to="https://www.$1/"/>
+</ruleset>
+END
+
+echo "$0: created $dest; please examine it." >&2
--
1.7.1