diff --git a/src/disk.sh b/src/disk.sh index e1c8084..7cd23df 100644 --- a/src/disk.sh +++ b/src/disk.sh @@ -82,7 +82,7 @@ isCow() { supportsDirect() { local FS=$1 - if [[ "${FS,,}" == "ecryptfs" ]] || [[ "${FS,,}" == "tmpfs" ]]; then + if [[ "${FS,,}" == "ecryptfs" || "${FS,,}" == "tmpfs" ]]; then return 1 fi @@ -507,7 +507,7 @@ addDevice () { physical="${physical%% *}" if [ -n "$physical" ]; then - if [[ "$physical" == "512" ]] || [[ "$physical" == "4096" ]]; then + if [[ "$physical" == "512" || "$physical" == "4096" ]]; then if [[ "$physical" == "4096" ]]; then sectors=",logical_block_size=$logical,physical_block_size=$physical" fi @@ -554,7 +554,7 @@ DISK_OPTS+=$(createDevice "$BOOT" "$DISK_TYPE" "1" "0xa" "raw" "$DISK_IO" "$DISK DISK_OPTS+=$(createDevice "$SYSTEM" "$DISK_TYPE" "2" "0xb" "raw" "$DISK_IO" "$DISK_CACHE" "" "") DISK1_FILE="$STORAGE/${DISK_NAME}" -if [[ ! -f "$DISK1_FILE.img" ]] && [[ -f "$STORAGE/data${DISK_SIZE}.img" ]]; then +if [[ ! -f "$DISK1_FILE.img" && -f "$STORAGE/data${DISK_SIZE}.img" ]]; then # Fallback for legacy installs mv "$STORAGE/data${DISK_SIZE}.img" "$DISK1_FILE.img" fi @@ -563,7 +563,7 @@ DISK2_FILE="/storage2/${DISK_NAME}2" if [ ! -f "$DISK2_FILE.img" ]; then # Fallback for legacy installs FALLBACK="/storage2/data.img" - if [[ -f "$DISK1_FILE.img" ]] && [[ -f "$FALLBACK" ]]; then + if [[ -f "$DISK1_FILE.img" && -f "$FALLBACK" ]]; then SIZE1=$(stat -c%s "$FALLBACK") SIZE2=$(stat -c%s "$DISK1_FILE.img") if [[ SIZE1 -ne SIZE2 ]]; then @@ -576,7 +576,7 @@ DISK3_FILE="/storage3/${DISK_NAME}3" if [ ! -f "$DISK3_FILE.img" ]; then # Fallback for legacy installs FALLBACK="/storage3/data.img" - if [[ -f "$DISK1_FILE.img" ]] && [[ -f "$FALLBACK" ]]; then + if [[ -f "$DISK1_FILE.img" && -f "$FALLBACK" ]]; then SIZE1=$(stat -c%s "$FALLBACK") SIZE2=$(stat -c%s "$DISK1_FILE.img") if [[ SIZE1 -ne SIZE2 ]]; then diff --git a/src/display.sh b/src/display.sh index a9598bf..2affc00 100644 --- a/src/display.sh +++ b/src/display.sh @@ -10,7 +10,7 @@ set -Eeuo pipefail CPU_VENDOR=$(lscpu | awk '/Vendor ID/{print $3}') -if [[ "$GPU" != [Yy1]* ]] || [[ "$CPU_VENDOR" != "GenuineIntel" ]] || [[ "$ARCH" != "amd64" ]]; then +if [[ "$GPU" != [Yy1]* || "$CPU_VENDOR" != "GenuineIntel" || "$ARCH" != "amd64" ]]; then [[ "${DISPLAY,,}" == "none" ]] && VGA="none" DISPLAY_OPTS="-display $DISPLAY -vga $VGA" diff --git a/src/install.sh b/src/install.sh index 75bfa27..e89f3c9 100644 --- a/src/install.sh +++ b/src/install.sh @@ -18,7 +18,7 @@ DIR=$(find / -maxdepth 1 -type d -iname "$FN" -print -quit) if [ -d "$DIR" ]; then BASE="DSM_VirtualDSM" && URL="file://$DIR" - if [[ ! -s "$STORAGE/$BASE.boot.img" ]] || [[ ! -s "$STORAGE/$BASE.system.img" ]]; then + if [[ ! -s "$STORAGE/$BASE.boot.img" || ! -s "$STORAGE/$BASE.system.img" ]]; then error "The bind $DIR maps to a file that does not exist!" && exit 65 fi fi @@ -34,13 +34,13 @@ if [ -n "$URL" ] && [ ! -s "$FILE" ] && [ ! -d "$DIR" ]; then : "${BASE//+/ }"; printf -v BASE '%b' "${_//%/\\x}" BASE=$(echo "$BASE" | sed -e 's/[^A-Za-z0-9._-]/_/g') fi - if [[ "${URL,,}" != "http"* ]] && [[ "${URL,,}" != "file:"* ]] ; then + if [[ "${URL,,}" != "http"* && "${URL,,}" != "file:"* ]] ; then [ ! -s "$STORAGE/$BASE.pat" ] && error "Invalid URL: $URL" && exit 65 URL="file://$STORAGE/$BASE.pat" fi fi -if [[ -s "$STORAGE/$BASE.boot.img" ]] && [[ -s "$STORAGE/$BASE.system.img" ]]; then +if [[ -s "$STORAGE/$BASE.boot.img" && -s "$STORAGE/$BASE.system.img" ]]; then return 0 # Previous installation found fi @@ -88,7 +88,7 @@ if [[ "${FS,,}" == "fuse"* ]]; then info "Warning: the filesystem of $STORAGE is FUSE, this extra layer will negatively affect performance!" fi -if [[ "${FS,,}" == "ecryptfs" ]] || [[ "${FS,,}" == "tmpfs" ]]; then +if [[ "${FS,,}" == "ecryptfs" || "${FS,,}" == "tmpfs" ]]; then info "Warning: the filesystem of $STORAGE is $FS, which does not support O_DIRECT mode, adjusting settings..." fi diff --git a/src/network.sh b/src/network.sh index 71e1770..9d7c76c 100644 --- a/src/network.sh +++ b/src/network.sh @@ -59,7 +59,7 @@ configureDHCP() { fi ;; esac - if [[ "$MTU" != "0" ]] && [[ "$MTU" != "1500" ]]; then + if [[ "$MTU" != "0" && "$MTU" != "1500" ]]; then if ! ip link set dev "$VM_NET_TAP" mtu "$MTU"; then warn "Failed to set MTU size.." fi @@ -78,7 +78,7 @@ configureDHCP() { IFS=: read -r MAJOR MINOR < <(cat /sys/devices/virtual/net/"$VM_NET_TAP"/tap*/dev) (( MAJOR < 1)) && error "Cannot find: sys/devices/virtual/net/$VM_NET_TAP" && return 1 - [[ ! -e "$TAP_PATH" ]] && [[ -e "/dev0/${TAP_PATH##*/}" ]] && ln -s "/dev0/${TAP_PATH##*/}" "$TAP_PATH" + [[ ! -e "$TAP_PATH" && -e "/dev0/${TAP_PATH##*/}" ]] && ln -s "/dev0/${TAP_PATH##*/}" "$TAP_PATH" if [[ ! -e "$TAP_PATH" ]]; then { mknod "$TAP_PATH" c "$MAJOR" "$MINOR" ; rc=$?; } || : @@ -249,7 +249,7 @@ configureNAT() { error "$tuntap" && return 1 fi - if [[ "$MTU" != "0" ]] && [[ "$MTU" != "1500" ]]; then + if [[ "$MTU" != "0" && "$MTU" != "1500" ]]; then if ! ip link set dev "$VM_NET_TAP" mtu "$MTU"; then warn "Failed to set MTU size.." fi @@ -407,7 +407,7 @@ getInfo() { fi if [[ "${ADAPTER,,}" != "virtio-net-pci" ]]; then - if [[ "$MTU" != "0" ]] && [[ "$MTU" != "1500" ]]; then + if [[ "$MTU" != "0" && "$MTU" != "1500" ]]; then warn "MTU size is $MTU, but cannot be set for $ADAPTER adapters!" && MTU="0" fi fi @@ -466,7 +466,7 @@ html "Initializing network..." if [[ "$DEBUG" == [Yy1]* ]]; then mtu=$(cat "/sys/class/net/$VM_NET_DEV/mtu") line="Host: $HOST IP: $IP Gateway: $GATEWAY Interface: $VM_NET_DEV MAC: $VM_NET_MAC MTU: $mtu" - [[ "$MTU" != "0" ]] && [[ "$MTU" != "$mtu" ]] && line+=" ($MTU)" + [[ "$MTU" != "0" && "$MTU" != "$mtu" ]] && line+=" ($MTU)" info "$line" if [ -f /etc/resolv.conf ]; then nameservers=$(grep '^nameserver*' /etc/resolv.conf | head -c -1 | sed 's/nameserver //g;' | sed -z 's/\n/, /g') @@ -500,7 +500,7 @@ if [[ "$DHCP" == [Yy1]* ]]; then else - if [[ "$IP" != "172."* ]] && [[ "$IP" != "10.8"* ]] && [[ "$IP" != "10.9"* ]]; then + if [[ "$IP" != "172."* && "$IP" != "10.8"* && "$IP" != "10.9"* ]]; then checkOS fi @@ -542,6 +542,6 @@ else fi NET_OPTS+=" -device $ADAPTER,id=net0,netdev=hostnet0,romfile=,mac=$VM_NET_MAC" -[[ "$MTU" != "0" ]] && [[ "$MTU" != "1500" ]] && NET_OPTS+=",host_mtu=$MTU" +[[ "$MTU" != "0" && "$MTU" != "1500" ]] && NET_OPTS+=",host_mtu=$MTU" return 0 diff --git a/src/reset.sh b/src/reset.sh index ccef801..46536c9 100644 --- a/src/reset.sh +++ b/src/reset.sh @@ -76,7 +76,7 @@ fi # Check filesystem FS=$(stat -f -c %T "$STORAGE") -if [[ "${FS,,}" == "ecryptfs" ]] || [[ "${FS,,}" == "tmpfs" ]]; then +if [[ "${FS,,}" == "ecryptfs" || "${FS,,}" == "tmpfs" ]]; then DISK_IO="threads" DISK_CACHE="writeback" fi