105
if [ -r /conf/conf.d/cryptroot ]; then
108
# Do not replace cryptroot file unless we need to.
112
mandos=/lib/mandos/plugin-runner
115
# parse /conf/conf.d/cryptroot. Format:
116
# target=sda2_crypt,source=/dev/sda2,rootdev,key=none,keyscript=/foo/bar/baz
117
# Is the root device specially marked?
119
while read -r options; do
121
rootdev,*|*,rootdev,*|*,rootdev)
122
# If the root device is specially marked, don't change all
123
# lines in crypttab by default.
106
# Do not replace cryptroot file unless we need to.
110
mandos=/lib/mandos/plugin-runner
113
# parse /conf/conf.d/cryptroot. Format:
114
# target=sda2_crypt,source=/dev/sda2,key=none,keyscript=/foo/bar/baz
115
exec 3>/conf/conf.d/cryptroot.mandos
116
while read options; do
118
# Split option line on commas
121
for opt in $options; do
122
# Find the keyscript option, if any
125
keyscript="${opt#keyscript=}"
126
newopts="$newopts,$opt"
130
newopts="$newopts,$opt"
127
done < /conf/conf.d/cryptroot
129
exec 3>/conf/conf.d/cryptroot.mandos
130
while read -r options; do
133
changethis="$changeall"
134
# Split option line on commas
137
for opt in $options; do
138
# Find the keyscript option, if any
141
keyscript="${opt#keyscript=}"
142
newopts="$newopts,$opt"
145
# Always use Mandos on the root device, if marked
148
newopts="$newopts,$opt"
150
# Don't use Mandos on resume device, if marked
153
newopts="$newopts,$opt"
156
newopts="$newopts,$opt"
162
# If there was no keyscript option, add one.
163
if [ "$changethis" = yes ] && [ -z "$keyscript" ]; then
164
replace_cryptroot=yes
165
newopts="$newopts,keyscript=$mandos"
167
newopts="${newopts#,}"
169
done < /conf/conf.d/cryptroot
172
# If we need to, replace the old cryptroot file with the new file.
173
if [ "$replace_cryptroot" = yes ]; then
174
mv /conf/conf.d/cryptroot /conf/conf.d/cryptroot.mandos-old
175
mv /conf/conf.d/cryptroot.mandos /conf/conf.d/cryptroot
177
rm -f /conf/conf.d/cryptroot.mandos
136
# If there was no keyscript option, add one.
137
if [ -z "$keyscript" ]; then
138
replace_cryptroot=yes
139
newopts="$newopts,keyscript=$mandos"
179
elif [ -x /usr/bin/cryptroot-unlock ]; then
180
setsid /lib/mandos/mandos-to-cryptroot-unlock &
141
newopts="${newopts#,}"
143
done < /conf/conf.d/cryptroot
146
# If we need to, replace the old cryptroot file with the new file.
147
if [ "$replace_cryptroot" = yes ]; then
148
mv /conf/conf.d/cryptroot /conf/conf.d/cryptroot.mandos-old
149
mv /conf/conf.d/cryptroot.mandos /conf/conf.d/cryptroot
151
rm /conf/conf.d/cryptroot.mandos