mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2026-08-29 12:17:07 +00:00
feat: Normalize boolean option handling (#1191)
This commit is contained in:
+13
-13
@@ -110,7 +110,7 @@ createDisk() {
|
||||
|
||||
DATA_SIZE=$(numfmt --from=iec "$DISK_SPACE")
|
||||
|
||||
if [[ "$ALLOCATE" != [Nn]* ]]; then
|
||||
if ! disabled "$ALLOCATE"; then
|
||||
|
||||
# Check free diskspace
|
||||
DIR=$(dirname "$DISK_FILE")
|
||||
@@ -139,7 +139,7 @@ createDisk() {
|
||||
{ chattr +C "$DISK_FILE"; } || :
|
||||
fi
|
||||
|
||||
if [[ "$ALLOCATE" == [Nn]* ]]; then
|
||||
if disabled "$ALLOCATE"; then
|
||||
|
||||
# Create an empty file
|
||||
if ! truncate -s "$DATA_SIZE" "$DISK_FILE"; then
|
||||
@@ -198,7 +198,7 @@ resizeDisk() {
|
||||
local REQ=$(( DATA_SIZE - CUR_SIZE ))
|
||||
(( REQ < 1 )) && error "Shrinking disks is not supported yet, please increase ${DISK_DESC^^}_SIZE." && exit 71
|
||||
|
||||
if [[ "$ALLOCATE" != [Nn]* ]]; then
|
||||
if ! disabled "$ALLOCATE"; then
|
||||
|
||||
# Check free diskspace
|
||||
DIR=$(dirname "$DISK_FILE")
|
||||
@@ -221,7 +221,7 @@ resizeDisk() {
|
||||
case "${DISK_FMT,,}" in
|
||||
raw)
|
||||
|
||||
if [[ "$ALLOCATE" == [Nn]* ]]; then
|
||||
if disabled "$ALLOCATE"; then
|
||||
|
||||
# Resize file by changing its length
|
||||
if ! truncate -s "$DATA_SIZE" "$DISK_FILE"; then
|
||||
@@ -272,7 +272,7 @@ convertDisk() {
|
||||
local DIR FA
|
||||
DIR=$(dirname "$TMP_FILE")
|
||||
|
||||
if [[ "$ALLOCATE" != [Nn]* ]]; then
|
||||
if ! disabled "$ALLOCATE"; then
|
||||
|
||||
local CUR_SIZE SPACE GB
|
||||
|
||||
@@ -297,7 +297,7 @@ convertDisk() {
|
||||
isCow "$FS" && DISK_PARAM+=",nocow=on"
|
||||
|
||||
if [[ "$DST_FMT" != "raw" ]]; then
|
||||
if [[ "$ALLOCATE" == [Nn]* ]]; then
|
||||
if disabled "$ALLOCATE"; then
|
||||
CONV_FLAGS+=" -c"
|
||||
fi
|
||||
[ -n "$DISK_FLAGS" ] && DISK_PARAM+=",$DISK_FLAGS"
|
||||
@@ -310,7 +310,7 @@ convertDisk() {
|
||||
fi
|
||||
|
||||
if [[ "$DST_FMT" == "raw" ]]; then
|
||||
if [[ "$ALLOCATE" != [Nn]* ]]; then
|
||||
if ! disabled "$ALLOCATE"; then
|
||||
# Work around qemu-img bug
|
||||
CUR_SIZE=$(stat -c%s "$TMP_FILE")
|
||||
if ! fallocate -l "$CUR_SIZE" "$TMP_FILE" &>/dev/null; then
|
||||
@@ -433,7 +433,7 @@ finishDisks () {
|
||||
DISK_OPTS+=" -object iothread,id=io2" ;;
|
||||
esac
|
||||
|
||||
if [[ "$DISK_DISABLE" != [Yy1]* ]]; then
|
||||
if ! enabled "$DISK_DISABLE"; then
|
||||
html "Initialized disks successfully..."
|
||||
fi
|
||||
|
||||
@@ -540,7 +540,7 @@ addDisk () {
|
||||
|
||||
fi
|
||||
|
||||
if [ -f "$DISK_FILE" ] && [[ "$ALLOCATE" == [Nn]* ]]; then
|
||||
if [ -f "$DISK_FILE" ] && disabled "$ALLOCATE"; then
|
||||
|
||||
CUR_SIZE=$(getSize "$DISK_FILE")
|
||||
USED=$(du -sB 1 "$DISK_FILE" | cut -f1)
|
||||
@@ -619,10 +619,10 @@ addDevice () {
|
||||
[ -z "${DISK_NAME:-}" ] && DISK_NAME="data"
|
||||
[ -z "${DISK_DISABLE:-}" ] && DISK_DISABLE=""
|
||||
|
||||
if [[ "$DISK_DISABLE" != [Yy1]* ]]; then
|
||||
if ! enabled "$DISK_DISABLE"; then
|
||||
msg="Initializing disks..."
|
||||
html "$msg"
|
||||
[[ "$DEBUG" == [Yy1]* ]] && echo "$msg"
|
||||
enabled "$DEBUG" && echo "$msg"
|
||||
fi
|
||||
|
||||
case "${DISK_TYPE,,}" in
|
||||
@@ -634,7 +634,7 @@ if [ -z "$ALLOCATE" ]; then
|
||||
ALLOCATE="N"
|
||||
fi
|
||||
|
||||
if [[ "$ALLOCATE" == [Nn]* ]]; then
|
||||
if disabled "$ALLOCATE"; then
|
||||
DISK_STYLE="growable"
|
||||
DISK_ALLOC="preallocation=off"
|
||||
else
|
||||
@@ -645,7 +645,7 @@ fi
|
||||
DISK_OPTS+=$(createDevice "$BOOT" "$DISK_TYPE" "1" "0xa" "raw" "$DISK_IO" "$DISK_CACHE" "" "")
|
||||
DISK_OPTS+=$(createDevice "$SYSTEM" "$DISK_TYPE" "2" "0xb" "raw" "$DISK_IO" "$DISK_CACHE" "" "")
|
||||
|
||||
if [[ "$DISK_DISABLE" == [Yy1]* ]]; then
|
||||
if enabled "$DISK_DISABLE"; then
|
||||
finishDisks
|
||||
return 0
|
||||
fi
|
||||
|
||||
+2
-2
@@ -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 ! enabled "$GPU" || [[ "$CPU_VENDOR" != "GenuineIntel" || "$ARCH" != "amd64" ]]; then
|
||||
|
||||
[[ "${DISPLAY,,}" == "none" ]] && VGA="none"
|
||||
DISPLAY_OPTS="-display $DISPLAY -vga $VGA"
|
||||
@@ -20,7 +20,7 @@ fi
|
||||
|
||||
msg="Configuring display drivers..."
|
||||
html "$msg"
|
||||
[[ "$DEBUG" == [Yy1]* ]] && echo "$msg"
|
||||
enabled "$DEBUG" && echo "$msg"
|
||||
|
||||
DISPLAY_OPTS="-display egl-headless,rendernode=$RENDERNODE"
|
||||
DISPLAY_OPTS+=" -vga $VGA"
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ cmd=(qemu-system-x86_64)
|
||||
version=$("${cmd[@]}" --version | awk 'NR==1 { print $4 }')
|
||||
info "Booting $APP using QEMU v$version..."
|
||||
|
||||
if [[ "$SHUTDOWN" != [Yy1]* ]]; then
|
||||
if ! enabled "$SHUTDOWN"; then
|
||||
exec "${cmd[@]}" ${ARGS:+ $ARGS}
|
||||
fi
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
if [[ "$DEBUG" == [Yy1]* ]]; then
|
||||
if enabled "$DEBUG"; then
|
||||
printf "QEMU arguments:\n\n%s\n\n" "${ARGS// -/$'\n-'}"
|
||||
fi
|
||||
|
||||
|
||||
+2
-2
@@ -2,12 +2,12 @@
|
||||
set -Eeuo pipefail
|
||||
|
||||
msg="Checking memory..."
|
||||
[[ "$DEBUG" == [Yy1]* ]] && echo "$msg"
|
||||
enabled "$DEBUG" && echo "$msg"
|
||||
|
||||
RAM_AVAIL=$(free -b | grep -m 1 Mem: | awk '{print $7}')
|
||||
AVAIL_MEM=$(formatBytes "$RAM_AVAIL")
|
||||
|
||||
if [[ "$RAM_CHECK" != [Nn]* && "${RAM_SIZE,,}" != "max" && "${RAM_SIZE,,}" != "half" ]]; then
|
||||
if ! disabled "$RAM_CHECK" && [[ "${RAM_SIZE,,}" != "max" && "${RAM_SIZE,,}" != "half" ]]; then
|
||||
|
||||
wanted=$(numfmt --from=iec "$RAM_SIZE")
|
||||
|
||||
|
||||
+32
-32
@@ -40,7 +40,7 @@ ADD_ERR="Please add the following setting to your container:"
|
||||
|
||||
configureDHCP() {
|
||||
|
||||
[[ "$DEBUG" == [Yy1]* ]] && echo "Configuring MACVTAP networking..."
|
||||
enabled "$DEBUG" && echo "Configuring MACVTAP networking..."
|
||||
|
||||
# Create the necessary file structure for /dev/vhost-net
|
||||
if [ ! -c /dev/vhost-net ]; then
|
||||
@@ -128,8 +128,8 @@ configureDNS() {
|
||||
|
||||
echo "$gateway" > /run/shm/qemu.gw
|
||||
|
||||
[[ "${DNSMASQ_DISABLE:-}" == [Yy1]* ]] && return 0
|
||||
[[ "$DEBUG" == [Yy1]* ]] && echo "Starting dnsmasq daemon..."
|
||||
enabled "${DNSMASQ_DISABLE:-}" && return 0
|
||||
enabled "$DEBUG" && echo "Starting dnsmasq daemon..."
|
||||
|
||||
[ -s "$DNSMASQ_PID" ] && pKill "$(<"$DNSMASQ_PID")"
|
||||
rm -f "$DNSMASQ_PID"
|
||||
@@ -174,7 +174,7 @@ configureDNS() {
|
||||
arguments+=" --log-facility=$log"
|
||||
|
||||
arguments=$(echo "$arguments" | sed 's/\t/ /g' | tr -s ' ' | sed 's/^ *//')
|
||||
[[ "$DEBUG" == [Yy1]* ]] && printf "Dnsmasq arguments:\n\n%s\n\n" "${arguments// -/$'\n-'}"
|
||||
enabled "$DEBUG" && printf "Dnsmasq arguments:\n\n%s\n\n" "${arguments// -/$'\n-'}"
|
||||
|
||||
{ $DNSMASQ ${arguments:+ $arguments}; rc=$?; } || :
|
||||
|
||||
@@ -182,7 +182,7 @@ configureDNS() {
|
||||
|
||||
local msg="Failed to start Dnsmasq, reason: $rc"
|
||||
|
||||
if [[ "${NETWORK,,}" == "slirp" || "${NETWORK,,}" == "passt" || "$ROOTLESS" != [Yy1]* || "$DEBUG" == [Yy1]* ]]; then
|
||||
if [[ "${NETWORK,,}" == "slirp" || "${NETWORK,,}" == "passt" ]] || ! enabled "$ROOTLESS" || enabled "$DEBUG"; then
|
||||
[ -f "$log" ] && [ -s "$log" ] && cat "$log"
|
||||
error "$msg"
|
||||
fi
|
||||
@@ -190,7 +190,7 @@ configureDNS() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ "$DNSMASQ_DEBUG" == [Yy1]* ]]; then
|
||||
if enabled "$DNSMASQ_DEBUG"; then
|
||||
tail -fn +0 "$log" --pid=$$ &
|
||||
fi
|
||||
|
||||
@@ -284,7 +284,7 @@ getSlirp() {
|
||||
configureSlirp() {
|
||||
|
||||
NETWORK="slirp"
|
||||
[[ "$DEBUG" == [Yy1]* ]] && echo "Configuring slirp networking..."
|
||||
enabled "$DEBUG" && echo "Configuring slirp networking..."
|
||||
|
||||
local ip="$IP"
|
||||
[ -n "$VM_NET_IP" ] && ip="$VM_NET_IP"
|
||||
@@ -301,7 +301,7 @@ configureSlirp() {
|
||||
forward=$(getSlirp "$ip")
|
||||
[ -n "$forward" ] && NET_OPTS+=",$forward"
|
||||
|
||||
if [[ "${DNSMASQ_DISABLE:-}" == [Yy1]* ]]; then
|
||||
if enabled "${DNSMASQ_DISABLE:-}"; then
|
||||
echo "$gateway" > /run/shm/qemu.gw
|
||||
else
|
||||
[ ! -f /etc/resolv.dnsmasq ] && cp /etc/resolv.conf /etc/resolv.dnsmasq
|
||||
@@ -319,7 +319,7 @@ configureSlirp() {
|
||||
configurePasst() {
|
||||
|
||||
NETWORK="passt"
|
||||
[[ "$DEBUG" == [Yy1]* ]] && echo "Configuring user-mode networking..."
|
||||
enabled "$DEBUG" && echo "Configuring user-mode networking..."
|
||||
|
||||
local log="/tmp/passt.log"
|
||||
rm -f "$log"
|
||||
@@ -360,7 +360,7 @@ configurePasst() {
|
||||
PASST_OPTS+=" -l $log"
|
||||
PASST_OPTS+=" -q"
|
||||
|
||||
if [[ "${DNSMASQ_DISABLE:-}" != [Yy1]* ]]; then
|
||||
if ! enabled "${DNSMASQ_DISABLE:-}"; then
|
||||
[ ! -f /etc/resolv.dnsmasq ] && cp /etc/resolv.conf /etc/resolv.dnsmasq
|
||||
printf '%s\n' \
|
||||
'nameserver 127.0.0.1' \
|
||||
@@ -370,7 +370,7 @@ configurePasst() {
|
||||
|
||||
PASST_OPTS=$(echo "$PASST_OPTS" | sed 's/\t/ /g' | tr -s ' ' | sed 's/^ *//')
|
||||
|
||||
if [[ "$DEBUG" == [Yy1]* || "$PASST_DEBUG" == [Yy1]* ]]; then
|
||||
if enabled "$DEBUG" || enabled "$PASST_DEBUG"; then
|
||||
printf "Passt arguments:\n\n%s\n\n" "${PASST_OPTS// -/$'\n-'}"
|
||||
fi
|
||||
|
||||
@@ -390,10 +390,10 @@ configurePasst() {
|
||||
|
||||
fi
|
||||
|
||||
if [[ "$PASST_DEBUG" == [Yy1]* ]]; then
|
||||
if enabled "$PASST_DEBUG"; then
|
||||
tail -fn +0 "$log" --pid=$$ &
|
||||
else
|
||||
if [[ "$DEBUG" == [Yy1]* ]]; then
|
||||
if enabled "$DEBUG"; then
|
||||
[ -f "$log" ] && [ -s "$log" ] && cat "$log" && echo ""
|
||||
fi
|
||||
fi
|
||||
@@ -447,7 +447,7 @@ configureNAT() {
|
||||
local tuntap="TUN device is missing. $ADD_ERR --device /dev/net/tun"
|
||||
local tables="the 'ip_tables' kernel module is not loaded. Try this command: sudo modprobe ip_tables iptable_nat"
|
||||
|
||||
[[ "$DEBUG" == [Yy1]* ]] && echo "Configuring NAT networking..."
|
||||
enabled "$DEBUG" && echo "Configuring NAT networking..."
|
||||
|
||||
# Create the necessary file structure for /dev/net/tun
|
||||
if [ ! -c /dev/net/tun ]; then
|
||||
@@ -458,7 +458,7 @@ configureNAT() {
|
||||
fi
|
||||
|
||||
if [ ! -c /dev/net/tun ]; then
|
||||
[[ "$ROOTLESS" == [Yy1]* && "$DEBUG" != [Yy1]* ]] && return 1
|
||||
enabled "$ROOTLESS" && ! enabled "$DEBUG" && return 1
|
||||
warn "$tuntap" && return 1
|
||||
fi
|
||||
|
||||
@@ -466,7 +466,7 @@ configureNAT() {
|
||||
if [[ $(< /proc/sys/net/ipv4/ip_forward) -eq 0 ]]; then
|
||||
{ sysctl -w net.ipv4.ip_forward=1 > /dev/null 2>&1; rc=$?; } || :
|
||||
if (( rc != 0 )) || [[ $(< /proc/sys/net/ipv4/ip_forward) -eq 0 ]]; then
|
||||
[[ "$ROOTLESS" == [Yy1]* && "$DEBUG" != [Yy1]* ]] && return 1
|
||||
enabled "$ROOTLESS" && ! enabled "$DEBUG" && return 1
|
||||
warn "IP forwarding is disabled. $ADD_ERR --sysctl net.ipv4.ip_forward=1"
|
||||
return 1
|
||||
fi
|
||||
@@ -496,7 +496,7 @@ configureNAT() {
|
||||
{ ip link add dev "$VM_NET_BRIDGE" type bridge ; rc=$?; } || :
|
||||
|
||||
if (( rc != 0 )); then
|
||||
[[ "$ROOTLESS" == [Yy1]* && "$DEBUG" != [Yy1]* ]] && return 1
|
||||
enabled "$ROOTLESS" && ! enabled "$DEBUG" && return 1
|
||||
warn "failed to create bridge. $ADD_ERR --cap-add NET_ADMIN" && return 1
|
||||
fi
|
||||
|
||||
@@ -511,7 +511,7 @@ configureNAT() {
|
||||
|
||||
# Set tap to the bridge created
|
||||
if ! ip tuntap add dev "$VM_NET_TAP" mode tap; then
|
||||
[[ "$ROOTLESS" == [Yy1]* && "$DEBUG" != [Yy1]* ]] && return 1
|
||||
enabled "$ROOTLESS" && ! enabled "$DEBUG" && return 1
|
||||
warn "$tuntap" && return 1
|
||||
fi
|
||||
|
||||
@@ -549,7 +549,7 @@ configureNAT() {
|
||||
|
||||
# NAT traffic from bridge subnet to Docker uplink
|
||||
if ! iptables -t nat -A POSTROUTING -o "$VM_NET_DEV" -s "$subnet" ! -d "$subnet" -m comment --comment "remove" -j MASQUERADE > /dev/null 2>&1; then
|
||||
[[ "$ROOTLESS" == [Yy1]* && "$DEBUG" != [Yy1]* ]] && return 1
|
||||
enabled "$ROOTLESS" && ! enabled "$DEBUG" && return 1
|
||||
if ! iptables -t nat -A POSTROUTING -o "$VM_NET_DEV" -s "$subnet" ! -d "$subnet" -m comment --comment "remove" -j MASQUERADE; then
|
||||
warn "$tables" && return 1
|
||||
fi
|
||||
@@ -619,11 +619,11 @@ closeWeb() {
|
||||
|
||||
closeNetwork() {
|
||||
|
||||
if [[ "${WEB:-}" != [Nn]* && "$DHCP" == [Yy1]* ]]; then
|
||||
if ! disabled "${WEB:-}" && enabled "$DHCP"; then
|
||||
closeWeb
|
||||
fi
|
||||
|
||||
[[ "$NETWORK" == [Nn]* ]] && return 0
|
||||
disabled "$NETWORK" && return 0
|
||||
|
||||
exec 30<&- || true
|
||||
exec 40<&- || true
|
||||
@@ -655,7 +655,7 @@ checkOS() {
|
||||
[[ "${kernel,,}" == *"darwin"* ]] && os="$ENGINE Desktop for macOS"
|
||||
[[ "${kernel,,}" == *"microsoft"* ]] && os="$ENGINE Desktop for Windows"
|
||||
|
||||
if [[ "$DHCP" == [Yy1]* ]]; then
|
||||
if enabled "$DHCP"; then
|
||||
iface="macvtap"
|
||||
[[ "${kernel,,}" == *"synology"* ]] && os="Synology Container Manager"
|
||||
fi
|
||||
@@ -687,7 +687,7 @@ getInfo() {
|
||||
|
||||
GATEWAY=$(ip route list dev "$VM_NET_DEV" | awk ' /^default/ {print $3}' | head -n 1)
|
||||
{ IP=$(ip address show dev "$VM_NET_DEV" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/ | head -n 1); } 2>/dev/null || :
|
||||
[ -z "$IP" ] && [[ "$DHCP" != [Yy1]* ]] && error "Could not determine container IPv4 address!" && exit 26
|
||||
[ -z "$IP" ] && ! enabled "$DHCP" && error "Could not determine container IPv4 address!" && exit 26
|
||||
|
||||
IP6=""
|
||||
# shellcheck disable=SC2143
|
||||
@@ -703,12 +703,12 @@ getInfo() {
|
||||
bus=$(grep -m 1 -i 'bus-info:' <<< "$result" | awk '{print $2}')
|
||||
|
||||
if [[ "${bus,,}" != "" && "${bus,,}" != "n/a" && "${bus,,}" != "tap" ]]; then
|
||||
[[ "$DEBUG" == [Yy1]* ]] && info "Detected BUS: $bus"
|
||||
enabled "$DEBUG" && info "Detected BUS: $bus"
|
||||
error "This container does not support host mode networking!"
|
||||
exit 29
|
||||
fi
|
||||
|
||||
if [[ "$DHCP" == [Yy1]* ]]; then
|
||||
if enabled "$DHCP"; then
|
||||
|
||||
checkOS
|
||||
|
||||
@@ -718,7 +718,7 @@ getInfo() {
|
||||
fi
|
||||
|
||||
if [[ "${nic,,}" != "macvlan" ]]; then
|
||||
[[ "$DEBUG" == [Yy1]* ]] && info "Detected NIC: $nic"
|
||||
enabled "$DEBUG" && info "Detected NIC: $nic"
|
||||
error "The container needs to be in a MACVLAN network when DHCP=Y."
|
||||
exit 29
|
||||
fi
|
||||
@@ -786,7 +786,7 @@ getInfo() {
|
||||
|
||||
GATEWAY_MAC=$(echo "$VM_NET_MAC" | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/')
|
||||
|
||||
if [[ "$DEBUG" == [Yy1]* ]]; then
|
||||
if enabled "$DEBUG"; then
|
||||
line="Host: $HOST IP: $IP Gateway: $GATEWAY Interface: $VM_NET_DEV MAC: $VM_NET_MAC MTU: $mtu"
|
||||
[[ "$MTU" != "0" && "$MTU" != "$mtu" ]] && line+=" ($MTU)"
|
||||
info "$line"
|
||||
@@ -807,14 +807,14 @@ getInfo() {
|
||||
# Configure Network
|
||||
# ######################################
|
||||
|
||||
if [[ "$NETWORK" == [Nn]* ]]; then
|
||||
if disabled "$NETWORK"; then
|
||||
NET_OPTS=""
|
||||
return 0
|
||||
fi
|
||||
|
||||
msg="Initializing network..."
|
||||
html "$msg"
|
||||
[[ "$DEBUG" == [Yy1]* ]] && echo "$msg"
|
||||
enabled "$DEBUG" && echo "$msg"
|
||||
|
||||
getInfo
|
||||
cleanUp
|
||||
@@ -826,14 +826,14 @@ fi
|
||||
MSG="Booting DSM instance..."
|
||||
html "$MSG"
|
||||
|
||||
if [[ "$DHCP" == [Yy1]* ]]; then
|
||||
if enabled "$DHCP"; then
|
||||
|
||||
# Configure for macvtap interface
|
||||
configureDHCP || exit 20
|
||||
|
||||
else
|
||||
|
||||
if [[ "${WEB:-}" != [Nn]* ]]; then
|
||||
if ! disabled "${WEB:-}"; then
|
||||
sleep 1.2
|
||||
closeWeb
|
||||
fi
|
||||
@@ -848,7 +848,7 @@ else
|
||||
closeBridge
|
||||
NETWORK="user"
|
||||
|
||||
if [[ "$ROOTLESS" != [Yy1]* || "$DEBUG" == [Yy1]* ]]; then
|
||||
if ! enabled "$ROOTLESS" || enabled "$DEBUG"; then
|
||||
msg="falling back to user-mode networking!"
|
||||
msg="failed to setup NAT networking, $msg"
|
||||
warn "$msg"
|
||||
|
||||
+2
-2
@@ -168,7 +168,7 @@ graceful_shutdown() {
|
||||
if (( cnt == sigterm_at )); then
|
||||
info "${name^} is still running, sending SIGTERM... ($cnt/$wait_until)"
|
||||
kill -15 -- "$pid" 2>/dev/null || :
|
||||
elif (( cnt > 0 )) && [[ "${DEBUG:-}" == [Yy1]* ]]; then
|
||||
elif (( cnt > 0 )) && enabled "${DEBUG:-}"; then
|
||||
info "Waiting for $name to shut down... ($cnt/$wait_until)"
|
||||
fi
|
||||
|
||||
@@ -180,7 +180,7 @@ graceful_shutdown() {
|
||||
finish "$code"
|
||||
}
|
||||
|
||||
[[ "$SHUTDOWN" != [Yy1]* ]] && return 0
|
||||
! enabled "$SHUTDOWN" && return 0
|
||||
[ -n "${QEMU_TIMEOUT:-}" ] && TIMEOUT="$QEMU_TIMEOUT"
|
||||
|
||||
_trap graceful_shutdown SIGTERM SIGHUP SIGABRT SIGQUIT
|
||||
|
||||
+2
-2
@@ -27,14 +27,14 @@ fi
|
||||
|
||||
flags=$(sed -ne '/^flags/s/^.*: //p' /proc/cpuinfo)
|
||||
|
||||
if [[ "$KVM" != [Nn]* ]]; then
|
||||
if ! disabled "$KVM"; then
|
||||
|
||||
CPU_FEATURES="kvm=on,l3-cache=on,+hypervisor"
|
||||
KVM_OPTS=",accel=kvm -enable-kvm -global kvm-pit.lost_tick_policy=discard"
|
||||
|
||||
if ! grep -qw "sse4_2" <<< "$flags"; then
|
||||
error "Your CPU does not have the SSE4 instruction set that Virtual DSM requires!"
|
||||
[[ "$DEBUG" != [Yy1]* ]] && exit 88
|
||||
! enabled "$DEBUG" && exit 88
|
||||
fi
|
||||
|
||||
if [ -z "$CPU_MODEL" ]; then
|
||||
|
||||
+5
-5
@@ -2,7 +2,7 @@
|
||||
set -Eeuo pipefail
|
||||
|
||||
trap 'error "Status $? while: $BASH_COMMAND (line $LINENO/$BASH_LINENO)"' ERR
|
||||
[[ "${TRACE:-}" == [Yy1]* ]] && set -o functrace && trap 'echo "# $BASH_COMMAND" >&2' DEBUG
|
||||
enabled "${TRACE:-}" && set -o functrace && trap 'echo "# $BASH_COMMAND" >&2' DEBUG
|
||||
|
||||
[ ! -f "/run/entry.sh" ] && error "Script must be run inside the container!" && exit 11
|
||||
[ "$(id -u)" -ne "0" ] && error "Script must be executed with root privileges." && exit 12
|
||||
@@ -169,7 +169,7 @@ else
|
||||
TARGET="arm64"
|
||||
fi
|
||||
|
||||
if [[ "$KVM" == [Nn]* ]]; then
|
||||
if disabled "$KVM"; then
|
||||
warn "KVM acceleration is disabled, this will cause the machine to run about 10 times slower!"
|
||||
else
|
||||
if [[ "${ARCH,,}" != "$TARGET" ]]; then
|
||||
@@ -178,7 +178,7 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$KVM" != [Nn]* ]]; then
|
||||
if ! disabled "$KVM"; then
|
||||
|
||||
KVM_ERR=""
|
||||
|
||||
@@ -195,7 +195,7 @@ if [[ "$KVM" != [Nn]* ]]; then
|
||||
fi
|
||||
if ! grep -qw "sse4_2" <<< "$flags"; then
|
||||
error "Your CPU does not have the SSE4 instruction set that Virtual DSM requires!"
|
||||
[[ "$DEBUG" != [Yy1]* ]] && exit 88
|
||||
! enabled "$DEBUG" && exit 88
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@@ -216,7 +216,7 @@ if [[ "$KVM" != [Nn]* ]]; then
|
||||
error "KVM acceleration is not available $KVM_ERR, this will cause the machine to run about 10 times slower."
|
||||
error "See the FAQ for possible causes, or disable acceleration by adding the \"KVM=N\" variable (not recommended)." ;;
|
||||
esac
|
||||
[[ "$DEBUG" != [Yy1]* ]] && exit 88
|
||||
! enabled "$DEBUG" && exit 88
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ HOST_ARGS+=("-cpu_arch=$HOST_CPU")
|
||||
[ -n "$HOST_SERIAL" ] && HOST_ARGS+=("-hostsn=$HOST_SERIAL")
|
||||
[ -n "$GUEST_SERIAL" ] && HOST_ARGS+=("-guestsn=$GUEST_SERIAL")
|
||||
|
||||
if [[ "$HOST_DEBUG" == [Yy1]* ]]; then
|
||||
if enabled "$HOST_DEBUG"; then
|
||||
set -x
|
||||
./host.bin "${HOST_ARGS[@]}" &
|
||||
{ set +x; } 2>/dev/null
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ rm -f "$WSD_PID" "$WEB_PID"
|
||||
|
||||
html "Starting $APP for $ENGINE..."
|
||||
|
||||
if [[ "${WEB:-}" != [Nn]* ]]; then
|
||||
if ! disabled "${WEB:-}"; then
|
||||
|
||||
mkdir -p /etc/nginx/sites-enabled
|
||||
cp /etc/nginx/default.conf /etc/nginx/sites-enabled/web.conf
|
||||
|
||||
+1
-1
@@ -292,7 +292,7 @@ cpu() {
|
||||
|
||||
hasDisk() {
|
||||
|
||||
[[ "${DISK_DISABLE:-}" == [Yy1]* ]] && return 1
|
||||
enabled "${DISK_DISABLE:-}" && return 1
|
||||
|
||||
[ -b "/disk" ] && return 0
|
||||
[ -b "/disk1" ] && return 0
|
||||
|
||||
Reference in New Issue
Block a user