mirror of
				https://github.com/vdsm/virtual-dsm.git
				synced 2025-11-04 08:54:51 +08:00 
			
		
		
		
	Minor changes
Minor changes
This commit is contained in:
		
						commit
						a086144cff
					
				@ -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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -2,14 +2,12 @@
 | 
			
		||||
set -eu
 | 
			
		||||
 | 
			
		||||
# Display wait message on port 5000
 | 
			
		||||
 | 
			
		||||
HTML="Please wait while Virtual DSM is installing...<script>\
 | 
			
		||||
        setTimeout(() => { document.location.reload(); }, 9999);</script>"
 | 
			
		||||
 | 
			
		||||
/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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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="<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}"
 | 
			
		||||
 | 
			
		||||
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