Skip to content

Commit

Permalink
Updating coding style in a first bunch of locations.
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-baumann committed Jun 14, 2012
1 parent 297a309 commit 1faa69a
Show file tree
Hide file tree
Showing 6 changed files with 212 additions and 176 deletions.
65 changes: 37 additions & 28 deletions scripts/boot/misc-helpers.sh
Expand Up @@ -81,7 +81,6 @@ mount_images_in_directory ()
rootmnt="${2}"
mac="${3}"


if match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.squashfs" ||
match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext2" ||
match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext3" ||
Expand Down Expand Up @@ -377,7 +376,8 @@ really_export ()
eval export "${STRING}"="${VALUE}"
}

is_in_list_separator_helper () {
is_in_list_separator_helper ()
{
local sep=${1}
shift
local element=${1}
Expand All @@ -386,13 +386,15 @@ is_in_list_separator_helper () {
echo ${list} | grep -qe "^\(.*${sep}\)\?${element}\(${sep}.*\)\?$"
}

is_in_space_sep_list () {
is_in_space_sep_list ()
{
local element=${1}
shift
is_in_list_separator_helper "[[:space:]]" "${element}" "${*}"
}

is_in_comma_sep_list () {
is_in_comma_sep_list ()
{
local element=${1}
shift
is_in_list_separator_helper "," "${element}" "${*}"
Expand Down Expand Up @@ -501,10 +503,11 @@ where_is_mounted ()
grep -m1 "^${device} " /proc/mounts | cut -f2 -d ' '
}

trim_path () {
# remove all unnecessary /:s in the path, including last one (except
# if path is just "/")
echo ${1} | sed 's|//\+|/|g' | sed 's|^\(.*[^/]\)/$|\1|'
trim_path ()
{
# remove all unnecessary /:s in the path, including last one (except
# if path is just "/")
echo ${1} | sed 's|//\+|/|g' | sed 's|^\(.*[^/]\)/$|\1|'
}

what_is_mounted_on ()
Expand Down Expand Up @@ -761,7 +764,8 @@ mount_persistence_media ()
return 0
}

close_persistence_media () {
close_persistence_media ()
{
local device=${1}
local backing="$(where_is_mounted ${device})"

Expand Down Expand Up @@ -945,8 +949,7 @@ find_persistence_media ()
# in order to probe any filesystem it contains, like we do
# below. activate_custom_mounts() also depends on that any luks
# device already has been opened.
if is_in_comma_sep_list luks ${PERSISTENCE_ENCRYPTION} && \
is_luks_partition ${dev}
if is_in_comma_sep_list luks ${PERSISTENCE_ENCRYPTION} && is_luks_partition ${dev}
then
if luks_device=$(open_luks_device "${dev}")
then
Expand Down Expand Up @@ -991,8 +994,7 @@ find_persistence_media ()
fi

# Close luks device if it isn't used
if [ -z "${result}" ] && [ -n "${luks_device}" ] && \
is_active_luks_mapping "${luks_device}"
if [ -z "${result}" ] && [ -n "${luks_device}" ] && is_active_luks_mapping "${luks_device}"
then
/sbin/cryptsetup luksClose "${luks_device}"
fi
Expand Down Expand Up @@ -1034,7 +1036,8 @@ is_active_luks_mapping ()
/sbin/cryptsetup status "${device}" 1>/dev/null 2>&1
}

get_luks_backing_device () {
get_luks_backing_device ()
{
device=${1}
cryptsetup status ${device} 2> /dev/null | \
awk '{if ($1 == "device:") print $2}'
Expand Down Expand Up @@ -1131,7 +1134,9 @@ link_files ()
return
fi

find "${src_dir}" -mindepth 1 -maxdepth 1 | while read src; do
find "${src_dir}" -mindepth 1 -maxdepth 1 | \
while read src
do
local dest="${dest_dir}$(basename "${src}")"
if [ -d "${src}" ]
then
Expand Down Expand Up @@ -1166,19 +1171,23 @@ do_union ()
local unionro1="${3}" # first underlying read-only branch (optional)
local unionro2="${4}" # second underlying read-only branch (optional)

if [ "${UNIONTYPE}" = "aufs" ]
then
rw_opt="rw"
ro_opt="rr+wh"
noxino_opt="noxino"
elif [ "${UNIONTYPE}" = "unionfs-fuse" ]
then
rw_opt="RW"
ro_opt="RO"
else
rw_opt="rw"
ro_opt="ro"
fi
case "${UNIONTYPE}" in
aufs)
rw_opt="rw"
ro_opt="rr+wh"
noxino_opt="noxino"
;;

unionfs-fuse)
rw_opt="RW"
ro_opt="RO"
;;

*)
rw_opt="rw"
ro_opt="ro"
;;
esac

case "${UNIONTYPE}" in
unionfs-fuse)
Expand Down
26 changes: 15 additions & 11 deletions scripts/boot/mountroot.sh
Expand Up @@ -4,8 +4,9 @@

mountroot ()
{
if [ -x /scripts/local-top/cryptroot ]; then
/scripts/local-top/cryptroot
if [ -x /scripts/local-top/cryptroot ]
then
/scripts/local-top/cryptroot
fi

exec 6>&1
Expand Down Expand Up @@ -136,18 +137,20 @@ mountroot ()
fi


if [ -n "${ROOT_PID}" ] ; then
if [ -n "${ROOT_PID}" ]
then
echo "${ROOT_PID}" > "${rootmnt}"/live/root.pid
fi

log_end_msg

# unionfs-fuse needs /dev to be bind-mounted for the duration of
# live-bottom; udev's init script will take care of things after that
if [ "${UNIONTYPE}" = unionfs-fuse ]
then
mount -n -o bind /dev "${rootmnt}/dev"
fi
case "${UNIONTYPE}" in
unionfs-fuse)
mount -n -o bind /dev "${rootmnt}/dev"
;;
esac

# Move to the new root filesystem so that programs there can get at it.
if [ ! -d /root/live/image ]
Expand Down Expand Up @@ -205,10 +208,11 @@ mountroot ()
;;
esac

if [ "${UNIONFS}" = unionfs-fuse ]
then
umount "${rootmnt}/dev"
fi
case "${UNIONFS}" in
unionfs-fuse)
umount "${rootmnt}/dev"
;;
esac

exec 1>&6 6>&-
exec 2>&7 7>&-
Expand Down
6 changes: 3 additions & 3 deletions scripts/boot/netbase.sh
Expand Up @@ -17,7 +17,7 @@ Netbase ()

IFFILE="/root/etc/network/interfaces"

if [ "${STATICIP}" = "frommedia" -a -e "${IFFILE}" ]
if [ "${STATICIP}" = "frommedia" ] && [ -e "${IFFILE}" ]
then
# will use existent /etc/network/interfaces
log_end_msg
Expand All @@ -33,9 +33,9 @@ EOF
udevadm trigger
udevadm settle

if [ -z "${NETBOOT}" -a -n "${STATICIP}" -a "${STATICIP}" != "frommedia" ]
if [ -z "${NETBOOT}" ] && [ -n "${STATICIP}" ] && [ "${STATICIP}" != "frommedia" ]
then
parsed=$(echo "${STATICIP}" | sed -e 's/,/ /g')
parsed=$(echo "${STATICIP}" | sed -e 's|,| |g')

for ifline in ${parsed}
do
Expand Down

0 comments on commit 1faa69a

Please sign in to comment.