forked from mk-fg/dracut-crypt-sshd
-
Notifications
You must be signed in to change notification settings - Fork 3
/
configure
executable file
·128 lines (117 loc) · 2.63 KB
/
configure
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
#!/bin/bash
while [[ $# -gt 0 ]]; do
case $1 in
--print-moduledir)
[[ -f config.mk ]] && source config.mk
[[ -z $DRACUT_MODULEDIR ]] && exit 1
echo $DRACUT_MODULEDIR
exit 0
;;
--dracut)
DRACUT=$2
shift
;;
--root-home)
ROOTHOME=$2
shift
;;
esac
shift
done
echo -n "Searching for dracut... "
if [[ -z $DRACUT ]]; then
DRACUT=$(which dracut)
if [[ $? -eq 0 ]]; then
echo $DRACUT
else
echo "not found"
exit 1
fi
else
echo "[provided] $DRACUT"
fi
echo -n "Checking dracut version... "
DRACUT_VERSION=$(${DRACUT} --help | egrep "Version:[ \t]+[0-9]+" | egrep -o [0-9]+)
if [[ $? -ne 0 ]]; then
echo -n "[old version - fallback] "
DRACUT_VERSION=004
else
DRACUT_VERSION=$(echo ${DRACUT_VERSION} | cut -f 1 -d " ")
fi
echo ${DRACUT_VERSION}
echo -n "Checking dracut module prefix... "
DRACUT_MODULEDIR=""
if [[ -d /usr/lib/dracut/modules.d ]]; then
DRACUT_MODULEDIR=lib/dracut/modules.d
elif [[ -d /usr/share/dracut/modules.d ]]; then
DRACUT_MODULEDIR=share/dracut/modules.d
else
echo "failed"
exit 1
fi
echo ${DRACUT_MODULEDIR}
NEED_CRYPTSETTLE=0
CRYPTPARSE=/usr/${DRACUT_MODULEDIR}/90crypt/parse-crypt.sh
if [[ -f $CRYPTPARSE ]]; then
echo -n "Checking whether crypt-settle patch is needed... "
grep -c -- "--settled" ${CRYPTPARSE} >/dev/null
if [[ $? -ne 0 ]]; then
NEED_CRYPTSETTLE=1
echo "yes"
else
echo "no"
fi
fi
echo -n "Checking for old-style modules... "
OLDSTYLE=1
if [[ -f /usr/${DRACUT_MODULEDIR}/99base/module-setup.sh ]]; then
OLDSTYLE=0
echo "no"
else
echo "yes"
fi
echo -n "Checking for root's home... "
if [[ -z ${ROOTHOME} ]]; then
ROOTHOME=/
module=module-setup.sh
[[ ${OLDSTYLE} -eq 1 ]] && module=install
MODULEBASE=/usr/${DRACUT_MODULEDIR}/99base/${module}
if [[ -f $MODULEBASE ]]; then
grep -c "root:" ${MODULEBASE} >/dev/null
if [[ $? -eq 0 ]]; then
ROOTHOME=/root
fi
fi
else
echo -n "[provided] "
fi
echo ${ROOTHOME}
echo -n "Checking for libnss_files.so ... "
DIRS="/usr/lib /usr/lib64 /lib64 /lib"
NSSFILES=""
for dir in ${DIRS}; do
for check in ${dir}/libnss_files.so*; do
if [[ -f $check ]]; then
NSSFILES=${check}
break
fi
done
done
if [[ -z $NSSFILES ]]; then
echo "not found"
exit 1
else
echo $NSSFILES
fi
OLDDRACUT=0
[[ $DRACUT_VERSION -le 4 ]] && OLDDRACUT=1
cat >config.mk <<EOF
export DRACUT=${DRACUT}
export DRACUT_VERSION=${DRACUT_VERSION}
export DRACUT_MODULEDIR=${DRACUT_MODULEDIR}
export NEED_CRYPTSETTLE=${NEED_CRYPTSETTLE}
export ROOTHOME=${ROOTHOME}
export OLDSTYLE=${OLDSTYLE}
export NSSFILES=${NSSFILES}
export OLDDRACUT=${OLDDRACUT}
EOF