updated README
[threegates.git] / bin / threegates_builder.sh
1 #!/bin/bash
2 set -x
3
4 usage () {
5     echo "USAGE"
6     echo "$1 [-d|-dd] [-p <prefix>]"
7     echo "  -dd dry totally run (local and system wide)"
8     echo "  -d  dry run system-related commands"
9     echo "  -p  prefix path for the installation (default is ./out)"
10     exit $2
11 }
12
13 #
14 #  MAIN
15 #
16 GROUPNAME=threegates
17
18 DRYRUN=0
19 EXCMD_FS=""
20 EXCMD_SY=""
21 THREEGATES_BASE="./out"
22
23 while [ $# -gt 0 ]; do
24     case $1 in
25         -dd) DRYRUN=2 ;;
26         -d)  DRYRUN=1 ;;
27         -p)  THREEGATES_BASE="$2" ; shift ;;
28         *)   usage $0  ;;
29     esac
30     shift
31 done
32
33 if [ $DRYRUN -eq 2 ]; then
34     EXCMD_FS="echo "
35 fi
36 if [ $DRYRUN -ge 1 ]; then
37     EXCMD_SY="echo "
38 fi
39
40 if ! grep -q $GROUPNAME /etc/group ; then
41     $EXCMD_SY groupadd -r $GROUPNAME
42 fi
43
44 $EXCMD_FS mkdir -p        ${THREEGATES_BASE}/usr/lib/threegates/bin
45 $EXCMD_FS cp raw/root/usr/lib/threegates/bin/crl-manager.py ${THREEGATES_BASE}/usr/lib/threegates/bin
46 $EXCMD_SY chown root.root ${THREEGATES_BASE}/usr/lib/threegates/bin/crl-manager.py
47 $EXCMD_FS chmod 744       ${THREEGATES_BASE}/usr/lib/threegates/bin/crl-manager.py
48
49
50 $EXCMD_FS mkdir -p  ${THREEGATES_BASE}/var/lib/threegates
51 $EXCMD_FS chmod 755 ${THREEGATES_BASE}/var/lib/threegates
52
53 $EXCMD_FS mkdir -p  ${THREEGATES_BASE}/var/lib/threegates/ca
54 $EXCMD_FS chmod 755 ${THREEGATES_BASE}/var/lib/threegates/ca
55
56 $EXCMD_FS mkdir -p  ${THREEGATES_BASE}/var/lib/threegates/crl
57 $EXCMD_FS chmod 755 ${THREEGATES_BASE}/var/lib/threegates/crl
58
59 $EXCMD_FS mkdir -p  ${THREEGATES_BASE}/var/lib/threegates/crluri
60 $EXCMD_FS chmod 755 ${THREEGATES_BASE}/var/lib/threegates/crluri
61
62 $EXCMD_FS mkdir -p  ${THREEGATES_BASE}/var/lib/threegates/crlurinew
63 $EXCMD_FS chmod 775 ${THREEGATES_BASE}/var/lib/threegates/crlurinew
64 $EXCMD_FS chmod g+s ${THREEGATES_BASE}/var/lib/threegates/crlurinew
65 $EXCMD_SY chgrp $GROUPNAME ${THREEGATES_BASE}/var/lib/threegates/crlurinew
66
67 export THREEGATES_CA_BASE="${THREEGATES_BASE}/var/lib/threegates/ca"
68 $EXCMD_FS ./bin/certs_extractor.sh
69
70 exit 0