mirror of
				https://github.com/vdsm/virtual-dsm.git
				synced 2025-11-04 17:04:52 +08:00 
			
		
		
		
	Minor changes
Minor changes
This commit is contained in:
		
						commit
						a086144cff
					
				@ -1,5 +1,5 @@
 | 
				
			|||||||
#!/usr/bin/env bash
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
set -eu
 | 
					set -u
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Docker Healthcheck
 | 
					# Docker Healthcheck
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -14,7 +14,6 @@ fi
 | 
				
			|||||||
IP=$(cat "${FILE}")
 | 
					IP=$(cat "${FILE}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if ! curl -m 3 -ILfSs "http://${IP}:${PORT}/" > /dev/null; then
 | 
					if ! curl -m 3 -ILfSs "http://${IP}:${PORT}/" > /dev/null; then
 | 
				
			||||||
  echo "Failed to reach ${IP}:${PORT}"
 | 
					 | 
				
			||||||
  exit 1
 | 
					  exit 1
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -37,6 +37,7 @@ if [ -f "${DATA}" ]; then
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    if [ "$ALLOCATE" = "N" ]; then
 | 
					    if [ "$ALLOCATE" = "N" ]; then
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      # Resize file by changing its length
 | 
				
			||||||
      truncate -s "${DATA_SIZE}" "${DATA}"; 
 | 
					      truncate -s "${DATA_SIZE}" "${DATA}"; 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
@ -51,6 +52,7 @@ if [ -f "${DATA}" ]; then
 | 
				
			|||||||
        echo "ERROR: Specify a smaller size or disable preallocation with ALLOCATE=N." && exit 84
 | 
					        echo "ERROR: Specify a smaller size or disable preallocation with ALLOCATE=N." && exit 84
 | 
				
			||||||
      fi
 | 
					      fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      # Resize file by allocating more space
 | 
				
			||||||
      if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then
 | 
					      if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then
 | 
				
			||||||
        echo "ERROR: Could not allocate a file for the virtual disk." && exit 85
 | 
					        echo "ERROR: Could not allocate a file for the virtual disk." && exit 85
 | 
				
			||||||
      fi
 | 
					      fi
 | 
				
			||||||
@ -78,10 +80,9 @@ fi
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
if [ ! -f "${DATA}" ]; then
 | 
					if [ ! -f "${DATA}" ]; then
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # Create an empty file
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if [ "$ALLOCATE" = "N" ]; then
 | 
					  if [ "$ALLOCATE" = "N" ]; then
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Create an empty file
 | 
				
			||||||
    truncate -s "${DATA_SIZE}" "${DATA}"
 | 
					    truncate -s "${DATA_SIZE}" "${DATA}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
@ -94,6 +95,7 @@ if [ ! -f "${DATA}" ]; then
 | 
				
			|||||||
      echo "ERROR: Specify a smaller size or disable preallocation with ALLOCATE=N." && exit 86
 | 
					      echo "ERROR: Specify a smaller size or disable preallocation with ALLOCATE=N." && exit 86
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Create an empty file
 | 
				
			||||||
    if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then
 | 
					    if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then
 | 
				
			||||||
      rm -f "${DATA}"
 | 
					      rm -f "${DATA}"
 | 
				
			||||||
      echo "ERROR: Could not allocate a file for the virtual disk." && exit 87
 | 
					      echo "ERROR: Could not allocate a file for the virtual disk." && exit 87
 | 
				
			||||||
 | 
				
			|||||||
@ -2,14 +2,12 @@
 | 
				
			|||||||
set -eu
 | 
					set -eu
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Display wait message on port 5000
 | 
					# Display wait message on port 5000
 | 
				
			||||||
 | 
					 | 
				
			||||||
HTML="Please wait while Virtual DSM is installing...<script>\
 | 
					HTML="Please wait while Virtual DSM is installing...<script>\
 | 
				
			||||||
        setTimeout(() => { document.location.reload(); }, 9999);</script>"
 | 
					        setTimeout(() => { document.location.reload(); }, 9999);</script>"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/run/server.sh 5000 "${HTML}" > /dev/null &
 | 
					/run/server.sh 5000 "${HTML}" > /dev/null &
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Download the required files from the Synology website
 | 
					# Download the required files from the Synology website
 | 
				
			||||||
 | 
					 | 
				
			||||||
DL="https://global.synologydownload.com/download/DSM"
 | 
					DL="https://global.synologydownload.com/download/DSM"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ -z "$URL" ]; then
 | 
					if [ -z "$URL" ]; then
 | 
				
			||||||
 | 
				
			|||||||
@ -159,7 +159,8 @@ configureNAT () {
 | 
				
			|||||||
    [[ -z $(hostname -d) ]] || DNSMASQ_OPTS="$DNSMASQ_OPTS --dhcp-option=option:domain-name,$(hostname -d)"
 | 
					    [[ -z $(hostname -d) ]] || DNSMASQ_OPTS="$DNSMASQ_OPTS --dhcp-option=option:domain-name,$(hostname -d)"
 | 
				
			||||||
  fi
 | 
					  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}
 | 
					  $DNSMASQ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -185,9 +186,9 @@ GATEWAY=$(ip r | grep default | awk '{print $3}')
 | 
				
			|||||||
if [ "$DEBUG" = "Y" ]; then
 | 
					if [ "$DEBUG" = "Y" ]; then
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  IP=$(ip address show dev "${VM_NET_DEV}" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/)
 | 
					  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}"
 | 
					  echo "Info: Container IP is ${IP} with gateway ${GATEWAY}" && echo
 | 
				
			||||||
  ifconfig
 | 
					  ifconfig && echo
 | 
				
			||||||
  ip route
 | 
					  ip route && echo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -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')
 | 
					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"
 | 
					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"
 | 
					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="${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
 | 
					if [ "$DEBUG" = "Y" ]; then
 | 
				
			||||||
  echo && echo -n "qemu-system-x86_64 "
 | 
					  echo -n "qemu-system-x86_64 "
 | 
				
			||||||
  echo "${ARGS}"
 | 
					  echo "${ARGS}" && echo
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set -m
 | 
					set -m
 | 
				
			||||||
 | 
				
			|||||||
@ -3,7 +3,7 @@ set -eu
 | 
				
			|||||||
trap exit SIGINT SIGTERM
 | 
					trap exit SIGINT SIGTERM
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Close any previous instances
 | 
					# Close any previous instances
 | 
				
			||||||
script_name=${BASH_SOURCE[0]}
 | 
					script_name="${BASH_SOURCE[0]}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
for pid in $(pidof -x "$script_name"); do
 | 
					for pid in $(pidof -x "$script_name"); do
 | 
				
			||||||
  if [ "$pid" != $$ ]; then
 | 
					  if [ "$pid" != $$ ]; then
 | 
				
			||||||
@ -13,7 +13,9 @@ for pid in $(pidof -x "$script_name"); do
 | 
				
			|||||||
done
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Serve the page
 | 
					# Serve the page
 | 
				
			||||||
HTML="<HTML><HEAD><STYLE>body {  color: white; background-color: #00BFFF; } </STYLE></HEAD><BODY><BR><BR><H1><CENTER>$2</CENTER></H1></BODY></HTML>"
 | 
					HTML="<HTML><HEAD><STYLE>body {  color: white; background-color: #00BFFF; }</STYLE>\
 | 
				
			||||||
 | 
					              </HEAD><BODY><BR><BR><H1><CENTER>$2</CENTER></H1></BODY></HTML>"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
LENGTH="${#HTML}"
 | 
					LENGTH="${#HTML}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RESPONSE="HTTP/1.1 200 OK\nContent-Length: ${LENGTH}\nConnection: close\n\n$HTML\n\n"
 | 
					RESPONSE="HTTP/1.1 200 OK\nContent-Length: ${LENGTH}\nConnection: close\n\n$HTML\n\n"
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user