Web inteface: nicer system error page, and introduced a bug (OK, a photo of a bug :-)
[openxpki.git] / trunk / deployment / configure
blob0175232390ca2c73f166037cfe53cae550f42508
1 #!/usr/bin/env bash
3 # OpenXPKI Configuration Script
5 # Written by Martin Bartosch for the OpenXPKI project 2006
6 # Copyright (c) 2006 by The OpenXPKI Project
9 CFG="bin/openxpki-metaconf"
11 CONFDIR="etc"
12 TEMPLATEDIR="$CONFDIR/templates"
13 TEMPLATE="default"
15 PREFIX="/usr"
16 DIST_ONLY=0
18 usage() {
19 cat <<EOF
20 Usage: configure [OPTIONS]
22 Prepare OpenXPKI for installation.
24 Options:
25 --help display this help text and exit
26 --prefix set installation prefix (Default: $PREFIX)
27 --distonly Use before 'make dist'. Creates specially reduced Makefile.
28 -- all options following -- are passed to openxpki-metaconf
30 This script prepares the OpenXPKI deployment environment for installation
31 on your system.
33 Example 1 - regular install from distribution:
35 ./configure --prefix /usr/local
36 (g)make
37 (g)make install
39 Example 2 - prepare distribution tarball:
40 ./configure --distonly
41 (g)make dist
43 EOF
47 METACONF_OPTS=""
49 # check infrastructure
50 ERRORS=0
51 # TODO: we should check non-standard modules used in the openxpki[adm|ctl]
52 # as well
53 echo "Checking required OpenXPKI Perl modules..."
54 for module in OpenXPKI OpenXPKI::Client ; do
55 echo -n "$module: "
56 if perl -e "use $module;" >/dev/null 2>&1 ; then
57 echo "OK"
58 else
59 echo "NOT FOUND"
60 ERRORS=1
62 done
64 if [ "$ERRORS" != "0" ] ; then
65 echo "Pre-installation check found errors."
66 echo "Please install the missing Perl modules before proceeding."
67 exit 1
70 UNAME=`uname`
72 if [ "$UNAME" == "SunOS" ]; then
73 # Solaris does not support id -nu/-ng, extract usernames manually
74 USER=`id|perl -n -e 's/.*uid=[0-9]+\(([a-z0-9]+)\).*/$1/; print $_'`;
75 GROUP=`id|perl -n -e 's/.*gid=[0-9]+\(([a-z0-9]+)\).*/$1/; print $_'`;
76 else
77 # we are on a "sane" system :-)
78 USER=`id -nu`
79 GROUP=`id -ng`
82 ADMUSER="$USER"
83 ADMGROUP="$GROUP"
84 if [ "$USER" != "root" ] ; then
85 echo "Preparing for non-root installation (user: $USER, group: $GROUP)"
86 RUNUSER="$USER"
87 RUNGROUP="$GROUP"
91 [ -n "$RUNUSER" ] && METACONF_OPTS="$METACONF_OPTS --setcfg server.runuser=$RUNUSER"
92 [ -n "$RUNGROUP" ] && METACONF_OPTS="$METACONF_OPTS --setcfg server.rungroup=$RUNGROUP"
93 METACONF_OPTS="$METACONF_OPTS --setcfg server.admuser=$ADMUSER"
94 METACONF_OPTS="$METACONF_OPTS --setcfg server.admgroup=$ADMGROUP"
96 while [ -n "$1" ] ; do
97 case "$1" in
98 --help)
99 usage
100 exit 0
102 --prefix)
103 PREFIX="$2"
104 shift
105 shift
107 --distonly)
108 DIST_ONLY=1
109 shift
112 shift
113 METACONF_OPTS="$METACONF_OPTS $*"
114 echo "Additional options to openxpki-metaconf: '$*'"
115 shift $#
118 echo "Unrecognized option $1"
119 exit 1
121 esac
122 done
124 BASH_SHELL=`which bash`
126 if [ "${DIST_ONLY}" != "0" ] ; then
127 # Use "," as delimeter symbol when calling sed
128 # change "[% shell.bash %]" line into actual path to bash
129 # Keep initial file under the name Makefile.in
130 sed -e "s,\[\% shell.bash \%\],$BASH_SHELL,g" < Makefile.in > Makefile
131 echo
132 echo "Specially reduced Makefile created. You may now prepare distribution tarball by running command:"
133 echo
134 echo "(g)make dist"
135 echo
136 else
137 echo "Configuring for installation in $PREFIX..."
138 # create initial configuration with new prefix
139 for TEMPLATE in $TEMPLATEDIR/* ; do
140 echo "Creating template set configuration in $TEMPLATE"
141 if [ -d $TEMPLATE ] ; then
142 $CFG --config $TEMPLATE/openxpki.conf.in \
143 --writecfg $TEMPLATE/openxpki.conf \
144 --force \
145 --setcfg dir.prefix="$PREFIX" \
146 $METACONF_OPTS
148 done
150 echo "Creating Makefile..."
151 $CFG --config $TEMPLATEDIR/default/openxpki.conf \
152 --setcfg shell.bash="$BASH_SHELL" \
153 --file Makefile.in >Makefile
155 echo
156 echo "Initial configuration complete. You may now run"
157 echo
158 echo "(g)make"
159 echo "(g)make install"
160 echo
161 echo "in order to build and install the OpenXPKI administrative environment."
162 echo