summaryrefslogtreecommitdiff
path: root/support/dktools/rshdown-init
blob: 50d2e4c8b27e04ff7d898e6461e8306dd9eadb79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#! /bin/sh

# This script generates a secret (pre-shared key) file.
# Use a secure mechanism to transfer the secret file between
# sender and recipient.
# Only root should have permissions on the file, no other users.

if [ ! -f "/usr/local/etc/rshdown/secret" ]
then
	LENGTH=`/usr/local/bin/dk-pwgen -p -l 2`
	LENGTH=`expr 1460 - $LENGTH`
	touch "/usr/local/etc/rshdown/secret"
	chmod 600 "/usr/local/etc/rshdown/secret"
	/usr/local/bin/dk-rand -b $LENGTH > "/usr/local/etc/rshdown/secret"
	chmod 600 "/usr/local/etc/rshdown/secret"
fi