From ff931de723b2d8a74339a412838d37a587c4a04e Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Tue, 1 Sep 2009 09:54:12 +0200 Subject: [PATCH] add shell script to automatically generate a new SECRET_KEY. --- pyweb/gen_secret_key.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 pyweb/gen_secret_key.sh diff --git a/pyweb/gen_secret_key.sh b/pyweb/gen_secret_key.sh new file mode 100755 index 0000000..e90664d --- /dev/null +++ b/pyweb/gen_secret_key.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# +# Update settings.py with an automatically generated Secret Key. +# +# Copyright (C) 2009, Michael "Svedrin" Ziegler +# +# Mumble-Django 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 package 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. +# + +HASHSCRIPT=' +from hashlib import sha1; +import sys; +print sha1( sys.stdin.read() ).hexdigest();' + +KEY=` dd if=/dev/urandom bs=64 count=1 2>/dev/null | python -c "$HASHSCRIPT" ` +SECKEY="SECRET_KEY = '$KEY'" + +sed -ie "s/^SECRET_KEY.*/${SECKEY}/" settings.py