f895b9878c822e8c9188cf814c4802e72dd28442
[openwrt/staging/dedeckeh.git] / package / libs / openssl / files / openssl.init
1 #!/bin/sh /etc/rc.common
2
3 START=13
4 ENGINES_CNF_D="/etc/ssl/engines.cnf.d"
5 ENGINES_CNF="/var/etc/ssl/engines.cnf"
6 ENGINES_DIR="%ENGINES_DIR%"
7
8 config_engine() {
9 local builtin enabled force
10
11 config_get_bool builtin "$1" builtin 0
12 config_get_bool enabled "$1" enabled 1
13 config_get_bool force "$1" force 0
14
15 if [ "$enabled" = 0 ]; then
16 [ "$builtin" != 1 ] && return 1
17 echo "Engine $1 is built into the libcrypto library and can't be disabled through UCI." && \
18 echo "If the engine was not built-in, remove 'config builtin' from /etc/config/openssl."
19 elif [ "$force" = 1 ]; then
20 printf "[Forced] "
21 elif ! grep -q "\\[ *$1 *]" "${ENGINES_CNF_D}"/*; then
22 echo "$1: Could not find section [$1] in config files."
23 return 1
24 elif [ "$builtin" = 1 ]; then
25 printf "[Builtin] "
26 elif [ ! -f "${ENGINES_DIR}/$1.so" ];then
27 echo "$1: ${ENGINES_DIR}/$1.so not found."
28 return 1
29 fi
30 echo Enabling engine "$1"
31 echo "$1=$1" >> "${ENGINES_CNF}"
32 }
33
34 start() {
35 mkdir -p "$(dirname "${ENGINES_CNF}")" || exit 1
36 echo Generating engines.cnf
37 echo "# This file is automatically generated from /etc/config/openssl." \
38 > "${ENGINES_CNF}" || \
39 { echo Error writing ${ENGINES_CNF} >&2; exit 1; }
40 config_load openssl
41 config_foreach config_engine engine
42 }