Installation

This commit is contained in:
Kroese 2023-03-27 19:23:50 +02:00
parent 059286eae5
commit 746dc53947
2 changed files with 104 additions and 1 deletions

95
run.sh
View File

@ -1,22 +1,105 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eu
/run/server.sh 5000 "<HTML><BODY><H1><CENTER>Please wait while Synology is installing...</CENTER></H1></BODY></HTML>" > /dev/null &
[ ! -f "/images/boot.img" ] && rm -f /images/dsm.pat
[ ! -f "/images/system.img" ] && rm -f /images/dsm.pat
FILE="/images/dsm.pat"
if [ ! -f "$FILE" ]; then
echo "Downloading Synology DSM..."
BASE="https://global.synologydownload.com/download/DSM"
PAT="$BASE/beta/7.2/64216/DSM_VirtualDSM_64216.pat"
#PAT="$BASE/release/7.1.1/42962-1/DSM_VirtualDSM_42962.pat"
#PAT="$BASE/release/7.0.1/42218/DSM_VirtualDSM_42218.pat"
wget $PAT -O $FILE -q --show-progress
echo "Extracting DSM boot image..."
rm -rf /images/out
mkdir -p /images/out
if { tar tf "$FILE"; } >/dev/null 2>&1; then
tar xf $FILE --checkpoint=.100 -C /images/out/.
else
export LD_LIBRARY_PATH="/run"
/run/syno_extract_system_patch $FILE /images/out/.
export LD_LIBRARY_PATH=""
fi
BOOT=$(find /images/out -name "*.bin.zip")
BOOT=$(echo $BOOT | head -c -5)
unzip -q $BOOT.zip -d /images/out
rm $BOOT.zip
echo "Extracting DSM system image..."
HDA="/images/out/hda1"
mv $HDA.tgz $HDA.xz
unxz $HDA.xz
mv $HDA $HDA.tar
echo "Extracting DSM disk template..."
TEMP="/images/temp.img"
PLATE="/data/template.img"
rm -f $PLATE
unxz $PLATE.xz
mv $PLATE $TEMP
echo "Mounting disk template..."
rm -rf /mnt/tmp
mkdir -p /mnt/tmp
guestmount -a $TEMP -m /dev/sda1:/ --rw /mnt/tmp
echo "Preparing disk template..."
rm -rf /mnt/tmp/{,.[!.],..?}*
echo "Installing system partition..."
tar -xf $HDA.tar --absolute-names --checkpoint=.100 -C /mnt/tmp/
echo "Unmounting disk template..."
rm $HDA.tar
guestunmount /mnt/tmp
rm -rf /mnt/tmp
mv -f $BOOT /images/boot.img
mv -f $TEMP /images/system.img
rm -rf /images/out
fi
echo "Booting Synology DSM for Docker..." echo "Booting Synology DSM for Docker..."
FILE="/images/boot.img" FILE="/images/boot.img"
if [ ! -f "$FILE" ]; then if [ ! -f "$FILE" ]; then
echo "ERROR: Synology DSM boot-image does not exist ($FILE)" echo "ERROR: Synology DSM boot-image does not exist ($FILE)"
rm -f /images/dsm.pat
exit 2 exit 2
fi fi
FILE="/images/system.img" FILE="/images/system.img"
if [ ! -f "$FILE" ]; then if [ ! -f "$FILE" ]; then
echo "ERROR: Synology DSM system-image does not exist ($FILE)" echo "ERROR: Synology DSM system-image does not exist ($FILE)"
rm -f /images/dsm.pat
exit 2 exit 2
fi fi
FILE="/images/data.img" FILE="/images/data.img"
if [ ! -f "$FILE" ]; then if [ ! -f "$FILE" ]; then
truncate -s 16G $FILE truncate -s 16G $FILE
mkfs.ext4 -q $FILE
fi fi
if [ ! -f "$FILE" ]; then if [ ! -f "$FILE" ]; then
@ -74,7 +157,17 @@ udhcpd -I $DUMMY_DHCPD_IP -f $DHCPD_CONF_FILE &
echo "Launching Synology Serial Emulator..." echo "Launching Synology Serial Emulator..."
# Start the Synology Serial Emulator # Start the Synology Serial Emulator
./run/serial.bin -vmmversion "2.6.1-12139" -buildnumber 42962 -vmmts 1650802981032 -cpu 1 -cpu_arch string "QEMU, Virtual CPU, X86_64" -guestsn "0000000000000" -hostsn "0000000000000" -guestuuid "ba13a19a-c0c1-4fef-9346-915ed3b98341" & ./run/serial.bin -cpu 1 \
-vmmversion "2.6.1-12139" \
-buildnumber 42962 \
-vmmts 1650802981032 \
-cpu_arch string "QEMU, Virtual CPU, X86_64" \
-guestsn "0000000000000" \
-hostsn "0000000000000" \
-guestuuid "ba13a19a-c0c1-4fef-9346-915ed3b98341" > /dev/null &
# Stop the webserver
pkill -f server.sh
echo "Booting OS..." echo "Booting OS..."

10
server.sh Normal file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -eu
RESPONSE="HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n${2:-"OK"}\r\n"
while { echo -en "$RESPONSE"; } | nc -lN "${1:-8080}"; do
echo "================================================"
done