Changeset View
Standalone View
etc/rc.d/geli
Show All 28 Lines | |||||
# PROVIDE: disks | # PROVIDE: disks | ||||
# KEYWORD: nojail | # KEYWORD: nojail | ||||
. /etc/rc.subr | . /etc/rc.subr | ||||
name="geli" | name="geli" | ||||
desc="GELI disk encryption" | desc="GELI disk encryption" | ||||
start_precmd='[ -n "$(geli_make_list)" ]' | start_precmd='[ -n "$(geli_make_list)" -o -n "$geli_groups" ]' | ||||
sobomax: Use {} around var name consistently:
```
start_precmd='[ -n "${geli_make_list}" -o -n… | |||||
Done Inline ActionsI think this comment was wrong. This code is a shell script, not a Makefile, and therefore $(geli_make_list) and ${geli_make_list} do something completely different. What is intended here is calling the function and checking its output, not checking a variable (which will not exist). The same change was made to D12644. Note that calling a function like this invokes it in a subshell environment and in a new process. Try to avoid this in new code since it is slower and causes changes to global variables and other state to be lost. jilles: I think this comment was wrong. This code is a shell script, not a Makefile, and therefore `$… | |||||
Done Inline ActionsAw, perhaps @jilles is right. Then geli_groups should be in {} and geli_make_list in (). sobomax: Aw, perhaps @jilles is right. Then geli_groups should be in {} and geli_make_list in (). | |||||
Done Inline ActionsIndeed, good pickup jilles. Thanks woodsb02: Indeed, good pickup jilles. Thanks | |||||
start_cmd="geli_start" | start_cmd="geli_start" | ||||
stop_cmd="geli_stop" | stop_cmd="geli_stop" | ||||
required_modules="geom_eli:g_eli" | required_modules="geom_eli:g_eli" | ||||
geli_start() | geli_start() | ||||
{ | { | ||||
devices=`geli_make_list` | devices=`geli_make_list` | ||||
Show All 21 Lines | if [ -e "/dev/${provider}" -a ! -e "/dev/${provider}.eli" ]; then | ||||
if [ -e "/dev/${provider}.eli" ]; then | if [ -e "/dev/${provider}.eli" ]; then | ||||
break | break | ||||
fi | fi | ||||
echo "Attach failed; attempt ${count} of ${geli_tries}." | echo "Attach failed; attempt ${count} of ${geli_tries}." | ||||
count=$((count+1)) | count=$((count+1)) | ||||
done | done | ||||
fi | fi | ||||
done | done | ||||
for group in ${geli_groups}; do | |||||
group_=`ltr ${group} '/-' '_'` | |||||
eval "flags=\${geli_${group_}_flags}" | |||||
if [ -z "${flags}" ]; then | |||||
flags=${geli_default_flags} | |||||
fi | |||||
eval "providers=\${geli_${group_}_devices}" | |||||
if [ -z "${providers}" ]; then | |||||
echo "No devices listed in geli group ${group}." | |||||
break | |||||
Done Inline ActionsMaybe continue here? (so that one empty group won't prevent the following groups being attached) delphij: Maybe continue here? (so that one empty group won't prevent the following groups being attached) | |||||
Done Inline ActionsGood point - I will update the review with this woodsb02: Good point - I will update the review with this | |||||
fi | |||||
echo "Configuring Disk Encryption for geli group ${group}, containing ${providers}." | |||||
geli attach ${flags} ${providers} | |||||
done | |||||
} | } | ||||
geli_stop() | geli_stop() | ||||
{ | { | ||||
devices=`geli_make_list` | devices=`geli_make_list` | ||||
for group in ${geli_groups}; do | |||||
group_=`ltr ${group} '/-' '_'` | |||||
eval "providers=\${geli_${group_}_devices}" | |||||
devices="${devices} ${providers}" | |||||
done | |||||
for provider in ${devices}; do | for provider in ${devices}; do | ||||
if [ -e "/dev/${provider}.eli" ]; then | if [ -e "/dev/${provider}.eli" ]; then | ||||
umount "/dev/${provider}.eli" 2>/dev/null | umount "/dev/${provider}.eli" 2>/dev/null | ||||
geli detach "${provider}" | geli detach "${provider}" | ||||
fi | fi | ||||
done | done | ||||
} | } | ||||
load_rc_config $name | load_rc_config $name | ||||
run_rc_command "$1" | run_rc_command "$1" |
Use {} around var name consistently: