indent: replace tab by 4 spaces

As decided in I072cf8bf6748d0c910fecffdf2282bcc4656d038, tab indent
should be avoided.

Change-Id: I301b6319ef4f36878999b6109e1842f9e7cafd43
This commit is contained in:
Gonéri Le Bouder 2014-04-18 10:29:46 +02:00
parent a9c0a7bf27
commit 9cb0615f38
2 changed files with 183 additions and 183 deletions

View File

@ -16,23 +16,23 @@
# under the License.
function get_kernel_parameter() {
local name=$1
for i in `cat /proc/cmdline`; do
case "$i" in
${name}=*)
echo "${i#${name}=}"
return 0
;;
${name})
echo ""
return 0
;;
*)
;;
esac
done
echo ""
return 1
local name=$1
for i in `cat /proc/cmdline`; do
case "$i" in
${name}=*)
echo "${i#${name}=}"
return 0
;;
${name})
echo ""
return 0
;;
*)
;;
esac
done
echo ""
return 1
}
function string_contains() {
@ -46,170 +46,170 @@ function string_contains() {
}
function load_modules_by_udev() {
udevadm trigger --action=add
udevadm settle
udevadm trigger --action=add
udevadm settle
}
function strip_dev() {
echo "$1" | sed -e 's:^/dev/::'
echo "$1" | sed -e 's:^/dev/::'
}
function prepend_dev() {
case "$1" in
/dev/*)
echo "$1"
;;
*)
echo "/dev/$1"
;;
esac
case "$1" in
/dev/*)
echo "$1"
;;
*)
echo "/dev/$1"
;;
esac
}
function whole_disk_name() {
local dev=`prepend_dev "$1"`
case "$dev" in
/dev/sd*|/dev/hd*|/dev/vd*)
echo "$dev" | sed -e 's/[0-9]*$//'
;;
/dev/cciss/*)
echo "$dev" | sed -e 's/p[0-9]*$//'
;;
*)
echo ""
return 1
;;
esac
local dev=`prepend_dev "$1"`
case "$dev" in
/dev/sd*|/dev/hd*|/dev/vd*)
echo "$dev" | sed -e 's/[0-9]*$//'
;;
/dev/cciss/*)
echo "$dev" | sed -e 's/p[0-9]*$//'
;;
*)
echo ""
return 1
;;
esac
}
function partition_name() {
local dev=`prepend_dev "$1"`
local part=$2
case "$dev" in
/dev/sd*|/dev/hd*|/dev/vd*)
echo "${dev}${part}"
;;
/dev/cciss/*)
echo "${dev}p${part}"
;;
*)
echo ""
return 1
;;
esac
local dev=`prepend_dev "$1"`
local part=$2
case "$dev" in
/dev/sd*|/dev/hd*|/dev/vd*)
echo "${dev}${part}"
;;
/dev/cciss/*)
echo "${dev}p${part}"
;;
*)
echo ""
return 1
;;
esac
}
function find_interface() {
local mac=$1
eth=`ifconfig -a | grep -i "$mac" | awk {' print $1 '} | head -n 1`
if [ -n "$eth" ]; then
echo "$eth"
return 0
else
return 1
fi
local mac=$1
eth=`ifconfig -a | grep -i "$mac" | awk {' print $1 '} | head -n 1`
if [ -n "$eth" ]; then
echo "$eth"
return 0
else
return 1
fi
}
function set_mac() {
local dev=$1
local mac=$2
ip link set "$dev" address "$mac"
local dev=$1
local mac=$2
ip link set "$dev" address "$mac"
}
function swap_ifname() {
local dev=$1
local dev2=$2
if [ "$dev" = "$dev2" ]; then
return
fi
if ip link show "$dev2" >/dev/null; then
# dev2 exists
# swap device name
ip link set "$dev" name "_$dev"
ip link set "$dev2" name "$dev"
ip link set "_$dev" name "$dev2"
else
ip link set "$dev" name "$dev2"
fi
local dev=$1
local dev2=$2
if [ "$dev" = "$dev2" ]; then
return
fi
if ip link show "$dev2" >/dev/null; then
# dev2 exists
# swap device name
ip link set "$dev" name "_$dev"
ip link set "$dev2" name "$dev"
ip link set "_$dev" name "$dev2"
else
ip link set "$dev" name "$dev2"
fi
}
function partition_exists() {
local dev=$1
dev=`strip_dev "$dev"`
if tail -n +3 /proc/partitions | grep "$dev" >/dev/null; then
return 0
else
return 1
fi
local dev=$1
dev=`strip_dev "$dev"`
if tail -n +3 /proc/partitions | grep "$dev" >/dev/null; then
return 0
else
return 1
fi
}
function find_disk() {
local disks=$1
local dev
local disks=$1
local dev
# find device
local OLD_IFS=$IFS
IFS=,
for i in $disks; do
dev=`whole_disk_name "$i"`
if partition_exists "$dev"; then
dev=`prepend_dev "$dev"`
break
fi
dev=""
done
IFS=$OLD_IFS
# find device
local OLD_IFS=$IFS
IFS=,
for i in $disks; do
dev=`whole_disk_name "$i"`
if partition_exists "$dev"; then
dev=`prepend_dev "$dev"`
break
fi
dev=""
done
IFS=$OLD_IFS
if [ -z "$dev" ]; then
return 1
fi
echo "$dev"
return 0
if [ -z "$dev" ]; then
return 1
fi
echo "$dev"
return 0
}
function check_tgtd_socket() {
echo -n "waiting for tgtd socket..."
if [ -e /var/run/tgtd.ipc_abstract_namespace.0 ]; then
echo "found"
return 0
else
echo "not found"
return 1
fi
echo -n "waiting for tgtd socket..."
if [ -e /var/run/tgtd.ipc_abstract_namespace.0 ]; then
echo "found"
return 0
else
echo "not found"
return 1
fi
}
wait_for(){
LOOPS=$1
SLEEPTIME=$2
shift ; shift
i=0
while [ $i -lt $LOOPS ] ; do
i=$((i + 1))
eval "$@" && return 0 || true
sleep $SLEEPTIME
done
return 1
LOOPS=$1
SLEEPTIME=$2
shift ; shift
i=0
while [ $i -lt $LOOPS ] ; do
i=$((i + 1))
eval "$@" && return 0 || true
sleep $SLEEPTIME
done
return 1
}
function start_iscsi_target() {
local iqn=$1
local dev=$2
local cli=$3
local iqn=$1
local dev=$2
local cli=$3
# used by tgtd
mkdir -p /var/run
# used by tgtd
mkdir -p /var/run
tgtd
wait_for 10 0.5 check_tgtd_socket
tgtd
wait_for 10 0.5 check_tgtd_socket
tgtadm --lld iscsi --mode target --op new --tid 1 --targetname "$iqn"
tgtadm --lld iscsi --mode logicalunit --op new --tid 1 --lun 1 --backing-store "$dev"
tgtadm --lld iscsi --mode target --op bind --tid 1 --initiator-address "$cli"
tgtadm --lld iscsi --mode target --op new --tid 1 --targetname "$iqn"
tgtadm --lld iscsi --mode logicalunit --op new --tid 1 --lun 1 --backing-store "$dev"
tgtadm --lld iscsi --mode target --op bind --tid 1 --initiator-address "$cli"
}
function stop_iscsi_target() {
tgtadm --lld iscsi --mode logicalunit --op delete --tid 1 --lun 1
tgtadm --lld iscsi --mode target --op delete --tid 1
killall tgtd
tgtadm --lld iscsi --mode logicalunit --op delete --tid 1 --lun 1
tgtadm --lld iscsi --mode target --op delete --tid 1
killall tgtd
}
function troubleshoot() {
@ -228,39 +228,39 @@ function troubleshoot() {
done
echo ""
fi
if [ "$TROUBLESHOOT" == 1 ]; then
echo "Starting troubleshooting shell."
bash
fi
if [ "$TROUBLESHOOT" == 1 ]; then
echo "Starting troubleshooting shell."
bash
fi
}
function safe_url_encode() {
local str=$1
local out=""
local str=$1
local out=""
for (( i=0; i<${#str}; i++ )); do
c=${str:$i:1}
case $c in
[a-zA-Z0-9.-_] )
out+="$c"
;;
' ' )
out+="+"
;;
*)
#skip it
;;
esac
done
echo "$out"
for (( i=0; i<${#str}; i++ )); do
c=${str:$i:1}
case $c in
[a-zA-Z0-9.-_] )
out+="$c"
;;
' ' )
out+="+"
;;
*)
#skip it
;;
esac
done
echo "$out"
}
function err_msg() {
message=$1
if [ -z "$FIRST_ERR_MSG" ]; then
FIRST_ERR_MSG=$(safe_url_encode "$message")
fi
echo "$message"
message=$1
if [ -z "$FIRST_ERR_MSG" ]; then
FIRST_ERR_MSG=$(safe_url_encode "$message")
fi
echo "$message"
}

View File

@ -1,15 +1,15 @@
echo "starting network $BOOT_MAC_ADDRESS"
t=0
while ! BOOT_INTERFACE=$(find_interface "$BOOT_MAC_ADDRESS"); do
t=`expr "$t" + 5`
if [ "$t" -gt 10 ]; then
break
fi
sleep 5
t=`expr "$t" + 5`
if [ "$t" -gt 10 ]; then
break
fi
sleep 5
done
if [ -z "$BOOT_INTERFACE" ]; then
err_msg "Could not find an interface that owns MAC: $BOOT_MAC_ADDRESS"
troubleshoot
err_msg "Could not find an interface that owns MAC: $BOOT_MAC_ADDRESS"
troubleshoot
fi
readonly BOOT_INTERFACE
@ -18,13 +18,13 @@ ifconfig lo 127.0.0.1 up
rv=0
ifconfig "$BOOT_INTERFACE" up || rv=1
if [ rv -ne 0 ]; then
sleep 10
rv=0
ifconfig "$BOOT_INTERFACE" up || rv=1
if [ $? -ne 0 ]; then
err_msg "Failed to ifconfig up $BOOT_INTERFACE"
troubleshoot
fi
sleep 10
rv=0
ifconfig "$BOOT_INTERFACE" up || rv=1
if [ $? -ne 0 ]; then
err_msg "Failed to ifconfig up $BOOT_INTERFACE"
troubleshoot
fi
fi
ifconfig "$BOOT_INTERFACE" "$BOOT_IP_ADDRESS" netmask "$BOOT_NETMASK"
route del default || true
@ -33,12 +33,12 @@ route add default gw $BOOT_GATEWAY
echo "pinging to boot server $BOOT_SERVER"
w=30
while [ $w -gt 0 ]; do
ping -c 5 -q "$BOOT_SERVER" > /dev/null
if [ $? -eq 0 ]; then
break
fi
sleep 1
w=`expr $w - 5`
ping -c 5 -q "$BOOT_SERVER" > /dev/null
if [ $? -eq 0 ]; then
break
fi
sleep 1
w=`expr $w - 5`
done
echo "network ready"