]> jfr.im git - vpn-prov.git/blame - init-dirs.sh
misc updates
[vpn-prov.git] / init-dirs.sh
CommitLineData
ac397a39
JR
1#!/bin/bash
2
3cd "$(dirname "$(readlink -f "$0")")"
4source ./easy-rsa/vars
5
6if [ -n "$KEY_DIR" ]; then
7 if [ -O "$KEY_DIR" ]; then
8 chmod go-rwx "$KEY_DIR"
9 if [ ! -e "$KEY_DIR/index.txt" ]; then
10 echo "Building index.txt"
11 touch "$KEY_DIR/index.txt"
12 fi
13 if [ ! -e "$KEY_DIR/index.txt.attr" ]; then
14 echo "Building index.txt.attr"
15 echo "unique_subject = no" >"$KEY_DIR/index.txt.attr"
16 fi
17 if [ ! -e "$KEY_DIR/serial" ]; then
18 echo "Building serial"
19 echo 01 >"$KEY_DIR/serial"
20 fi
21 if [ ! -e "$KEY_DIR/ca.crt" -a ! -e "$KEY_DIR/ca.key" ]; then
22 echo "Building CA"
23 ./easy-rsa/build-ca
24 fi
25 else
26 echo "The key dir '$KEY_DIR' isn't owned by the right user ($USER)"
27 fi
28else
29 echo 'Make sure you have edited easy-rsa/vars to reflect your configuration.'
30fi