Storage
This commit is contained in:
Kroese 2023-04-16 16:24:24 +02:00 committed by GitHub
commit 42a456224d
4 changed files with 24 additions and 24 deletions

View File

@ -1,17 +1,17 @@
#!/usr/bin/env bash
set -eu
BOOT="$IMG/$BASE.boot.img"
SYSTEM="$IMG/$BASE.system.img"
BOOT="$STORAGE/$BASE.boot.img"
SYSTEM="$STORAGE/$BASE.system.img"
[ ! -f "$BOOT" ] && echo "ERROR: Virtual DSM boot-image does not exist ($BOOT)" && exit 81
[ ! -f "$SYSTEM" ] && echo "ERROR: Virtual DSM system-image does not exist ($SYSTEM)" && exit 82
DATA="${IMG}/data.img"
DATA="${STORAGE}/data.img"
if [[ ! -f "${DATA}" ]] && [[ -f "$IMG/data$DISK_SIZE.img" ]]; then
if [[ ! -f "${DATA}" ]] && [[ -f "$STORAGE/data$DISK_SIZE.img" ]]; then
# Fallback for legacy installs
DATA="$IMG/data$DISK_SIZE.img"
DATA="$STORAGE/data$DISK_SIZE.img"
fi
DISK_SIZE=$(echo "${DISK_SIZE}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
@ -32,7 +32,7 @@ if [ -f "${DATA}" ]; then
REQ=$((DATA_SIZE-OLD_SIZE))
# Check free diskspace
SPACE=$(df --output=avail -B 1 "${IMG}" | tail -n 1)
SPACE=$(df --output=avail -B 1 "${STORAGE}" | tail -n 1)
if (( REQ > SPACE )); then
echo "ERROR: Not enough free space to resize virtual disk." && exit 84
@ -58,7 +58,7 @@ fi
if [ ! -f "${DATA}" ]; then
# Check free diskspace
SPACE=$(df --output=avail -B 1 "${IMG}" | tail -n 1)
SPACE=$(df --output=avail -B 1 "${STORAGE}" | tail -n 1)
if (( DATA_SIZE > SPACE )); then
echo "ERROR: Not enough free space to create virtual disk." && exit 86

View File

@ -16,14 +16,14 @@ fi
BASE=$(basename "$URL" .pat)
rm -f "$IMG"/"$BASE".pat
rm -f "$IMG"/"$BASE".agent
rm -f "$IMG"/"$BASE".boot.img
rm -f "$IMG"/"$BASE".system.img
rm -f "$STORAGE"/"$BASE".pat
rm -f "$STORAGE"/"$BASE".agent
rm -f "$STORAGE"/"$BASE".boot.img
rm -f "$STORAGE"/"$BASE".system.img
echo "Install: Downloading extractor..."
TMP="$IMG/tmp"
TMP="$STORAGE/tmp"
RD="$TMP/rd.gz"
rm -rf $TMP && mkdir -p $TMP
@ -160,7 +160,7 @@ cp /agent/service.sh $LOC/agent.sh
chmod +x $LOC/agent.sh
# Store agent version
echo "2" > "$IMG"/"$BASE".agent
echo "2" > "$STORAGE"/"$BASE".agent
echo "Install: Installing system partition..."
@ -172,9 +172,9 @@ mke2fs -q -t ext4 -b 4096 -d $MOUNT/ -L $LABEL -F -E offset=$OFFSET $SYSTEM $NUM
rm -rf $MOUNT
echo "$BASE" > "$IMG"/dsm.ver
mv -f "$PAT" "$IMG"/"$BASE".pat
mv -f "$BOOT" "$IMG"/"$BASE".boot.img
mv -f "$SYSTEM" "$IMG"/"$BASE".system.img
echo "$BASE" > "$STORAGE"/dsm.ver
mv -f "$PAT" "$STORAGE"/"$BASE".pat
mv -f "$BOOT" "$STORAGE"/"$BASE".boot.img
mv -f "$SYSTEM" "$STORAGE"/"$BASE".system.img
rm -rf $TMP

View File

@ -43,7 +43,7 @@ _graceful_shutdown(){
echo
echo "Could not send shutdown command to guest, error: $RESPONSE"
FILE="${IMG}/${BASE}.agent"
FILE="${STORAGE}/${BASE}.agent"
[ ! -f "$FILE" ] && echo "1" > "$FILE"
AGENT_VERSION=$(cat "${FILE}")

View File

@ -3,20 +3,20 @@ set -eu
echo "Starting Virtual DSM..."
IMG="/storage"
[ ! -d "$IMG" ] && echo "Storage folder (${IMG}) not found!" && exit 69
STORAGE="/storage"
[ ! -d "$STORAGE" ] && echo "Storage folder (${STORAGE}) not found!" && exit 69
[ ! -f "/run/run.sh" ] && echo "Script must run inside Docker container!" && exit 60
if [ -f "$IMG"/dsm.ver ]; then
BASE=$(cat "${IMG}/dsm.ver")
if [ -f "$STORAGE"/dsm.ver ]; then
BASE=$(cat "${STORAGE}/dsm.ver")
else
# Fallback for old installs
BASE="DSM_VirtualDSM_42962"
fi
[ -n $URL ] && BASE=$(basename "$URL" .pat)
[ -n "$URL" ] && BASE=$(basename "$URL" .pat)
if [[ ! -f "$IMG/$BASE.boot.img" ]] || [[ ! -f "$IMG/$BASE.system.img" ]]; then
if [[ ! -f "$STORAGE/$BASE.boot.img" ]] || [[ ! -f "$STORAGE/$BASE.system.img" ]]; then
. /run/install.sh
fi