mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-02-24 13:30:02 +08:00
Installation fixes
This commit is contained in:
parent
9843f40d0c
commit
ba9b14ebd3
49
install.sh
49
install.sh
@ -3,7 +3,7 @@
|
||||
set -eu
|
||||
IMG="/storage"
|
||||
|
||||
[ ! -f "/run/server.sh" ] && echo "Script must run inside Docker container!" && exit 1
|
||||
[ ! -f "/run/server.sh" ] && echo "Script must run inside Docker container!" && exit 60
|
||||
[ ! -f "$IMG/boot.img" ] && rm -f $IMG/system.img
|
||||
|
||||
if [ ! -f "$IMG/system.img" ]; then
|
||||
@ -16,19 +16,40 @@ if [ ! -f "$IMG/system.img" ]; then
|
||||
rm -rf $TMP && mkdir -p $TMP
|
||||
wget $URL -O $FILE -q --show-progress
|
||||
|
||||
[ ! -f "$FILE" ] && echo "Download failed" && exit 61
|
||||
|
||||
SIZE=$(stat -c%s "$FILE")
|
||||
|
||||
if ((SIZE<250000000)); then
|
||||
echo "Invalid PAT file: File is an update pack which contains no OS image." && exit 62
|
||||
fi
|
||||
|
||||
echo "Extracting boot image..."
|
||||
|
||||
if { tar tf "$FILE"; } >/dev/null 2>&1; then
|
||||
tar xpf $FILE -C $TMP/.
|
||||
else
|
||||
export LD_LIBRARY_PATH="/run"
|
||||
/run/syno_extract_system_patch $FILE $TMP/.
|
||||
if ! /run/syno_extract_system_patch $FILE $TMP/. ; then
|
||||
echo "Invalid PAT file: File is an update pack which contains no OS image." && exit 63
|
||||
fi
|
||||
export LD_LIBRARY_PATH=""
|
||||
fi
|
||||
|
||||
rm $FILE
|
||||
|
||||
HDA="$TMP/hda1"
|
||||
HDP="$TMP/synohdpack_img"
|
||||
IDB="$TMP/indexdb"
|
||||
|
||||
[ ! -f "$HDA.tgz" ] && echo "Invalid PAT file: File contains no OS image." && exit 64
|
||||
[ ! -f "$HDP.txz" ] && echo "Invalid PAT file: HD pack not found." && exit 65
|
||||
[ ! -f "$IDB.txz" ] && echo "Invalid PAT file: IndexDB file not found." && exit 66
|
||||
|
||||
BOOT=$(find $TMP -name "*.bin.zip")
|
||||
|
||||
[ ! -f "$BOOT" ] && echo "Invalid PAT file: boot file not found." && exit 67
|
||||
|
||||
BOOT=$(echo $BOOT | head -c -5)
|
||||
|
||||
unzip -q $BOOT.zip -d $TMP
|
||||
@ -36,12 +57,11 @@ if [ ! -f "$IMG/system.img" ]; then
|
||||
|
||||
echo "Extracting system image..."
|
||||
|
||||
HDA="$TMP/hda1"
|
||||
mv $HDA.tgz $HDA.xz
|
||||
unxz $HDA.xz
|
||||
mv $HDA $HDA.tar
|
||||
|
||||
echo "Extracting data image..."
|
||||
echo "Extracting disk image..."
|
||||
|
||||
SYSTEM="$TMP/temp.img"
|
||||
PLATE="/data/template.img"
|
||||
@ -50,7 +70,7 @@ if [ ! -f "$IMG/system.img" ]; then
|
||||
unxz $PLATE.xz
|
||||
mv -f $PLATE $SYSTEM
|
||||
|
||||
echo "Mounting disk template..."
|
||||
echo "Mounting disk image..."
|
||||
MOUNT="/mnt/tmp"
|
||||
|
||||
rm -rf $MOUNT
|
||||
@ -60,12 +80,17 @@ if [ ! -f "$IMG/system.img" ]; then
|
||||
|
||||
echo -n "Installing system partition.."
|
||||
|
||||
tar xpf $HDP.txz --absolute-names -C $MOUNT/
|
||||
tar xpf $HDA.tar --absolute-names --checkpoint=.6000 -C $MOUNT/
|
||||
tar xpf $IDB.txz --absolute-names -C $MOUNT/usr/syno/synoman/indexdb/
|
||||
|
||||
echo ""
|
||||
echo "Unmounting disk template..."
|
||||
|
||||
rm $HDA.tar
|
||||
rm $HDP.txz
|
||||
rm $IDB.txz
|
||||
|
||||
guestunmount $MOUNT
|
||||
rm -rf $MOUNT
|
||||
|
||||
@ -75,18 +100,4 @@ if [ ! -f "$IMG/system.img" ]; then
|
||||
rm -rf $TMP
|
||||
fi
|
||||
|
||||
FILE="$IMG/boot.img"
|
||||
[ ! -f "$FILE" ] && echo "ERROR: Synology DSM boot-image does not exist ($FILE)" && exit 2
|
||||
|
||||
FILE="$IMG/system.img"
|
||||
[ ! -f "$FILE" ] && echo "ERROR: Synology DSM system-image does not exist ($FILE)" && exit 2
|
||||
|
||||
FILE="$IMG/data.img"
|
||||
if [ ! -f "$FILE" ]; then
|
||||
truncate -s $DISK_SIZE $FILE
|
||||
mkfs.ext4 -q $FILE
|
||||
fi
|
||||
|
||||
[ ! -f "$FILE" ] && echo "ERROR: Synology DSM data-image does not exist ($FILE)" && exit 2
|
||||
|
||||
exit 0
|
||||
|
25
run.sh
25
run.sh
@ -7,9 +7,24 @@ set -eu
|
||||
if /run/install.sh; then
|
||||
echo "Starting DSM for Docker..."
|
||||
else
|
||||
echo "Installation failed (code $?)" && exit 2
|
||||
echo "Installation failed (code $?)" && exit 80
|
||||
fi
|
||||
|
||||
IMG="/storage"
|
||||
FILE="$IMG/boot.img"
|
||||
[ ! -f "$FILE" ] && echo "ERROR: Synology DSM boot-image does not exist ($FILE)" && exit 81
|
||||
|
||||
FILE="$IMG/system.img"
|
||||
[ ! -f "$FILE" ] && echo "ERROR: Synology DSM system-image does not exist ($FILE)" && exit 82
|
||||
|
||||
FILE="$IMG/data.img"
|
||||
if [ ! -f "$FILE" ]; then
|
||||
truncate -s $DISK_SIZE $FILE
|
||||
mkfs.ext4 -q $FILE
|
||||
fi
|
||||
|
||||
[ ! -f "$FILE" ] && echo "ERROR: Synology DSM data-image does not exist ($FILE)" && exit 83
|
||||
|
||||
# A bridge of this name will be created to host the TAP interface created for
|
||||
# the VM
|
||||
QEMU_BRIDGE='qemubr0'
|
||||
@ -74,17 +89,15 @@ GUEST_SERIAL=$(/run/serial.sh)
|
||||
# Stop the webserver
|
||||
pkill -f server.sh
|
||||
|
||||
[ ! -e /dev/fuse ] && echo "Error: FUSE interface not available..." && exit 2
|
||||
[ ! -e /dev/net/tun ] && echo "Error: TUN interface not available..." && exit 2
|
||||
[ ! -e /dev/fuse ] && echo "Error: FUSE interface not available..." && exit 84
|
||||
[ ! -e /dev/net/tun ] && echo "Error: TUN interface not available..." && exit 85
|
||||
|
||||
if [ -e /dev/kvm ] && sh -c 'echo -n > /dev/kvm' &> /dev/null; then
|
||||
echo "Booting DSM image..."
|
||||
else
|
||||
echo "Error: KVM not available..." && exit 2
|
||||
echo "Error: KVM not available..." && exit 86
|
||||
fi
|
||||
|
||||
IMG="/storage"
|
||||
|
||||
# Configure QEMU for graceful shutdown
|
||||
|
||||
QEMU_MONPORT=7100
|
||||
|
Loading…
x
Reference in New Issue
Block a user