diff --git a/run/check.sh b/run/check.sh index 6179b26..cdc99ca 100644 --- a/run/check.sh +++ b/run/check.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -eu +set -u # Docker Healthcheck @@ -14,7 +14,6 @@ fi IP=$(cat "${FILE}") if ! curl -m 3 -ILfSs "http://${IP}:${PORT}/" > /dev/null; then - echo "Failed to reach ${IP}:${PORT}" exit 1 fi diff --git a/run/disk.sh b/run/disk.sh index 4eb4e27..b12df10 100644 --- a/run/disk.sh +++ b/run/disk.sh @@ -37,6 +37,7 @@ if [ -f "${DATA}" ]; then if [ "$ALLOCATE" = "N" ]; then + # Resize file by changing its length truncate -s "${DATA_SIZE}" "${DATA}"; else @@ -51,6 +52,7 @@ if [ -f "${DATA}" ]; then echo "ERROR: Specify a smaller size or disable preallocation with ALLOCATE=N." && exit 84 fi + # Resize file by allocating more space if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then echo "ERROR: Could not allocate a file for the virtual disk." && exit 85 fi @@ -78,10 +80,9 @@ fi if [ ! -f "${DATA}" ]; then - # Create an empty file - if [ "$ALLOCATE" = "N" ]; then + # Create an empty file truncate -s "${DATA_SIZE}" "${DATA}" else @@ -94,6 +95,7 @@ if [ ! -f "${DATA}" ]; then echo "ERROR: Specify a smaller size or disable preallocation with ALLOCATE=N." && exit 86 fi + # Create an empty file if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then rm -f "${DATA}" echo "ERROR: Could not allocate a file for the virtual disk." && exit 87 diff --git a/run/install.sh b/run/install.sh index 94162b9..1566539 100644 --- a/run/install.sh +++ b/run/install.sh @@ -2,14 +2,12 @@ set -eu # Display wait message on port 5000 - HTML="Please wait while Virtual DSM is installing..." /run/server.sh 5000 "${HTML}" > /dev/null & # Download the required files from the Synology website - DL="https://global.synologydownload.com/download/DSM" if [ -z "$URL" ]; then diff --git a/run/network.sh b/run/network.sh index f04409b..1a35131 100644 --- a/run/network.sh +++ b/run/network.sh @@ -159,7 +159,8 @@ configureNAT () { [[ -z $(hostname -d) ]] || DNSMASQ_OPTS="$DNSMASQ_OPTS --dhcp-option=option:domain-name,$(hostname -d)" fi - [ "$DEBUG" = "Y" ] && echo && echo "$DNSMASQ $DNSMASQ_OPTS" + DNSMASQ_OPTS=$(echo "$DNSMASQ_OPTS" | sed 's/\t/ /g' | tr -s ' ' | sed 's/^ *//') + [ "$DEBUG" = "Y" ] && echo "$DNSMASQ $DNSMASQ_OPTS" && echo $DNSMASQ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS} } @@ -185,9 +186,9 @@ GATEWAY=$(ip r | grep default | awk '{print $3}') if [ "$DEBUG" = "Y" ]; then IP=$(ip address show dev "${VM_NET_DEV}" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/) - echo "Info: Container IP is ${IP} with gateway ${GATEWAY}" - ifconfig - ip route + echo "Info: Container IP is ${IP} with gateway ${GATEWAY}" && echo + ifconfig && echo + ip route && echo fi diff --git a/run/run.sh b/run/run.sh index e7a7cbd..5fabd17 100755 --- a/run/run.sh +++ b/run/run.sh @@ -61,11 +61,13 @@ KVM_OPTS="-machine type=q35,usb=off${KVM_OPTS}" RAM_OPTS=$(echo "-m ${RAM_SIZE}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g') CPU_OPTS="-smp ${CPU_CORES},sockets=1,cores=${CPU_CORES},threads=1" EXTRA_OPTS="-device virtio-balloon-pci,id=balloon0 -object rng-random,id=rng0,filename=/dev/urandom -device virtio-rng-pci,rng=rng0" + ARGS="${DEF_OPTS} ${CPU_OPTS} ${RAM_OPTS} ${KVM_OPTS} ${MON_OPTS} ${SERIAL_OPTS} ${NET_OPTS} ${DISK_OPTS} ${EXTRA_OPTS}" +ARGS=$(echo "$ARGS" | sed 's/\t/ /g' | tr -s ' ') if [ "$DEBUG" = "Y" ]; then - echo && echo -n "qemu-system-x86_64 " - echo "${ARGS}" + echo -n "qemu-system-x86_64 " + echo "${ARGS}" && echo fi set -m diff --git a/run/server.sh b/run/server.sh index e615992..1c5f58d 100644 --- a/run/server.sh +++ b/run/server.sh @@ -3,7 +3,7 @@ set -eu trap exit SIGINT SIGTERM # Close any previous instances -script_name=${BASH_SOURCE[0]} +script_name="${BASH_SOURCE[0]}" for pid in $(pidof -x "$script_name"); do if [ "$pid" != $$ ]; then @@ -13,7 +13,9 @@ for pid in $(pidof -x "$script_name"); do done # Serve the page -HTML="