Loading Dockerfile +6 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ RUN if [ "$TARGETPLATFORM" != "linux/amd64" ]; then extra="qemu-user"; fi \ wget \ fdisk \ unzip \ socat \ nginx \ procps \ xz-utils \ iptables \ Loading @@ -39,11 +39,16 @@ RUN if [ "$TARGETPLATFORM" != "linux/amd64" ]; then extra="qemu-user"; fi \ qemu-system-x86 \ "$extra" \ && apt-get clean \ && unlink /etc/nginx/sites-enabled/default \ && sed -i 's/^worker_processes.*/worker_processes 1;/' /etc/nginx/nginx.conf \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* COPY ./src /run/ COPY ./web /var/www/ COPY --from=builder /qemu-host.bin /run/host.bin RUN chmod +x /run/*.sh && chmod +x /run/*.bin RUN mv /var/www/nginx.conf /etc/nginx/sites-enabled/web.conf VOLUME /storage EXPOSE 22 139 445 5000 Loading src/disk.sh +17 −8 Original line number Diff line number Diff line Loading @@ -61,8 +61,8 @@ getSize() { local DISK_FILE=$1 local DISK_EXT DISK_FMT DISK_EXT="$(echo "${DISK_FILE//*./}" | sed 's/^.*\.//')" DISK_FMT="$(ext2fmt "$DISK_EXT")" DISK_EXT=$(echo "${DISK_FILE//*./}" | sed 's/^.*\.//') DISK_FMT=$(ext2fmt "$DISK_EXT") case "${DISK_FMT,,}" in raw) Loading Loading @@ -112,7 +112,9 @@ createDisk() { fi fi info "Creating a $DISK_TYPE $DISK_DESC image in $DISK_FMT format with a size of $DISK_SPACE..." MSG="Creating a $DISK_TYPE $DISK_DESC image in $DISK_FMT format with a size of $DISK_SPACE..." info "$MSG" && html "$MSG" local FAIL="Could not create a $DISK_TYPE $DISK_FMT $DISK_DESC image of $DISK_SPACE ($DISK_FILE)" case "${DISK_FMT,,}" in Loading Loading @@ -195,7 +197,9 @@ resizeDisk() { fi local GB=$(( (CUR_SIZE + 1073741823)/1073741824 )) info "Resizing $DISK_DESC from ${GB}G to $DISK_SPACE..." MSG="Resizing $DISK_DESC from ${GB}G to $DISK_SPACE..." info "$MSG" && html "$MSG" local FAIL="Could not resize the $DISK_TYPE $DISK_FMT $DISK_DESC image from ${GB}G to $DISK_SPACE ($DISK_FILE)" case "${DISK_FMT,,}" in Loading Loading @@ -262,7 +266,8 @@ convertDisk() { fi fi info "Converting $DISK_DESC to $DST_FMT, please wait until completed..." MSG="Converting $DISK_DESC to $DST_FMT, please wait until completed..." info "$MSG" && html "$MSG" local CONV_FLAGS="-p" local DISK_PARAM="$DISK_ALLOC" Loading Loading @@ -301,7 +306,8 @@ convertDisk() { fi fi info "Conversion of $DISK_DESC to $DST_FMT completed succesfully!" MSG="Conversion of $DISK_DESC to $DST_FMT completed succesfully!" info "$MSG" && html "$MSG" return 0 } Loading Loading @@ -372,7 +378,7 @@ addDisk () { else PREV_FMT="qcow2" fi PREV_EXT="$(fmt2ext "$PREV_FMT")" PREV_EXT=$(fmt2ext "$PREV_FMT") if [ -f "$DISK_BASE.$PREV_EXT" ] ; then convertDisk "$DISK_BASE.$PREV_EXT" "$PREV_FMT" "$DISK_FILE" "$DISK_FMT" "$DISK_BASE" "$DISK_DESC" "$FS" || exit $? Loading Loading @@ -420,7 +426,9 @@ addDevice () { return 0 } DISK_EXT="$(fmt2ext "$DISK_FMT")" || exit $? html "Initializing disks..." DISK_EXT=$(fmt2ext "$DISK_FMT") if [ -z "$ALLOCATE" ]; then if [[ "${DISK_FMT,,}" == "raw" ]]; then Loading Loading @@ -505,4 +513,5 @@ else addDisk "userdata4" "$DISK4_FILE" "$DISK_EXT" "disk4" "$DISK4_SIZE" "6" "0xf" "$DISK_FMT" || exit $? fi html "Initialized disks successfully..." return 0 src/entry.sh +2 −3 Original line number Diff line number Diff line #!/usr/bin/env bash set -Eeuo pipefail echo "❯ Starting Virtual DSM for Docker v$(</run/version)..." echo "❯ For support visit https://github.com/vdsm/virtual-dsm" echo APP="Virtual DSM" SUPPORT="https://github.com/vdsm/virtual-dsm" cd /run Loading src/install.sh +16 −9 Original line number Diff line number Diff line Loading @@ -23,8 +23,7 @@ if [[ -f "$STORAGE/$BASE.boot.img" ]] && [[ -f "$STORAGE/$BASE.system.img" ]]; t return 0 # Previous installation found fi # Display wait message /run/server.sh 5000 install & html "Please wait while Virtual DSM is being installed..." DL="" DL_CHINA="https://cndl.synology.cn/download/DSM" Loading Loading @@ -105,7 +104,8 @@ RDC="$STORAGE/dsm.rd" if [ ! -f "$RDC" ]; then info "Install: Downloading installer..." MSG="Downloading installer..." info "Install: $MSG" && html "$MSG" RD="$TMP/rd.gz" POS="65627648-71021835" Loading Loading @@ -174,7 +174,8 @@ fi rm -rf "$TMP" && mkdir -p "$TMP" info "Install: Downloading $BASE.pat..." MSG="Downloading $BASE.pat..." info "Install: $MSG" && html "$MSG" PAT="/$BASE.pat" rm -f "$PAT" Loading @@ -198,7 +199,8 @@ if ((SIZE<250000000)); then error "The specified PAT file is probably an update pack as it's too small." && exit 62 fi info "Install: Extracting downloaded image..." MSG="Extracting downloaded image..." info "Install: $MSG" && html "$MSG" if { tar tf "$PAT"; } >/dev/null 2>&1; then Loading @@ -221,7 +223,9 @@ else fi rm -rf /run/extract info "Install: Preparing system partition..." MSG="Preparing system partition..." info "Install: $MSG" && html "$MSG" BOOT=$(find "$TMP" -name "*.bin.zip") [ ! -f "$BOOT" ] && error "The PAT file contains no boot image." && exit 67 Loading Loading @@ -277,7 +281,8 @@ sfdisk -q "$SYSTEM" < "$PART" MOUNT="$TMP/system" rm -rf "$MOUNT" && mkdir -p "$MOUNT" info "Install: Extracting system partition..." MSG="Extracting system partition..." info "Install: $MSG" && html "$MSG" HDA="$TMP/hda1" IDB="$TMP/indexdb" Loading @@ -301,12 +306,13 @@ fi LABEL="1.44.1-42218" OFFSET="1048576" # 2048 * 512 NUMBLOCKS="622560" # (4980480 * 512) / 4096 MSG="Installing system partition..." if [[ "$ROOT" != [Nn]* ]]; then tar xpfJ "$HDA.txz" --absolute-names --skip-old-files -C "$MOUNT/" info "Install: Installing system partition..." info "Install: $MSG" && html "$MSG" mke2fs -q -t ext4 -b 4096 -d "$MOUNT/" -L "$LABEL" -F -E "offset=$OFFSET" "$SYSTEM" "$NUMBLOCKS" Loading @@ -314,7 +320,7 @@ else fakeroot -- bash -c "set -Eeu;\ tar xpfJ $HDA.txz --absolute-names --skip-old-files -C $MOUNT/;\ printf '%b%s%b' '\E[1;34m❯ \E[1;36m' 'Install: Installing system partition...' '\E[0m\n';\ printf '%b%s%b' '\E[1;34m❯ \E[1;36m' 'Install: $MSG' '\E[0m\n';\ mke2fs -q -t ext4 -b 4096 -d $MOUNT/ -L $LABEL -F -E offset=$OFFSET $SYSTEM $NUMBLOCKS" fi Loading @@ -334,4 +340,5 @@ rm -rf "$TMP" { set +x; } 2>/dev/null [[ "$DEBUG" == [Yy1]* ]] && echo html "Installation finished successfully..." return 0 src/network.sh +12 −6 Original line number Diff line number Diff line Loading @@ -173,14 +173,17 @@ closeNetwork() { if [[ "$DHCP" == [Yy1]* ]]; then fKill "server.sh" # Shutdown nginx nginx -s stop 2> /dev/null fWait "nginx" ip link set "$VM_NET_TAP" down || true ip link delete "$VM_NET_TAP" || true else fKill "dnsmasq" local pid="/var/run/dnsmasq.pid" [ -f "$pid" ] && pKill "$(<"$pid")" ip link set "$VM_NET_TAP" down promisc off || true ip link delete "$VM_NET_TAP" || true Loading Loading @@ -227,8 +230,6 @@ getInfo() { # Configure Network # ###################################### fKill "server.sh" if [ ! -c /dev/vhost-net ]; then if mknod /dev/vhost-net c 10 238; then chmod 660 /dev/vhost-net Loading @@ -236,6 +237,7 @@ if [ ! -c /dev/vhost-net ]; then fi getInfo html "Initializing network..." if [[ "$DEBUG" == [Yy1]* ]]; then info "Container IP is $IP with gateway $GATEWAY on interface $VM_NET_DEV" && echo Loading @@ -252,11 +254,15 @@ if [[ "$DHCP" == [Yy1]* ]]; then # Configuration for DHCP IP configureDHCP # Display IP on port 80 and 5000 /run/server.sh 5000 /run/ip.sh & MSG="Please wait while discovering IP..." html "$MSG" "2000" else # Shutdown nginx nginx -s stop 2> /dev/null fWait "nginx" # Configuration for static IP configureNAT Loading Loading
Dockerfile +6 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ RUN if [ "$TARGETPLATFORM" != "linux/amd64" ]; then extra="qemu-user"; fi \ wget \ fdisk \ unzip \ socat \ nginx \ procps \ xz-utils \ iptables \ Loading @@ -39,11 +39,16 @@ RUN if [ "$TARGETPLATFORM" != "linux/amd64" ]; then extra="qemu-user"; fi \ qemu-system-x86 \ "$extra" \ && apt-get clean \ && unlink /etc/nginx/sites-enabled/default \ && sed -i 's/^worker_processes.*/worker_processes 1;/' /etc/nginx/nginx.conf \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* COPY ./src /run/ COPY ./web /var/www/ COPY --from=builder /qemu-host.bin /run/host.bin RUN chmod +x /run/*.sh && chmod +x /run/*.bin RUN mv /var/www/nginx.conf /etc/nginx/sites-enabled/web.conf VOLUME /storage EXPOSE 22 139 445 5000 Loading
src/disk.sh +17 −8 Original line number Diff line number Diff line Loading @@ -61,8 +61,8 @@ getSize() { local DISK_FILE=$1 local DISK_EXT DISK_FMT DISK_EXT="$(echo "${DISK_FILE//*./}" | sed 's/^.*\.//')" DISK_FMT="$(ext2fmt "$DISK_EXT")" DISK_EXT=$(echo "${DISK_FILE//*./}" | sed 's/^.*\.//') DISK_FMT=$(ext2fmt "$DISK_EXT") case "${DISK_FMT,,}" in raw) Loading Loading @@ -112,7 +112,9 @@ createDisk() { fi fi info "Creating a $DISK_TYPE $DISK_DESC image in $DISK_FMT format with a size of $DISK_SPACE..." MSG="Creating a $DISK_TYPE $DISK_DESC image in $DISK_FMT format with a size of $DISK_SPACE..." info "$MSG" && html "$MSG" local FAIL="Could not create a $DISK_TYPE $DISK_FMT $DISK_DESC image of $DISK_SPACE ($DISK_FILE)" case "${DISK_FMT,,}" in Loading Loading @@ -195,7 +197,9 @@ resizeDisk() { fi local GB=$(( (CUR_SIZE + 1073741823)/1073741824 )) info "Resizing $DISK_DESC from ${GB}G to $DISK_SPACE..." MSG="Resizing $DISK_DESC from ${GB}G to $DISK_SPACE..." info "$MSG" && html "$MSG" local FAIL="Could not resize the $DISK_TYPE $DISK_FMT $DISK_DESC image from ${GB}G to $DISK_SPACE ($DISK_FILE)" case "${DISK_FMT,,}" in Loading Loading @@ -262,7 +266,8 @@ convertDisk() { fi fi info "Converting $DISK_DESC to $DST_FMT, please wait until completed..." MSG="Converting $DISK_DESC to $DST_FMT, please wait until completed..." info "$MSG" && html "$MSG" local CONV_FLAGS="-p" local DISK_PARAM="$DISK_ALLOC" Loading Loading @@ -301,7 +306,8 @@ convertDisk() { fi fi info "Conversion of $DISK_DESC to $DST_FMT completed succesfully!" MSG="Conversion of $DISK_DESC to $DST_FMT completed succesfully!" info "$MSG" && html "$MSG" return 0 } Loading Loading @@ -372,7 +378,7 @@ addDisk () { else PREV_FMT="qcow2" fi PREV_EXT="$(fmt2ext "$PREV_FMT")" PREV_EXT=$(fmt2ext "$PREV_FMT") if [ -f "$DISK_BASE.$PREV_EXT" ] ; then convertDisk "$DISK_BASE.$PREV_EXT" "$PREV_FMT" "$DISK_FILE" "$DISK_FMT" "$DISK_BASE" "$DISK_DESC" "$FS" || exit $? Loading Loading @@ -420,7 +426,9 @@ addDevice () { return 0 } DISK_EXT="$(fmt2ext "$DISK_FMT")" || exit $? html "Initializing disks..." DISK_EXT=$(fmt2ext "$DISK_FMT") if [ -z "$ALLOCATE" ]; then if [[ "${DISK_FMT,,}" == "raw" ]]; then Loading Loading @@ -505,4 +513,5 @@ else addDisk "userdata4" "$DISK4_FILE" "$DISK_EXT" "disk4" "$DISK4_SIZE" "6" "0xf" "$DISK_FMT" || exit $? fi html "Initialized disks successfully..." return 0
src/entry.sh +2 −3 Original line number Diff line number Diff line #!/usr/bin/env bash set -Eeuo pipefail echo "❯ Starting Virtual DSM for Docker v$(</run/version)..." echo "❯ For support visit https://github.com/vdsm/virtual-dsm" echo APP="Virtual DSM" SUPPORT="https://github.com/vdsm/virtual-dsm" cd /run Loading
src/install.sh +16 −9 Original line number Diff line number Diff line Loading @@ -23,8 +23,7 @@ if [[ -f "$STORAGE/$BASE.boot.img" ]] && [[ -f "$STORAGE/$BASE.system.img" ]]; t return 0 # Previous installation found fi # Display wait message /run/server.sh 5000 install & html "Please wait while Virtual DSM is being installed..." DL="" DL_CHINA="https://cndl.synology.cn/download/DSM" Loading Loading @@ -105,7 +104,8 @@ RDC="$STORAGE/dsm.rd" if [ ! -f "$RDC" ]; then info "Install: Downloading installer..." MSG="Downloading installer..." info "Install: $MSG" && html "$MSG" RD="$TMP/rd.gz" POS="65627648-71021835" Loading Loading @@ -174,7 +174,8 @@ fi rm -rf "$TMP" && mkdir -p "$TMP" info "Install: Downloading $BASE.pat..." MSG="Downloading $BASE.pat..." info "Install: $MSG" && html "$MSG" PAT="/$BASE.pat" rm -f "$PAT" Loading @@ -198,7 +199,8 @@ if ((SIZE<250000000)); then error "The specified PAT file is probably an update pack as it's too small." && exit 62 fi info "Install: Extracting downloaded image..." MSG="Extracting downloaded image..." info "Install: $MSG" && html "$MSG" if { tar tf "$PAT"; } >/dev/null 2>&1; then Loading @@ -221,7 +223,9 @@ else fi rm -rf /run/extract info "Install: Preparing system partition..." MSG="Preparing system partition..." info "Install: $MSG" && html "$MSG" BOOT=$(find "$TMP" -name "*.bin.zip") [ ! -f "$BOOT" ] && error "The PAT file contains no boot image." && exit 67 Loading Loading @@ -277,7 +281,8 @@ sfdisk -q "$SYSTEM" < "$PART" MOUNT="$TMP/system" rm -rf "$MOUNT" && mkdir -p "$MOUNT" info "Install: Extracting system partition..." MSG="Extracting system partition..." info "Install: $MSG" && html "$MSG" HDA="$TMP/hda1" IDB="$TMP/indexdb" Loading @@ -301,12 +306,13 @@ fi LABEL="1.44.1-42218" OFFSET="1048576" # 2048 * 512 NUMBLOCKS="622560" # (4980480 * 512) / 4096 MSG="Installing system partition..." if [[ "$ROOT" != [Nn]* ]]; then tar xpfJ "$HDA.txz" --absolute-names --skip-old-files -C "$MOUNT/" info "Install: Installing system partition..." info "Install: $MSG" && html "$MSG" mke2fs -q -t ext4 -b 4096 -d "$MOUNT/" -L "$LABEL" -F -E "offset=$OFFSET" "$SYSTEM" "$NUMBLOCKS" Loading @@ -314,7 +320,7 @@ else fakeroot -- bash -c "set -Eeu;\ tar xpfJ $HDA.txz --absolute-names --skip-old-files -C $MOUNT/;\ printf '%b%s%b' '\E[1;34m❯ \E[1;36m' 'Install: Installing system partition...' '\E[0m\n';\ printf '%b%s%b' '\E[1;34m❯ \E[1;36m' 'Install: $MSG' '\E[0m\n';\ mke2fs -q -t ext4 -b 4096 -d $MOUNT/ -L $LABEL -F -E offset=$OFFSET $SYSTEM $NUMBLOCKS" fi Loading @@ -334,4 +340,5 @@ rm -rf "$TMP" { set +x; } 2>/dev/null [[ "$DEBUG" == [Yy1]* ]] && echo html "Installation finished successfully..." return 0
src/network.sh +12 −6 Original line number Diff line number Diff line Loading @@ -173,14 +173,17 @@ closeNetwork() { if [[ "$DHCP" == [Yy1]* ]]; then fKill "server.sh" # Shutdown nginx nginx -s stop 2> /dev/null fWait "nginx" ip link set "$VM_NET_TAP" down || true ip link delete "$VM_NET_TAP" || true else fKill "dnsmasq" local pid="/var/run/dnsmasq.pid" [ -f "$pid" ] && pKill "$(<"$pid")" ip link set "$VM_NET_TAP" down promisc off || true ip link delete "$VM_NET_TAP" || true Loading Loading @@ -227,8 +230,6 @@ getInfo() { # Configure Network # ###################################### fKill "server.sh" if [ ! -c /dev/vhost-net ]; then if mknod /dev/vhost-net c 10 238; then chmod 660 /dev/vhost-net Loading @@ -236,6 +237,7 @@ if [ ! -c /dev/vhost-net ]; then fi getInfo html "Initializing network..." if [[ "$DEBUG" == [Yy1]* ]]; then info "Container IP is $IP with gateway $GATEWAY on interface $VM_NET_DEV" && echo Loading @@ -252,11 +254,15 @@ if [[ "$DHCP" == [Yy1]* ]]; then # Configuration for DHCP IP configureDHCP # Display IP on port 80 and 5000 /run/server.sh 5000 /run/ip.sh & MSG="Please wait while discovering IP..." html "$MSG" "2000" else # Shutdown nginx nginx -s stop 2> /dev/null fWait "nginx" # Configuration for static IP configureNAT Loading