From 578d988c6b17ea6c5ebaf010b7e97376fb244ac9 Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 19 May 2023 16:29:24 +0200 Subject: [PATCH 1/8] Virtualization --- run/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run/run.sh b/run/run.sh index dbe98c0..2c9ce88 100755 --- a/run/run.sh +++ b/run/run.sh @@ -54,7 +54,7 @@ KVM_OPTS="" if [ -e /dev/kvm ] && sh -c 'echo -n > /dev/kvm' &> /dev/null; then if ! grep -q -e vmx -e svm /proc/cpuinfo; then - KVM_ERR="(cpuinfo $(grep -c -e vmx -e svm /proc/cpuinfo))" + KVM_ERR="(vmx/svm disabled)" fi else [ -e /dev/kvm ] && KVM_ERR="(no write access)" || KVM_ERR="(device file missing)" From 384a3ad04262ecd55686addf22609a86098fce4e Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 19 May 2023 16:50:51 +0200 Subject: [PATCH 2/8] KVM check --- run/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run/run.sh b/run/run.sh index 2c9ce88..519d052 100755 --- a/run/run.sh +++ b/run/run.sh @@ -62,7 +62,7 @@ fi if [ -n "${KVM_ERR}" ]; then error "KVM acceleration not detected ${KVM_ERR}, see the FAQ about this." - [[ "${DEBUG}" == [Yy1]* ]] && exit 88 + [[ "${DEBUG}" != [Yy1]* ]] && exit 88 else KVM_OPTS=",accel=kvm -enable-kvm -cpu host" fi From 192635de6b47c70f06e85daa9fcf11deca6dca5c Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 19 May 2023 16:54:14 +0200 Subject: [PATCH 3/8] Detect architecture --- run/run.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/run/run.sh b/run/run.sh index 519d052..94ba2e4 100755 --- a/run/run.sh +++ b/run/run.sh @@ -21,6 +21,7 @@ trap 'error "Status $? while: ${BASH_COMMAND} (line $LINENO/$BASH_LINENO)"' ERR STORAGE="/storage" KERNEL=$(uname -r | cut -b 1) +ARCH=$(dpkg --print-architecture) [ ! -d "$STORAGE" ] && error "Storage folder (${STORAGE}) not found!" && exit 13 From 6e36569b9ba03fdda218c1f00232c3816538aad8 Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 19 May 2023 17:14:18 +0200 Subject: [PATCH 4/8] Installation --- run/install.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/run/install.sh b/run/install.sh index 983779c..523fbe0 100644 --- a/run/install.sh +++ b/run/install.sh @@ -38,15 +38,17 @@ rm -rf "$TMP" && mkdir -p "$TMP" if [ ! -f "${RDC}" ]; then - RD="$TMP/rd.gz" info "Install: Downloading installer..." + + RD="$TMP/rd.gz" + POS="65627648-71021835" + VERIFY="b4215a4b213ff5154db0488f92c87864" LOC="$DL/release/7.0.1/42218/DSM_VirtualDSM_42218.pat" - { curl -r 65627648-71021835 -sfk -o "$RD" "$LOC"; rc=$?; } || : + { curl -r "$POS" -sfk -o "$RD" "$LOC"; rc=$?; } || : (( rc != 0 )) && error "Failed to download $LOC, reason: $rc" && exit 60 SUM=$(md5sum "$RD" | cut -f 1 -d " ") - VERIFY="b4215a4b213ff5154db0488f92c87864" if [ "$SUM" != "$VERIFY" ]; then @@ -57,7 +59,7 @@ if [ ! -f "${RDC}" ]; then { wget "$LOC" -O "$PAT" -q --no-check-certificate --show-progress "$PROGRESS"; rc=$?; } || : (( rc != 0 )) && error "Failed to download $LOC, reason: $rc" && exit 60 - tar --extract --file="$PAT" --directory="$TMP/." rd.gz + tar --extract --file="$PAT" --directory="$(dirname "${RD}")"/. "$(basename "${RD}")" rm "$PAT" fi @@ -66,10 +68,11 @@ if [ ! -f "${RDC}" ]; then fi -set +e -xz -dc <"$RDC" >"$TMP/rd" 2>/dev/null || true -(cd "$TMP" && cpio -idm <"$TMP/rd" 2>/dev/null) -set -e +{ xz -dc <"$RDC" >"$TMP/rd" 2>/dev/null; rc=$?; } || : +(( rc != 0 )) && error "Failed to extract $RDC" && exit 91 + +{ (cd "$TMP" && cpio -idm <"$TMP/rd" 2>/dev/null); rc=$?; } || : +(( rc != 0 )) && error "Failed to cpio $RDC" && exit 92 mkdir -p /run/extract for file in $TMP/usr/lib/libcurl.so.4 \ From 3cda109cf090f4108ac9532d3e208058c5cfe67a Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 19 May 2023 17:32:13 +0200 Subject: [PATCH 5/8] Extraction --- run/install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/run/install.sh b/run/install.sh index 523fbe0..b5d372d 100644 --- a/run/install.sh +++ b/run/install.sh @@ -42,7 +42,7 @@ if [ ! -f "${RDC}" ]; then RD="$TMP/rd.gz" POS="65627648-71021835" - VERIFY="b4215a4b213ff5154db0488f92c87864" + VERIFY="b4215a4b213ff5154db0488f92c87864" LOC="$DL/release/7.0.1/42218/DSM_VirtualDSM_42218.pat" { curl -r "$POS" -sfk -o "$RD" "$LOC"; rc=$?; } || : @@ -69,10 +69,10 @@ if [ ! -f "${RDC}" ]; then fi { xz -dc <"$RDC" >"$TMP/rd" 2>/dev/null; rc=$?; } || : -(( rc != 0 )) && error "Failed to extract $RDC" && exit 91 +(( rc > 1 )) && error "Failed to unxz $RDC, reason $rc" && exit 91 { (cd "$TMP" && cpio -idm <"$TMP/rd" 2>/dev/null); rc=$?; } || : -(( rc != 0 )) && error "Failed to cpio $RDC" && exit 92 +(( rc != 0 )) && error "Failed to cpio $RDC, reason $rc" && exit 92 mkdir -p /run/extract for file in $TMP/usr/lib/libcurl.so.4 \ From 052c65e257559bfc900c87bc922c98f81e3e604d Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 19 May 2023 17:39:37 +0200 Subject: [PATCH 6/8] Formatting --- run/install.sh | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/run/install.sh b/run/install.sh index b5d372d..0b427c2 100644 --- a/run/install.sh +++ b/run/install.sh @@ -143,13 +143,10 @@ SYSTEM_SIZE=4954537983 # Check free diskspace SPACE=$(df --output=avail -B 1 "$TMP" | tail -n 1) -if (( SYSTEM_SIZE > SPACE )); then - error "Not enough free space to create a 4 GB system disk." && exit 87 -fi +(( SYSTEM_SIZE > SPACE )) && error "Not enough free space to create a 4 GB system disk." && exit 87 if ! fallocate -l "${SYSTEM_SIZE}" "${SYSTEM}"; then - rm -f "${SYSTEM}" - error "Could not allocate a file for the system disk." && exit 88 + rm -f "${SYSTEM}" && error "Could not allocate a file for the system disk." && exit 88 fi if [[ "${ALLOCATE}" == [Zz]* ]]; then @@ -158,17 +155,11 @@ if [[ "${ALLOCATE}" == [Zz]* ]]; then fi # Check if file exists -if [ ! -f "${SYSTEM}" ]; then - error "System disk does not exist ($SYSTEM)" && exit 89 -fi +[ ! -f "${SYSTEM}" ] && error "System disk does not exist ($SYSTEM)" && exit 89 # Check the filesize SIZE=$(stat -c%s "${SYSTEM}") - -if [[ SIZE -ne SYSTEM_SIZE ]]; then - rm -f "${SYSTEM}" - error "System disk has the wrong size: ${SIZE}" && exit 90 -fi +[[ SIZE -ne SYSTEM_SIZE ]] && rm -f "${SYSTEM}" && error "System disk has the wrong size: ${SIZE}" && exit 90 PART="$TMP/partition.fdisk" @@ -189,7 +180,6 @@ info "Install: Extracting system partition..." MOUNT="$TMP/system" rm -rf "$MOUNT" && mkdir -p "$MOUNT" - mv -f "$HDA.tgz" "$HDA.txz" tar xpfJ "$HDP.txz" --absolute-names -C "$MOUNT/" From e260f2436ff579e4a96df1ff8595137e34e0ebfe Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 19 May 2023 17:50:21 +0200 Subject: [PATCH 7/8] Installation --- run/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run/install.sh b/run/install.sh index 0b427c2..3ddf6ce 100644 --- a/run/install.sh +++ b/run/install.sh @@ -69,7 +69,7 @@ if [ ! -f "${RDC}" ]; then fi { xz -dc <"$RDC" >"$TMP/rd" 2>/dev/null; rc=$?; } || : -(( rc > 1 )) && error "Failed to unxz $RDC, reason $rc" && exit 91 +(( rc != 1 )) && error "Failed to unxz $RDC, reason $rc" && exit 91 { (cd "$TMP" && cpio -idm <"$TMP/rd" 2>/dev/null); rc=$?; } || : (( rc != 0 )) && error "Failed to cpio $RDC, reason $rc" && exit 92 From 4d2f1119601fec5dda6a514e1e2ae29190baa8f8 Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 19 May 2023 18:30:50 +0200 Subject: [PATCH 8/8] CPU Model --- run/serial.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run/serial.sh b/run/serial.sh index 148178a..3af2e75 100644 --- a/run/serial.sh +++ b/run/serial.sh @@ -12,7 +12,7 @@ set -Eeuo pipefail : ${HOST_TIMESTAMP:=''} if [ -z "$HOST_CPU" ]; then - HOST_CPU=$(lscpu | sed -nr '/Model name/ s/.*:\s*(.*) @ .*/\1/p' | sed ':a;s/ / /;ta' | sed s/"(R)"//g | sed 's/[^[:alnum:] ]\+/ /g' | sed 's/ */ /g') + HOST_CPU=$(lscpu | grep 'Model name' | cut -f 2 -d ":" | awk '{$1=$1}1' | sed 's# @.*##g' | sed s/"(R)"//g | sed 's/[^[:alnum:] ]\+/ /g' | sed 's/ */ /g') fi if [ -n "$HOST_CPU" ]; then