mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-11-07 02:23:42 +08:00
Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a768fecfde | ||
|
|
01e41a4014 | ||
|
|
eb4852683b | ||
|
|
6218333fec | ||
|
|
f32d8cbefc | ||
|
|
3e985502c2 | ||
|
|
ad3132e8c2 | ||
|
|
830ace0e47 | ||
|
|
1c36893729 | ||
|
|
a87aaab6f7 | ||
|
|
21699b8960 | ||
|
|
87ee25d404 | ||
|
|
c1714f9e6b | ||
|
|
754765b766 | ||
|
|
419f0cf571 | ||
|
|
55d9ac521f | ||
|
|
3406b3b471 | ||
|
|
f067ad2458 | ||
|
|
7eafd0a969 | ||
|
|
116f30bc0a | ||
|
|
04aa20e836 | ||
|
|
3bf4cc861b | ||
|
|
3c6620a3f9 | ||
|
|
ab0ea5a1d8 | ||
|
|
f894ad2686 | ||
|
|
570340d4e5 | ||
|
|
7dbe706282 | ||
|
|
0c9559f695 | ||
|
|
3113e2b64e | ||
|
|
f0ce992a27 | ||
|
|
6334cfc8bc | ||
|
|
451a569617 | ||
|
|
44d82d6544 |
85
.github/workflows/build.yml
vendored
85
.github/workflows/build.yml
vendored
@@ -7,12 +7,16 @@ on:
|
|||||||
- master
|
- master
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**/*.md'
|
- '**/*.md'
|
||||||
- '**/*.yml'
|
- '**/*.yml'
|
||||||
- '.gitignore'
|
- '.gitignore'
|
||||||
- '.dockerignore'
|
- '.dockerignore'
|
||||||
- '.github/**'
|
- '.github/**'
|
||||||
- '.github/workflows/**'
|
- '.github/workflows/**'
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: build
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
shellcheck:
|
shellcheck:
|
||||||
name: Check
|
name: Check
|
||||||
@@ -22,37 +26,34 @@ jobs:
|
|||||||
needs: shellcheck
|
needs: shellcheck
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
|
actions: write
|
||||||
packages: write
|
packages: write
|
||||||
contents: read
|
contents: read
|
||||||
steps:
|
steps:
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
-
|
-
|
||||||
name: Prepare Docker build
|
name: Docker metadata
|
||||||
id: prepare
|
id: meta
|
||||||
run: |
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
PLATFORMS="linux/amd64,linux/arm64"
|
context: git
|
||||||
VERSION="${{ vars.MAJOR }}.${{ vars.MINOR }}"
|
images: |
|
||||||
|
${{ secrets.DOCKERHUB_REPO }}
|
||||||
TAGS=()
|
ghcr.io/${{ github.repository }}
|
||||||
TAGS=("${{ github.repository }}:latest")
|
tags: |
|
||||||
TAGS+=("${{ github.repository }}:${VERSION}")
|
type=raw,value=latest,priority=100
|
||||||
#TAGS+=("${{ secrets.DOCKERHUB_MIRROR }}:latest")
|
type=raw,value=${{ vars.MAJOR }}.${{ vars.MINOR }}
|
||||||
#TAGS+=("${{ secrets.DOCKERHUB_MIRROR }}:${VERSION}")
|
labels: |
|
||||||
TAGS+=("ghcr.io/${{ github.repository }}:latest")
|
org.opencontainers.image.title=${{ vars.NAME }}
|
||||||
TAGS+=("ghcr.io/${{ github.repository }}:${VERSION}")
|
env:
|
||||||
|
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
|
||||||
echo "tags=${TAGS[@]}" >> $GITHUB_OUTPUT
|
-
|
||||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
name: Set up Docker Buildx
|
||||||
echo "docker_platforms=${PLATFORMS}" >> $GITHUB_OUTPUT
|
uses: docker/setup-buildx-action@v3
|
||||||
echo "build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
|
|
||||||
-
|
-
|
||||||
name: Login into Docker Hub
|
name: Login into Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
@@ -66,36 +67,28 @@ jobs:
|
|||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
-
|
|
||||||
name: Build Docker image
|
|
||||||
run: |
|
|
||||||
|
|
||||||
TAGS=(${{ steps.prepare.outputs.tags }})
|
|
||||||
|
|
||||||
echo "Build date: ${{ steps.prepare.outputs.build_date }}"
|
|
||||||
echo "Docker platform: ${{ steps.prepare.outputs.docker_platforms }}"
|
|
||||||
echo "Tags: ${{ steps.prepare.outputs.tags }}"
|
|
||||||
|
|
||||||
docker buildx build --platform ${{ steps.prepare.outputs.docker_platforms }} \
|
|
||||||
--output "type=image,push=true" \
|
|
||||||
--progress=plain \
|
|
||||||
--build-arg "BUILD_ARG=${GITHUB_RUN_ID}" \
|
|
||||||
--build-arg "VERSION_ARG=${{ steps.prepare.outputs.version }}" \
|
|
||||||
--build-arg "DATE_ARG=${{ steps.prepare.outputs.build_date }}" \
|
|
||||||
--build-arg "VCS_REF=${GITHUB_SHA::8}" \
|
|
||||||
$(printf "%s" "${TAGS[@]/#/ --tag }" ) .
|
|
||||||
-
|
-
|
||||||
name: Clear Docker credentials
|
name: Build Docker image
|
||||||
run: |
|
uses: docker/build-push-action@v5
|
||||||
rm -f ${HOME}/.docker/config.json
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
provenance: false
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
annotations: ${{ steps.meta.outputs.annotations }}
|
||||||
|
build-args: |
|
||||||
|
VCS_REF=${GITHUB_SHA::8}
|
||||||
|
VERSION_ARG=${{ steps.meta.outputs.version }}
|
||||||
-
|
-
|
||||||
name: Create a release
|
name: Create a release
|
||||||
uses: action-pack/github-release@v2
|
uses: action-pack/github-release@v2
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
|
||||||
with:
|
with:
|
||||||
tag: "v${{ steps.prepare.outputs.version }}"
|
tag: "v${{ steps.meta.outputs.version }}"
|
||||||
title: "v${{ steps.prepare.outputs.version }}"
|
title: "v${{ steps.meta.outputs.version }}"
|
||||||
-
|
-
|
||||||
name: Increment version variable
|
name: Increment version variable
|
||||||
uses: action-pack/bump@v2
|
uses: action-pack/bump@v2
|
||||||
|
|||||||
21
Dockerfile
21
Dockerfile
@@ -33,7 +33,7 @@ RUN apt-get update && apt-get -y upgrade && \
|
|||||||
&& apt-get clean \
|
&& apt-get clean \
|
||||||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||||
|
|
||||||
COPY src/*.sh /run/
|
COPY ./src /run/
|
||||||
COPY --from=builder /qemu-host.bin /run/host.bin
|
COPY --from=builder /qemu-host.bin /run/host.bin
|
||||||
RUN chmod +x /run/*.sh && chmod +x /run/*.bin
|
RUN chmod +x /run/*.sh && chmod +x /run/*.bin
|
||||||
|
|
||||||
@@ -45,24 +45,13 @@ EXPOSE 139
|
|||||||
EXPOSE 445
|
EXPOSE 445
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
|
||||||
ENV CPU_CORES "1"
|
ENV RAM_SIZE "1G"
|
||||||
ENV DISK_SIZE "16G"
|
ENV DISK_SIZE "16G"
|
||||||
ENV RAM_SIZE "512M"
|
ENV CPU_CORES "1"
|
||||||
|
|
||||||
ARG DATE_ARG=""
|
|
||||||
ARG BUILD_ARG=0
|
|
||||||
ARG VERSION_ARG="0.0"
|
ARG VERSION_ARG="0.0"
|
||||||
ENV VERSION=$VERSION_ARG
|
RUN echo "$VERSION_ARG" > /run/version
|
||||||
|
|
||||||
LABEL org.opencontainers.image.licenses="MIT"
|
HEALTHCHECK --interval=60s --start-period=45s --retries=2 CMD /run/check.sh
|
||||||
LABEL org.opencontainers.image.title="Virtual DSM"
|
|
||||||
LABEL org.opencontainers.image.created=${DATE_ARG}
|
|
||||||
LABEL org.opencontainers.image.revision=${BUILD_ARG}
|
|
||||||
LABEL org.opencontainers.image.version=${VERSION_ARG}
|
|
||||||
LABEL org.opencontainers.image.source="https://github.com/vdsm/virtual-dsm/"
|
|
||||||
LABEL org.opencontainers.image.url="https://hub.docker.com/r/vdsm/virtual-dsm/"
|
|
||||||
LABEL org.opencontainers.image.description="Virtual DSM in a docker container"
|
|
||||||
|
|
||||||
HEALTHCHECK --interval=60s --retries=2 CMD /run/check.sh
|
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/bin/tini", "-s", "/run/entry.sh"]
|
ENTRYPOINT ["/usr/bin/tini", "-s", "/run/entry.sh"]
|
||||||
|
|||||||
@@ -4,11 +4,12 @@ services:
|
|||||||
container_name: dsm
|
container_name: dsm
|
||||||
image: vdsm/virtual-dsm:latest
|
image: vdsm/virtual-dsm:latest
|
||||||
environment:
|
environment:
|
||||||
CPU_CORES: "1"
|
|
||||||
DISK_SIZE: "16G"
|
DISK_SIZE: "16G"
|
||||||
RAM_SIZE: "512M"
|
RAM_SIZE: "1G"
|
||||||
|
CPU_CORES: "1"
|
||||||
devices:
|
devices:
|
||||||
- /dev/kvm
|
- /dev/kvm
|
||||||
|
- /dev/net/tun
|
||||||
- /dev/vhost-net
|
- /dev/vhost-net
|
||||||
device_cgroup_rules:
|
device_cgroup_rules:
|
||||||
- 'c *:* rwm'
|
- 'c *:* rwm'
|
||||||
|
|||||||
75
readme.md
75
readme.md
@@ -10,11 +10,12 @@
|
|||||||
[![Pulls]][hub_url]
|
[![Pulls]][hub_url]
|
||||||
|
|
||||||
</div></h1>
|
</div></h1>
|
||||||
|
|
||||||
Virtual DSM in a docker container.
|
Virtual DSM in a docker container.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Multi-platform
|
- Multiple disks
|
||||||
- KVM acceleration
|
- KVM acceleration
|
||||||
- GPU passthrough
|
- GPU passthrough
|
||||||
- Upgrades supported
|
- Upgrades supported
|
||||||
@@ -33,7 +34,6 @@ services:
|
|||||||
DISK_SIZE: "16G"
|
DISK_SIZE: "16G"
|
||||||
devices:
|
devices:
|
||||||
- /dev/kvm
|
- /dev/kvm
|
||||||
- /dev/vhost-net
|
|
||||||
cap_add:
|
cap_add:
|
||||||
- NET_ADMIN
|
- NET_ADMIN
|
||||||
ports:
|
ports:
|
||||||
@@ -58,7 +58,7 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
environment:
|
environment:
|
||||||
DISK_SIZE: "256G"
|
DISK_SIZE: "128G"
|
||||||
```
|
```
|
||||||
|
|
||||||
This can also be used to resize the existing disk to a larger capacity without any data loss.
|
This can also be used to resize the existing disk to a larger capacity without any data loss.
|
||||||
@@ -74,6 +74,19 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
|
|||||||
|
|
||||||
Replace the example path `/home/user/data` with the desired storage folder.
|
Replace the example path `/home/user/data` with the desired storage folder.
|
||||||
|
|
||||||
|
* ### How do I add multiple disks?
|
||||||
|
|
||||||
|
To create additional disks, modify your compose file like this:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
environment:
|
||||||
|
DISK2_SIZE: "32G"
|
||||||
|
DISK3_SIZE: "64G"
|
||||||
|
volumes:
|
||||||
|
- /home/example:/storage2
|
||||||
|
- /mnt/data/example:/storage3
|
||||||
|
```
|
||||||
|
|
||||||
* ### How do I change the space reserved by the virtual disk?
|
* ### How do I change the space reserved by the virtual disk?
|
||||||
|
|
||||||
By default, the entire disk space is reserved in advance. To create a growable disk that only reserves the space that is actually used, add the following environment variable:
|
By default, the entire disk space is reserved in advance. To create a growable disk that only reserves the space that is actually used, add the following environment variable:
|
||||||
@@ -84,41 +97,15 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
|
|||||||
```
|
```
|
||||||
|
|
||||||
Keep in mind that this will not affect any of your existing disks, it only applies to newly created disks.
|
Keep in mind that this will not affect any of your existing disks, it only applies to newly created disks.
|
||||||
|
|
||||||
* ### How do I add multiple disks?
|
|
||||||
|
|
||||||
To mount extra volumes, modify your compose file like this:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
environment:
|
|
||||||
DISK2_SIZE: "32G"
|
|
||||||
DISK3_SIZE: "64G"
|
|
||||||
volumes:
|
|
||||||
- /home/example2:/storage2
|
|
||||||
- /home/example3:/storage3
|
|
||||||
```
|
|
||||||
|
|
||||||
Additionally, it's also possible to passthrough raw disk devices like this:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
environment:
|
|
||||||
DEVICE2: "/dev/vdc1"
|
|
||||||
DEVICE3: "/dev/vdc2"
|
|
||||||
devices:
|
|
||||||
- /dev/vdc1
|
|
||||||
- /dev/vdc2
|
|
||||||
```
|
|
||||||
|
|
||||||
Please beware that any pre-existing partitions and data on those devices will be wiped.
|
|
||||||
|
|
||||||
* ### How do I increase the amount of CPU or RAM?
|
* ### How do I increase the amount of CPU or RAM?
|
||||||
|
|
||||||
By default, a single core and 512 MB of RAM are allocated to the container. To increase this, add the following environment variables:
|
By default, a single core and 1 GB of RAM are allocated to the container. To increase this, add the following environment variables:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
environment:
|
environment:
|
||||||
|
RAM_SIZE: "4G"
|
||||||
CPU_CORES: "4"
|
CPU_CORES: "4"
|
||||||
RAM_SIZE: "2048M"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
* ### How do I verify if my system supports KVM?
|
* ### How do I verify if my system supports KVM?
|
||||||
@@ -185,18 +172,7 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
|
|||||||
|
|
||||||
Please note that even if you don't need DHCP, it's still recommended to enable this feature as it prevents NAT issues and increases performance by using a `macvtap` interface.
|
Please note that even if you don't need DHCP, it's still recommended to enable this feature as it prevents NAT issues and increases performance by using a `macvtap` interface.
|
||||||
|
|
||||||
* ### How do I install a specific version of vDSM?
|
* ### How do I passthrough the GPU?
|
||||||
|
|
||||||
By default, version 7.2.1 will be installed, but if you prefer an older version, you can add its download URL to your compose file as follows:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
environment:
|
|
||||||
URL: "https://global.synologydownload.com/download/DSM/release/7.0.1/42218/DSM_VirtualDSM_42218.pat"
|
|
||||||
```
|
|
||||||
|
|
||||||
With this method, it is even possible to switch between different versions while keeping all your file data intact.
|
|
||||||
|
|
||||||
* ### How do I passthrough my GPU?
|
|
||||||
|
|
||||||
To passthrough your Intel GPU, add the following lines to your compose file:
|
To passthrough your Intel GPU, add the following lines to your compose file:
|
||||||
|
|
||||||
@@ -208,7 +184,18 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
|
|||||||
```
|
```
|
||||||
|
|
||||||
This can be used to enable the facial recognition function in Synology Photos for example.
|
This can be used to enable the facial recognition function in Synology Photos for example.
|
||||||
|
|
||||||
|
* ### How do I install a specific version of vDSM?
|
||||||
|
|
||||||
|
By default, version 7.2.1 will be installed, but if you prefer an older version, you can add its download URL to your compose file as follows:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
environment:
|
||||||
|
URL: "https://global.synologydownload.com/download/DSM/release/7.0.1/42218/DSM_VirtualDSM_42218.pat"
|
||||||
|
```
|
||||||
|
|
||||||
|
With this method, it is even possible to switch between different versions while keeping all your file data intact.
|
||||||
|
|
||||||
* ### What are the differences compared to the standard DSM?
|
* ### What are the differences compared to the standard DSM?
|
||||||
|
|
||||||
There are only two minor differences: the Virtual Machine Manager package is not available, and Surveillance Station will not include any free licenses.
|
There are only two minor differences: the Virtual Machine Manager package is not available, and Surveillance Station will not include any free licenses.
|
||||||
|
|||||||
@@ -27,9 +27,7 @@ addDisk () {
|
|||||||
local GB
|
local GB
|
||||||
local DIR
|
local DIR
|
||||||
local REQ
|
local REQ
|
||||||
local SIZE
|
|
||||||
local SPACE
|
local SPACE
|
||||||
local MIN_SIZE
|
|
||||||
local CUR_SIZE
|
local CUR_SIZE
|
||||||
local DATA_SIZE
|
local DATA_SIZE
|
||||||
local DISK_ID=$1
|
local DISK_ID=$1
|
||||||
@@ -46,8 +44,7 @@ addDisk () {
|
|||||||
DISK_SPACE=$(echo "${DISK_SPACE}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
|
DISK_SPACE=$(echo "${DISK_SPACE}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
|
||||||
DATA_SIZE=$(numfmt --from=iec "${DISK_SPACE}")
|
DATA_SIZE=$(numfmt --from=iec "${DISK_SPACE}")
|
||||||
|
|
||||||
MIN_SIZE=6442450944
|
if (( DATA_SIZE < 6442450944 )); then
|
||||||
if (( DATA_SIZE < MIN_SIZE )); then
|
|
||||||
error "Please increase ${DISK_DESC^^}_SIZE to at least 6 GB." && exit 83
|
error "Please increase ${DISK_DESC^^}_SIZE to at least 6 GB." && exit 83
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
echo "❯ Starting Virtual DSM for Docker v${VERSION}..."
|
echo "❯ Starting Virtual DSM for Docker v$(</run/version)..."
|
||||||
echo "❯ For support visit https://github.com/vdsm/virtual-dsm/"
|
echo "❯ For support visit https://github.com/vdsm/virtual-dsm/"
|
||||||
|
|
||||||
cd /run
|
cd /run
|
||||||
@@ -17,6 +17,11 @@ cd /run
|
|||||||
|
|
||||||
trap - ERR
|
trap - ERR
|
||||||
|
|
||||||
|
if [[ "${CONSOLE}" == [Yy]* ]]; then
|
||||||
|
exec qemu-system-x86_64 -pidfile "${QEMU_PID}" ${ARGS:+ $ARGS}
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
set -m
|
set -m
|
||||||
(
|
(
|
||||||
[[ "${DEBUG}" == [Yy1]* ]] && info "$VERS" && set -x
|
[[ "${DEBUG}" == [Yy1]* ]] && info "$VERS" && set -x
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
: ${URL:=''} # URL of the PAT file to be downloaded.
|
||||||
|
: ${DEV:='Y'} # Controls whether device nodes are created.
|
||||||
|
|
||||||
if [ -f "$STORAGE"/dsm.ver ]; then
|
if [ -f "$STORAGE"/dsm.ver ]; then
|
||||||
BASE=$(cat "${STORAGE}/dsm.ver")
|
BASE=$(cat "${STORAGE}/dsm.ver")
|
||||||
else
|
else
|
||||||
@@ -8,7 +11,6 @@ else
|
|||||||
BASE="DSM_VirtualDSM_42962"
|
BASE="DSM_VirtualDSM_42962"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
: ${URL:=''}
|
|
||||||
[ -n "$URL" ] && BASE=$(basename "$URL" .pat)
|
[ -n "$URL" ] && BASE=$(basename "$URL" .pat)
|
||||||
|
|
||||||
if [[ -f "$STORAGE/$BASE.boot.img" ]] && [[ -f "$STORAGE/$BASE.system.img" ]]; then
|
if [[ -f "$STORAGE/$BASE.boot.img" ]] && [[ -f "$STORAGE/$BASE.system.img" ]]; then
|
||||||
@@ -107,8 +109,14 @@ if [ -f "${RDC}" ]; then
|
|||||||
{ xz -dc <"$RDC" >"$TMP/rd" 2>/dev/null; rc=$?; } || :
|
{ 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=$?; } || :
|
if [[ "${DEV}" == [Nn]* ]]; then
|
||||||
(( rc != 0 )) && error "Failed to cpio $RDC, reason $rc" && exit 92
|
# Exclude dev/ from cpio extract
|
||||||
|
{ (cd "$TMP" && cpio -it < "$TMP/rd" | grep -Ev 'dev/' | while read -r entry; do cpio -idm "$entry" < "$TMP/rd" 2>/dev/null; done); rc=$?; } || :
|
||||||
|
else
|
||||||
|
{ (cd "$TMP" && cpio -idm <"$TMP/rd" 2>/dev/null); rc=$?; } || :
|
||||||
|
fi
|
||||||
|
|
||||||
|
(( rc != 0 )) && error "Failed to extract $RDC, reason $rc" && exit 92
|
||||||
|
|
||||||
mkdir -p /run/extract
|
mkdir -p /run/extract
|
||||||
for file in $TMP/usr/lib/libcurl.so.4 \
|
for file in $TMP/usr/lib/libcurl.so.4 \
|
||||||
@@ -240,7 +248,13 @@ MOUNT="$TMP/system"
|
|||||||
rm -rf "$MOUNT" && mkdir -p "$MOUNT"
|
rm -rf "$MOUNT" && mkdir -p "$MOUNT"
|
||||||
|
|
||||||
mv "$HDA.tgz" "$HDA.txz"
|
mv "$HDA.tgz" "$HDA.txz"
|
||||||
tar xpfJ "$HDA.txz" --absolute-names -C "$MOUNT/"
|
|
||||||
|
if [[ "${DEV}" == [Nn]* ]]; then
|
||||||
|
# Exclude dev/ from tar extract
|
||||||
|
tar xpfJ "$HDA.txz" --absolute-names --exclude="dev" -C "$MOUNT/"
|
||||||
|
else
|
||||||
|
tar xpfJ "$HDA.txz" --absolute-names -C "$MOUNT/"
|
||||||
|
fi
|
||||||
|
|
||||||
[ -d "$PKG" ] && mv "$PKG/" "$MOUNT/.SynoUpgradePackages/"
|
[ -d "$PKG" ] && mv "$PKG/" "$MOUNT/.SynoUpgradePackages/"
|
||||||
rm -f "$MOUNT/.SynoUpgradePackages/ActiveInsight-"*
|
rm -f "$MOUNT/.SynoUpgradePackages/ActiveInsight-"*
|
||||||
|
|||||||
14
src/reset.sh
14
src/reset.sh
@@ -12,11 +12,12 @@ trap 'error "Status $? while: ${BASH_COMMAND} (line $LINENO/$BASH_LINENO)"' ERR
|
|||||||
|
|
||||||
: ${GPU:='N'} # Enable GPU passthrough
|
: ${GPU:='N'} # Enable GPU passthrough
|
||||||
: ${DEBUG:='N'} # Enable debugging mode
|
: ${DEBUG:='N'} # Enable debugging mode
|
||||||
|
: ${CONSOLE:='N'} # Start in console mode
|
||||||
: ${ALLOCATE:='Y'} # Preallocate diskspace
|
: ${ALLOCATE:='Y'} # Preallocate diskspace
|
||||||
: ${ARGUMENTS:=''} # Extra QEMU parameters
|
: ${ARGUMENTS:=''} # Extra QEMU parameters
|
||||||
: ${CPU_CORES:='1'} # Amount of CPU cores
|
: ${CPU_CORES:='1'} # Amount of CPU cores
|
||||||
|
: ${RAM_SIZE:='1G'} # Maximum RAM amount
|
||||||
: ${DISK_SIZE:='16G'} # Initial data disk size
|
: ${DISK_SIZE:='16G'} # Initial data disk size
|
||||||
: ${RAM_SIZE:='512M'} # Maximum RAM amount
|
|
||||||
|
|
||||||
# Helper variables
|
# Helper variables
|
||||||
|
|
||||||
@@ -25,15 +26,20 @@ MINOR=$(uname -r | cut -d '.' -f2)
|
|||||||
ARCH=$(dpkg --print-architecture)
|
ARCH=$(dpkg --print-architecture)
|
||||||
VERS=$(qemu-system-x86_64 --version | head -n 1 | cut -d '(' -f 1)
|
VERS=$(qemu-system-x86_64 --version | head -n 1 | cut -d '(' -f 1)
|
||||||
|
|
||||||
|
# Check folder
|
||||||
|
|
||||||
|
STORAGE="/storage"
|
||||||
|
[ ! -d "$STORAGE" ] && error "Storage folder (${STORAGE}) not found!" && exit 13
|
||||||
|
|
||||||
# Cleanup files
|
# Cleanup files
|
||||||
|
|
||||||
rm -f /run/dsm.url
|
rm -f /run/dsm.url
|
||||||
rm -f /run/qemu.pid
|
rm -f /run/qemu.pid
|
||||||
rm -f /run/qemu.count
|
rm -f /run/qemu.count
|
||||||
|
|
||||||
# Check folder
|
# Cleanup dirs
|
||||||
|
|
||||||
STORAGE="/storage"
|
rm -rf /tmp/dsm
|
||||||
[ ! -d "$STORAGE" ] && error "Storage folder (${STORAGE}) not found!" && exit 13
|
rm -rf "$STORAGE/tmp"
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ sleep 0.2
|
|||||||
while ! nc -z -w1 127.0.0.1 2210 > /dev/null 2>&1; do
|
while ! nc -z -w1 127.0.0.1 2210 > /dev/null 2>&1; do
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
cnt=$((cnt + 1))
|
cnt=$((cnt + 1))
|
||||||
(( cnt > 20 )) && error "Failed to connect to qemu-host.." && exit 58
|
(( cnt > 50 )) && error "Failed to connect to qemu-host.." && exit 58
|
||||||
done
|
done
|
||||||
|
|
||||||
cnt=0
|
cnt=0
|
||||||
@@ -56,7 +56,7 @@ cnt=0
|
|||||||
while ! nc -z -w1 127.0.0.1 12345 > /dev/null 2>&1; do
|
while ! nc -z -w1 127.0.0.1 12345 > /dev/null 2>&1; do
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
cnt=$((cnt + 1))
|
cnt=$((cnt + 1))
|
||||||
(( cnt > 20 )) && error "Failed to connect to qemu-host.." && exit 59
|
(( cnt > 50 )) && error "Failed to connect to qemu-host.." && exit 59
|
||||||
done
|
done
|
||||||
|
|
||||||
# Configure serial ports
|
# Configure serial ports
|
||||||
|
|||||||
Reference in New Issue
Block a user