diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2013-11-22 16:18:55 +0100 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2015-06-07 04:27:47 +0200 |
commit | 5df4738c72485e6788e70ce021ce266aa556acfa (patch) | |
tree | 2d8c0e3b1b765d0b3cd2d16680e76853db39f1ce | |
parent | 7870977adc6e8aec370b182561c3dd767a97322e (diff) |
wibble
Replaced [ -n "$string" ] with [ "$string" ], and [ -z "$string" ] with
[ ! "$string" ].
-rw-r--r-- | src/fripost-partman-udeb/base.sh | 19 | ||||
-rwxr-xr-x | virtualenv/virt | 15 |
2 files changed, 19 insertions, 15 deletions
diff --git a/src/fripost-partman-udeb/base.sh b/src/fripost-partman-udeb/base.sh index 3266bc6..d44d983 100644 --- a/src/fripost-partman-udeb/base.sh +++ b/src/fripost-partman-udeb/base.sh @@ -206,7 +206,7 @@ fripost_encrypt() { db_go db_get fripost/encryption-password - if [ -n "$RET" ]; then + if [ "$RET" ]; then log "The password can be found from debconf (hey, that's insecure!)" # Since we're using the builtin, the password shouldn't be # visible in ps(1). @@ -381,7 +381,7 @@ fripost_mkfs() { # XXX: The parsing has been tested with mkfs.ext{2,3,4} only. case "$line" in *:*/*) - [ -z "$total" ] || db_progress STOP + [ "$total" ] && db_progress STOP stage="${line%: *}" step="${line##*: }" @@ -395,10 +395,10 @@ fripost_mkfs() { db_progress INFO fripost/mkfs_progress_info ;; */$total) - [ -z "$total" ] || db_progress SET ${line%/*} + [ "$total" ] && db_progress SET ${line%/*} ;; done) - [ -z "$total" ] || db_progress SET $total + [ "$total" ] && db_progress SET $total ;; esac done 7< "$fifo" @@ -406,7 +406,7 @@ fripost_mkfs() { rm -f "$fifo" trap '' EXIT - [ -z "$total" ] || db_progress STOP + [ "$total" ] && db_progress STOP db_unregister fripost/mkfs_progress_title db_unregister fripost/mkfs_progress_info } @@ -463,7 +463,7 @@ fripost_fstab_addentry() { # Always use UUIDs local uuid=$(/bin/block-attr --uuid "$device") - if [ -z "$uuid" ]; then + if [ ! "$uuid" ]; then log "Warning: Block device $device has no UUID!" printf "$entry" "$device" $mp $type $options $dump $pass >> $fstab else @@ -510,7 +510,7 @@ fripost_mount_partitions() { # for APT packages. TODO: What if it was a USB stick? A netboot? cdrom=$( sed -rn 's#^(\S+) /cdrom.*#\1#p' /proc/mounts \ | grep -m1 -Ev '^/dev/(loop|sd[a-z])' ) - [ -n "$cdrom" ] || fatal "Error: Is /cdrom a mountpoint?" + [ "$cdrom" ] || fatal "Error: Is /cdrom a mountpoint?" fripost_fstab_addentry "$cdrom" /media/cdrom0 udf,iso9660 user,noauto 0 0 mkdir -p /target/media/cdrom0 ln -s cdrom0 /target/media/cdrom @@ -522,5 +522,8 @@ fripost_mount_partitions() { } getIPv4() { - /bin/ip addr show "${1:-eth0}" | sed -nr 's/^\s+inet\s([0-9.]{4,32}).*/\1/p' + local if=$( /bin/ip -4 route show to default scope global \ + | sed -nr '/^default via \S+ dev (\S+).*/ {s//\1/p;q}' ) + /bin/ip -4 address show dev "$if" scope global \ + | sed -nr '/^\s+inet\s([[:xdigit:].:]{3,39}).*/ {s//\1/p;q}' } diff --git a/virtualenv/virt b/virtualenv/virt index b88d04e..043589f 100755 --- a/virtualenv/virt +++ b/virtualenv/virt @@ -10,7 +10,7 @@ set -ue root=$(dirname "$0") -help() { +usage() { cat >&2 <<-EOF Usage: $0 install <libvirt domain> [<QEMU image>] @@ -41,7 +41,7 @@ isActive() { } install() { - [ $# -eq 1 -o $# -eq 2 ] || help + [ $# -eq 1 -o $# -eq 2 ] || usage local name=$1 local disk=${2:-$root/images/${name}.qcow2} @@ -103,7 +103,7 @@ install() { | sed '/^\s*$/d' \ | sort -n \ | tail -1 ) - [ -n "$ip" ] || \ + [ "$ip" ] || \ ip=$( /usr/bin/virsh net-dumpxml $network \ | /usr/bin/xmlstarlet sel -t -m /network/ip -v @address ) ip=${ip%.*}.$(( 1 + ${ip##*.} )) @@ -123,7 +123,7 @@ install() { } view(){ - [ $# -eq 1 ] || help + [ $# -eq 1 ] || usage local domain="$1" if ! doesExist "$domain"; then @@ -141,17 +141,18 @@ view(){ local type=$(get_XML_attribute "$domain" devices/graphics type) local port=$(get_XML_attribute "$domain" devices/graphics port) || true - if [ "$type" != spice -o -z "$port" ]; then + if ! [ "$type" = spice -a "$port" ]; then echo "Error: Could not find a valid Spice server on domain '$domain'." >&2 exit 1 fi /usr/bin/spicec -h 127.0.0.1 -p $port } -command="${1:-}" +[ $# -gt 0 ] || usage +command="$1" shift; case "$command" in install|view) $command "$@";; - *) help + *) usage esac |