summaryrefslogtreecommitdiffstats
path: root/configure
blob: 0c9f327361e057404dc8a7a6b8376cca5809a2bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/sh

usage() {
    cat <<EOF
configure help for eurephia

          --help               | -h        -- This help screen
          --prefix <path>      | -p <path> -- Root directory of installation
                                              (default: /etc/openvpn/eurephia)
          --openvpn-src <path> | -s <path> -- OpenVPN source directory (needed for building)
          --debug              | -D        -- Enable verbose debug logging
          --show-secrets       | -S        -- Log passwords as clear text in log files
                               |              (only available when debug is enabled)
          --fw-iptables        |           -- Build iptables firewall module
          --db-sqlite3         |           -- Build SQLite3 database module
          --sqlite3-prefix     | -sp       -- Root directory of SQLite3 eurephia database
                                              (default: /etc/openvpn)
EOF
}

PARAMS=""
DB=""
FW=""
OPENVPN_SRC_DIR=""
PREFIX="/etc/openvpn/eurephia"
SQLITE3PREFIX="/etc/openvpn"
while [ ! -z "$1" ]; do
      case $1 in 
          -h|--help)
              usage
              exit 0
              ;;
          -p|--prefix)
              PREFIX="$2";
              shift;
              ;;
          -s|--openvpn-src)
              OPENVPN_SRC_DIR="$2"
              PARAMS="${PARAMS} -DOPENVPN_SRC:STRING=$2"
              shift
              ;;
          -D|--debug)
              PARAMS="${PARAMS} -DDEBUG=ON"
              DEBUG_WARN=1
              ;;
          -S|--show-secrets)
              PARAMS="${PARAMS} -DSHOW_SECRETS=ON"
              SECRETS_WARN=1
              ;;
          --fw-iptables)
              PARAMS="${PARAMS} -DFW_IPTABLES=ON"
              FW="iptables "
              ;;
          --db-sqlite3)
              PARAMS="${PARAMS} -DSQLITE3=ON"
              DB="SQLite3 "
              ;;
          --sp|--sqlite3-prefix)
              SQLITE3PREFIX="$2"
              shift
              ;;
          *)
              echo "Unkown option: $1"
              exit 2
              ;;
      esac
      shift
done

if [ -z "$(which cmake)" ]; then
    echo "To build eurephia, you need to install cmake (at least version 2.6)"
    exit 1;
fi

if [ -z "${OPENVPN_SRC_DIR}" ]; then
    echo "You need to give the --openvpn-src <path> option"
    exit 1;
fi

if [ -z "${DB}" ]; then
    echo "You need to activate at least one database driver"
    exit 1;
fi

if [ ${DB} = "SQLite3" ]; then
    PARAMS="${PARAMS} -DSQLITE3PREFIX:STIRNG=${SQLITE3PREFIX}"
fi

rm -f CMakeCache.txt
cmake . ${PARAMS} -DPREFIX:STRING=${PREFIX}
ec=$?
if [ $ec = 0 ]; then
    cat >> Makefile <<EOF
dist-clean : clean
	find -type d -name "CMakeFiles" | xargs rm -rf
	find -type f -name "cmake_install.cmake" | xargs rm -rf
	find -type f -name CMakeCache.txt | xargs rm -rf
	find -type f -name install_manifest.txt | xargs rm -rf
	find -type f -name Makefile | xargs rm -rf 
	find -type f -name "*~" | xargs rm -f
	rm -f CMakeCache.txt 

EOF

    echo
    echo
    echo "eurephia will be built with support for: "
    echo
    echo "               Database: ${DB}"
    echo "               Firewall: ${FW:-"None"}"
    echo
    echo "         Install prefix: ${PREFIX}"
    if [ ${DB} = "SQLite3" ]; then
        echo "  SQLite3 database path: ${SQLITE3PREFIX}"
    fi
    echo
    echo
    if [ "$DEBUG_WARN" = 1 ]; then
        echo
        echo "     *******   DEBUG is enabled.  This might be a security issue   *******"
        echo
        if [ "$SECRETS_WARN" = 1 ]; then
            echo
            echo "     *******   SHOW_SECRETS is enabled.  THIS WILL LOG PASSWORDS IN CLEAR TEXT IN LOG FILES   *******"
            echo
        fi
    fi
fi
exit $?