mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-11-07 10:33:42 +08:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b588f8c90d | ||
|
|
1f1007a0f1 | ||
|
|
2ec37e2802 | ||
|
|
3126b3847b | ||
|
|
41e0157e9d | ||
|
|
1d64410849 | ||
|
|
55034b0f40 | ||
|
|
acffcf3774 | ||
|
|
fba0eb527b | ||
|
|
d9fc2714a6 | ||
|
|
d1f1772d74 | ||
|
|
bf1d47e4f3 | ||
|
|
3da564dfd1 | ||
|
|
abd30b9d91 | ||
|
|
c86408cbd6 | ||
|
|
1f51974c48 | ||
|
|
29f4cde296 | ||
|
|
c4a0035062 | ||
|
|
6724ddbd7d | ||
|
|
8d8ed63122 |
62
.github/ISSUE_TEMPLATE/1-issue.yml
vendored
Normal file
62
.github/ISSUE_TEMPLATE/1-issue.yml
vendored
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
name: "\U0001F6A8 Technical issue"
|
||||||
|
description: When you're experiencing problems using the container
|
||||||
|
body:
|
||||||
|
- type: checkboxes
|
||||||
|
attributes:
|
||||||
|
label: Is there no existing issue for this?
|
||||||
|
description: Please search to see if no solution was already provided before.
|
||||||
|
options:
|
||||||
|
- label: I have searched the existing issues
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: cpu
|
||||||
|
attributes:
|
||||||
|
label: Machine specifications
|
||||||
|
description: The processor and RAM amount in your machine.
|
||||||
|
placeholder: e.g. Intel N5105 / 16 GB
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: os
|
||||||
|
attributes:
|
||||||
|
label: Operating system
|
||||||
|
description: The distribution and kernel version (as shown by `uname -a`).
|
||||||
|
placeholder: e.g. Ubuntu 24.04 / Kernel 6.8.0-22-generic
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: docker
|
||||||
|
attributes:
|
||||||
|
label: Docker version
|
||||||
|
description: The version of the Docker engine (as shown by `docker -v`).
|
||||||
|
placeholder: e.g. 26.0.1
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: summary
|
||||||
|
attributes:
|
||||||
|
label: Description
|
||||||
|
description: A clear and concise description of your issue.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: compose
|
||||||
|
attributes:
|
||||||
|
label: Docker compose
|
||||||
|
description: The compose file (or otherwise the `docker run` command used).
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: log
|
||||||
|
attributes:
|
||||||
|
label: Docker log
|
||||||
|
description: The logfile of the container (as shown by `docker logs dsm`).
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: screenshot
|
||||||
|
attributes:
|
||||||
|
label: Screenshots (optional)
|
||||||
|
description: Screenshots that might help to make the problem more clear.
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
@@ -5,8 +5,8 @@ labels: ["enhancement"]
|
|||||||
body:
|
body:
|
||||||
- type: checkboxes
|
- type: checkboxes
|
||||||
attributes:
|
attributes:
|
||||||
label: Is there an existing feature request for this?
|
label: Is there no existing feature request for this?
|
||||||
description: Please search to see if the feature request already exists.
|
description: Please search to see if the feature was not already requested before.
|
||||||
options:
|
options:
|
||||||
- label: I have searched the existing feature requests
|
- label: I have searched the existing feature requests
|
||||||
required: true
|
required: true
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
name: "\U0001F41E Bug Report"
|
name: "\U0001F41E Bug report"
|
||||||
description: Create a report to help us improve the container
|
description: Create a report to help us improve the container
|
||||||
title: "[Bug]: "
|
title: "[Bug]: "
|
||||||
labels: ["bug"]
|
labels: ["bug"]
|
||||||
body:
|
body:
|
||||||
- type: checkboxes
|
- type: checkboxes
|
||||||
attributes:
|
attributes:
|
||||||
label: Is there an existing issue for this?
|
label: Is there no existing bug report for this?
|
||||||
description: Please search to see if an issue already exists for the bug you encountered.
|
description: Please search to see if the bug was not already reported before.
|
||||||
options:
|
options:
|
||||||
- label: I have searched the existing issues
|
- label: I have searched the existing bug reports
|
||||||
required: true
|
required: true
|
||||||
- type: input
|
- type: input
|
||||||
id: cpu
|
id: cpu
|
||||||
@@ -22,7 +22,7 @@ body:
|
|||||||
id: os
|
id: os
|
||||||
attributes:
|
attributes:
|
||||||
label: Operating system
|
label: Operating system
|
||||||
description: The Linux distribution and kernel version as shown by `uname -a`.
|
description: The distribution and kernel version (as shown by `uname -a`).
|
||||||
placeholder: e.g. Ubuntu 24.04 / Kernel 6.8.0-22-generic
|
placeholder: e.g. Ubuntu 24.04 / Kernel 6.8.0-22-generic
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
@@ -30,35 +30,35 @@ body:
|
|||||||
id: docker
|
id: docker
|
||||||
attributes:
|
attributes:
|
||||||
label: Docker version
|
label: Docker version
|
||||||
description: The Docker version as shown by `docker -v`.
|
description: The version of the Docker engine (as shown by `docker -v`).
|
||||||
placeholder: e.g. Docker version 26.0.1, build d260a54
|
placeholder: e.g. 26.0.1
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: summary
|
id: summary
|
||||||
attributes:
|
attributes:
|
||||||
label: Description
|
label: Description
|
||||||
description: A clear and concise description of the problem.
|
description: Describe the expected behaviour, the actual behaviour, and the steps to reproduce.
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: compose
|
id: compose
|
||||||
attributes:
|
attributes:
|
||||||
label: Docker compose
|
label: Docker compose
|
||||||
description: The Docker compose file (or otherwise `run` command).
|
description: The compose file (or otherwise the `docker run` command used).
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: log
|
id: log
|
||||||
attributes:
|
attributes:
|
||||||
label: Docker log
|
label: Docker log
|
||||||
description: The Docker logfile of the container.
|
description: The logfile of the container (as shown by `docker logs dsm`).
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: screenshot
|
id: screenshot
|
||||||
attributes:
|
attributes:
|
||||||
label: Screenshots (optional)
|
label: Screenshots (optional)
|
||||||
description: Screenshots of the problem.
|
description: Screenshots that might help to make the problem more clear.
|
||||||
validations:
|
validations:
|
||||||
required: false
|
required: false
|
||||||
26
.github/ISSUE_TEMPLATE/4-question.yml
vendored
Normal file
26
.github/ISSUE_TEMPLATE/4-question.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
name: "\U00002753 General question"
|
||||||
|
description: Questions about the container not related to an issue
|
||||||
|
title: "[Question]: "
|
||||||
|
labels: ["question"]
|
||||||
|
body:
|
||||||
|
- type: checkboxes
|
||||||
|
attributes:
|
||||||
|
label: Is your question not already answered in the FAQ?
|
||||||
|
description: Please read the [FAQ](https://github.com/vdsm/virtual-dsm/blob/master/readme.md) carefully to avoid asking duplicate questions.
|
||||||
|
options:
|
||||||
|
- label: I made sure the question is not listed in the [FAQ](https://github.com/vdsm/virtual-dsm/blob/master/readme.md).
|
||||||
|
required: true
|
||||||
|
- type: checkboxes
|
||||||
|
attributes:
|
||||||
|
label: Is this a general question and not a technical issue?
|
||||||
|
description: For questions related to issues you must use the [technical issue](https://github.com/vdsm/virtual-dsm/issues/new?assignees=&labels=&projects=&template=1-issue.yml) form instead. It contains all the right fields (system info, logfiles, etc.) we need in order to be able to help you.
|
||||||
|
options:
|
||||||
|
- label: I am sure my question is not about a technical issue.
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: question
|
||||||
|
attributes:
|
||||||
|
label: Question
|
||||||
|
description: What's the question you have about the container?
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
16
.github/ISSUE_TEMPLATE/QUESTION.yml
vendored
16
.github/ISSUE_TEMPLATE/QUESTION.yml
vendored
@@ -1,16 +0,0 @@
|
|||||||
name: "? Question"
|
|
||||||
description: General questions about the container
|
|
||||||
title: "[Question]: "
|
|
||||||
labels: ["question"]
|
|
||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
Please do not use this form for technical issues, and make sure to check the [FAQ](https://github.com/vdsm/virtual-dsm/blob/master/readme.md) first!
|
|
||||||
- type: textarea
|
|
||||||
id: question
|
|
||||||
attributes:
|
|
||||||
label: Question
|
|
||||||
description: What's the question you have about the container?
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
24
Dockerfile
24
Dockerfile
@@ -10,11 +10,13 @@ FROM qemux/qemu-host:2.04 as builder
|
|||||||
FROM debian:trixie-slim
|
FROM debian:trixie-slim
|
||||||
|
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
ARG DEBCONF_NOWARNINGS "yes"
|
ARG VERSION_ARG="0.0"
|
||||||
ARG DEBIAN_FRONTEND "noninteractive"
|
ARG DEBCONF_NOWARNINGS="yes"
|
||||||
ARG DEBCONF_NONINTERACTIVE_SEEN "true"
|
ARG DEBIAN_FRONTEND="noninteractive"
|
||||||
|
ARG DEBCONF_NONINTERACTIVE_SEEN="true"
|
||||||
|
|
||||||
RUN if [ "$TARGETPLATFORM" != "linux/amd64" ]; then extra="qemu-user"; fi && \
|
RUN set -eu && extra="" && \
|
||||||
|
if [ "$TARGETPLATFORM" != "linux/amd64" ]; then extra="qemu-user"; fi && \
|
||||||
apt-get update && \
|
apt-get update && \
|
||||||
apt-get --no-install-recommends -y install \
|
apt-get --no-install-recommends -y install \
|
||||||
jq \
|
jq \
|
||||||
@@ -41,14 +43,13 @@ RUN if [ "$TARGETPLATFORM" != "linux/amd64" ]; then extra="qemu-user"; fi && \
|
|||||||
apt-get clean && \
|
apt-get clean && \
|
||||||
unlink /etc/nginx/sites-enabled/default && \
|
unlink /etc/nginx/sites-enabled/default && \
|
||||||
sed -i 's/^worker_processes.*/worker_processes 1;/' /etc/nginx/nginx.conf && \
|
sed -i 's/^worker_processes.*/worker_processes 1;/' /etc/nginx/nginx.conf && \
|
||||||
|
echo "$VERSION_ARG" > /run/version && \
|
||||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||||
|
|
||||||
COPY ./src /run/
|
COPY --chmod=755 ./src /run/
|
||||||
COPY ./web /var/www/
|
COPY --chmod=755 ./web /var/www/
|
||||||
COPY --from=builder /qemu-host.bin /run/host.bin
|
COPY --chmod=755 --from=builder /qemu-host.bin /run/host.bin
|
||||||
|
COPY --chmod=744 ./web/nginx.conf /etc/nginx/sites-enabled/web.conf
|
||||||
RUN chmod +x /run/*.sh && chmod +x /run/*.bin
|
|
||||||
RUN mv /var/www/nginx.conf /etc/nginx/sites-enabled/web.conf
|
|
||||||
|
|
||||||
VOLUME /storage
|
VOLUME /storage
|
||||||
EXPOSE 22 139 445 5000
|
EXPOSE 22 139 445 5000
|
||||||
@@ -57,9 +58,6 @@ ENV RAM_SIZE "1G"
|
|||||||
ENV DISK_SIZE "16G"
|
ENV DISK_SIZE "16G"
|
||||||
ENV CPU_CORES "1"
|
ENV CPU_CORES "1"
|
||||||
|
|
||||||
ARG VERSION_ARG "0.0"
|
|
||||||
RUN echo "$VERSION_ARG" > /run/version
|
|
||||||
|
|
||||||
HEALTHCHECK --interval=60s --start-period=45s --retries=2 CMD /run/check.sh
|
HEALTHCHECK --interval=60s --start-period=45s --retries=2 CMD /run/check.sh
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/bin/tini", "-s", "/run/entry.sh"]
|
ENTRYPOINT ["/usr/bin/tini", "-s", "/run/entry.sh"]
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
version: "3"
|
|
||||||
services:
|
services:
|
||||||
dsm:
|
dsm:
|
||||||
container_name: dsm
|
container_name: dsm
|
||||||
@@ -13,5 +12,4 @@ services:
|
|||||||
- 5000:5000
|
- 5000:5000
|
||||||
volumes:
|
volumes:
|
||||||
- /var/dsm:/storage
|
- /var/dsm:/storage
|
||||||
restart: on-failure
|
|
||||||
stop_grace_period: 2m
|
stop_grace_period: 2m
|
||||||
|
|||||||
58
kubernetes.yml
Normal file
58
kubernetes.yml
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: dsm-pvc
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 16Gi
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
name: dsm
|
||||||
|
labels:
|
||||||
|
name: dsm
|
||||||
|
spec:
|
||||||
|
terminationGracePeriodSeconds: 120 # the Kubernetes default is 30 seconds and it may be not enough
|
||||||
|
containers:
|
||||||
|
- name: dsm
|
||||||
|
image: vdsm/virtual-dsm
|
||||||
|
ports:
|
||||||
|
- containerPort: 5000
|
||||||
|
protocol: TCP
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
devices.kubevirt.io/kvm: 1
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
|
env:
|
||||||
|
- name: RAM_SIZE
|
||||||
|
value: 1G
|
||||||
|
- name: CPU_CORES
|
||||||
|
value: "1"
|
||||||
|
- name: DISK_SIZE
|
||||||
|
value: "16G" # Kubernetes uses Gi, but DSM uses GB
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /storage
|
||||||
|
name: storage
|
||||||
|
volumes:
|
||||||
|
- name: storage
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: dsm-pvc
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: dsm
|
||||||
|
spec:
|
||||||
|
type: NodePort
|
||||||
|
selector:
|
||||||
|
name: dsm
|
||||||
|
ports:
|
||||||
|
- name: tcp-5000
|
||||||
|
port: 5000
|
||||||
|
targetPort: 5000
|
||||||
|
nodePort: 31150
|
||||||
49
readme.md
49
readme.md
@@ -24,7 +24,6 @@ Virtual DSM in a Docker container.
|
|||||||
Via Docker Compose:
|
Via Docker Compose:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
version: "3"
|
|
||||||
services:
|
services:
|
||||||
dsm:
|
dsm:
|
||||||
container_name: dsm
|
container_name: dsm
|
||||||
@@ -39,14 +38,19 @@ services:
|
|||||||
- 5000:5000
|
- 5000:5000
|
||||||
volumes:
|
volumes:
|
||||||
- /var/dsm:/storage
|
- /var/dsm:/storage
|
||||||
restart: on-failure
|
|
||||||
stop_grace_period: 2m
|
stop_grace_period: 2m
|
||||||
```
|
```
|
||||||
|
|
||||||
Via Docker CLI:
|
Via Docker CLI:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -it --rm --name dsm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-timeout 120 vdsm/virtual-dsm
|
docker run -it --name dsm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-timeout 120 vdsm/virtual-dsm
|
||||||
|
```
|
||||||
|
|
||||||
|
Via Kubernetes:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
kubectl apply -f kubernetes.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
## FAQ
|
## FAQ
|
||||||
@@ -61,17 +65,6 @@ docker run -it --rm --name dsm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMI
|
|||||||
|
|
||||||
Enjoy your brand new machine, and don't forget to star this repo!
|
Enjoy your brand new machine, and don't forget to star this repo!
|
||||||
|
|
||||||
* ### How do I change the size of the disk?
|
|
||||||
|
|
||||||
To expand the default size of 16 GB, locate the `DISK_SIZE` setting in your compose file and modify it to your preferred capacity:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
environment:
|
|
||||||
DISK_SIZE: "128G"
|
|
||||||
```
|
|
||||||
|
|
||||||
This can also be used to resize the existing disk to a larger capacity without any data loss.
|
|
||||||
|
|
||||||
* ### How do I change the storage location?
|
* ### How do I change the storage location?
|
||||||
|
|
||||||
To change the storage location, include the following bind mount in your compose file:
|
To change the storage location, include the following bind mount in your compose file:
|
||||||
@@ -82,6 +75,17 @@ docker run -it --rm --name dsm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMI
|
|||||||
```
|
```
|
||||||
|
|
||||||
Replace the example path `/var/dsm` with the desired storage folder.
|
Replace the example path `/var/dsm` with the desired storage folder.
|
||||||
|
|
||||||
|
* ### How do I change the size of the disk?
|
||||||
|
|
||||||
|
To expand the default size of 16 GB, locate the `DISK_SIZE` setting in your compose file and modify it to your preferred capacity:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
environment:
|
||||||
|
DISK_SIZE: "128G"
|
||||||
|
```
|
||||||
|
|
||||||
|
This can also be used to resize the existing disk to a larger capacity without any data loss.
|
||||||
|
|
||||||
* ### How do I create a growable disk?
|
* ### How do I create a growable disk?
|
||||||
|
|
||||||
@@ -115,10 +119,12 @@ docker run -it --rm --name dsm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMI
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
devices:
|
devices:
|
||||||
- /dev/disk/by-uuid/12345-12345-12345-12345-12345:/dev/disk2
|
- /dev/disk/by-uuid/12345-12345-12345-12345-12345:/disk2
|
||||||
- /dev/disk/by-uuid/45678-45678-45678-45678-45678:/dev/disk3
|
- /dev/disk/by-uuid/45678-45678-45678-45678-45678:/disk3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Make sure to bind the disk via its UUID (obtainable via `lsblk -o name,uuid`) instead of its name (`/dev/sdc`), to prevent ever binding the wrong disk when the drive letters happen to change.
|
||||||
|
|
||||||
Please note that the device needs to be totally empty (without any partition table) otherwise DSM does not always format it into a volume.
|
Please note that the device needs to be totally empty (without any partition table) otherwise DSM does not always format it into a volume.
|
||||||
|
|
||||||
Do NOT use this feature with the goal of sharing files from the host, they will all be lost without warning when DSM creates the volume.
|
Do NOT use this feature with the goal of sharing files from the host, they will all be lost without warning when DSM creates the volume.
|
||||||
@@ -127,7 +133,7 @@ docker run -it --rm --name dsm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMI
|
|||||||
|
|
||||||
By default, a single CPU core and 1 GB of RAM are allocated to the container.
|
By default, a single CPU core and 1 GB of RAM are allocated to the container.
|
||||||
|
|
||||||
To increase this, add the following environment variables:
|
If there arises a need to increase this, add the following environment variables:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
environment:
|
environment:
|
||||||
@@ -223,6 +229,15 @@ docker run -it --rm --name dsm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMI
|
|||||||
|
|
||||||
With this method, it is even possible to switch between different versions while keeping all your file data intact.
|
With this method, it is even possible to switch between different versions while keeping all your file data intact.
|
||||||
|
|
||||||
|
If you don't have internet access, it's also possible to skip the download by setting URL to:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
environment:
|
||||||
|
URL: "DSM_VirtualDSM_42218.pat"
|
||||||
|
```
|
||||||
|
|
||||||
|
after placing a file called `DSM_VirtualDSM_42218.pat` in your `/storage` folder.
|
||||||
|
|
||||||
* ### 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.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
DEF_OPTS="-nodefaults -boot strict=on"
|
DEF_OPTS="-nodefaults -boot strict=on"
|
||||||
RAM_OPTS=$(echo "-m $RAM_SIZE" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
|
RAM_OPTS=$(echo "-m ${RAM_SIZE^^}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
|
||||||
CPU_OPTS="-cpu $CPU_FLAGS -smp $CPU_CORES,sockets=1,dies=1,cores=$CPU_CORES,threads=1"
|
CPU_OPTS="-cpu $CPU_FLAGS -smp $CPU_CORES,sockets=1,dies=1,cores=$CPU_CORES,threads=1"
|
||||||
MAC_OPTS="-machine type=q35,usb=off,vmport=off,dump-guest-core=off,hpet=off${KVM_OPTS}"
|
MAC_OPTS="-machine type=q35,usb=off,vmport=off,dump-guest-core=off,hpet=off${KVM_OPTS}"
|
||||||
DEV_OPTS="-device virtio-balloon-pci,id=balloon0,bus=pcie.0,addr=0x4"
|
DEV_OPTS="-device virtio-balloon-pci,id=balloon0,bus=pcie.0,addr=0x4"
|
||||||
@@ -12,4 +12,18 @@ DEV_OPTS="$DEV_OPTS -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pcie.0,addr=0
|
|||||||
ARGS="$DEF_OPTS $CPU_OPTS $RAM_OPTS $MAC_OPTS $DISPLAY_OPTS $MON_OPTS $SERIAL_OPTS $NET_OPTS $DISK_OPTS $DEV_OPTS $ARGUMENTS"
|
ARGS="$DEF_OPTS $CPU_OPTS $RAM_OPTS $MAC_OPTS $DISPLAY_OPTS $MON_OPTS $SERIAL_OPTS $NET_OPTS $DISK_OPTS $DEV_OPTS $ARGUMENTS"
|
||||||
ARGS=$(echo "$ARGS" | sed 's/\t/ /g' | tr -s ' ')
|
ARGS=$(echo "$ARGS" | sed 's/\t/ /g' | tr -s ' ')
|
||||||
|
|
||||||
|
# Check available memory as the very last step
|
||||||
|
|
||||||
|
RAM_AVAIL=$(free -b | grep -m 1 Mem: | awk '{print $7}')
|
||||||
|
AVAIL_GB=$(( (RAM_AVAIL + 1073741823)/1073741824 ))
|
||||||
|
|
||||||
|
if (( (RAM_WANTED + 500000000) > RAM_AVAIL )); then
|
||||||
|
error "Your configured RAM_SIZE of $WANTED_GB GB is higher than the $AVAIL_GB GB of memory available, please set a lower value."
|
||||||
|
exit 17
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( (RAM_WANTED + 1450000000) > RAM_AVAIL )); then
|
||||||
|
warn "your configured RAM_SIZE of $WANTED_GB GB is much too close to the $AVAIL_GB GB of memory available, please set a lower value."
|
||||||
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -527,6 +527,12 @@ DISK4_FILE="/storage4/data4"
|
|||||||
: "${DEVICE3:=""}"
|
: "${DEVICE3:=""}"
|
||||||
: "${DEVICE4:=""}"
|
: "${DEVICE4:=""}"
|
||||||
|
|
||||||
|
[ -z "$DEVICE" ] && [ -b "/disk" ] && DEVICE="/disk"
|
||||||
|
[ -z "$DEVICE" ] && [ -b "/disk1" ] && DEVICE="/disk1"
|
||||||
|
[ -z "$DEVICE2" ] && [ -b "/disk2" ] && DEVICE2="/disk2"
|
||||||
|
[ -z "$DEVICE3" ] && [ -b "/disk3" ] && DEVICE3="/disk3"
|
||||||
|
[ -z "$DEVICE4" ] && [ -b "/disk4" ] && DEVICE4="/disk4"
|
||||||
|
|
||||||
[ -z "$DEVICE" ] && [ -b "/dev/disk1" ] && DEVICE="/dev/disk1"
|
[ -z "$DEVICE" ] && [ -b "/dev/disk1" ] && DEVICE="/dev/disk1"
|
||||||
[ -z "$DEVICE2" ] && [ -b "/dev/disk2" ] && DEVICE2="/dev/disk2"
|
[ -z "$DEVICE2" ] && [ -b "/dev/disk2" ] && DEVICE2="/dev/disk2"
|
||||||
[ -z "$DEVICE3" ] && [ -b "/dev/disk3" ] && DEVICE3="/dev/disk3"
|
[ -z "$DEVICE3" ] && [ -b "/dev/disk3" ] && DEVICE3="/dev/disk3"
|
||||||
|
|||||||
@@ -18,6 +18,13 @@ if [ -n "$URL" ]; then
|
|||||||
: "${BASE//+/ }"; printf -v BASE '%b' "${_//%/\\x}"
|
: "${BASE//+/ }"; printf -v BASE '%b' "${_//%/\\x}"
|
||||||
BASE=$(echo "$BASE" | sed -e 's/[^A-Za-z0-9._-]/_/g')
|
BASE=$(echo "$BASE" | sed -e 's/[^A-Za-z0-9._-]/_/g')
|
||||||
fi
|
fi
|
||||||
|
if [[ "${URL,,}" != "http"* ]]; then
|
||||||
|
if [ -s "$STORAGE/$BASE.pat" ]; then
|
||||||
|
URL="file://$STORAGE/$BASE.pat"
|
||||||
|
else
|
||||||
|
error "File $STORAGE/$BASE.pat does not exist!" && exit 65
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -s "$STORAGE/$BASE.boot.img" ]] && [[ -s "$STORAGE/$BASE.system.img" ]]; then
|
if [[ -s "$STORAGE/$BASE.boot.img" ]] && [[ -s "$STORAGE/$BASE.system.img" ]]; then
|
||||||
@@ -109,26 +116,41 @@ fi
|
|||||||
# Download the required files from the Synology website
|
# Download the required files from the Synology website
|
||||||
|
|
||||||
ROOT="Y"
|
ROOT="Y"
|
||||||
|
RD="$TMP/rd.gz"
|
||||||
RDC="$STORAGE/dsm.rd"
|
RDC="$STORAGE/dsm.rd"
|
||||||
|
|
||||||
|
if [ ! -s "$RDC" ] && [[ "$URL" == "file://"* ]] && [[ "${URL,,}" == *"_42218.pat" ]]; then
|
||||||
|
|
||||||
|
rm -f "$RD"
|
||||||
|
rm -f "$RDC"
|
||||||
|
|
||||||
|
tar --extract --file="${URL:7}" --directory="$(dirname "$RD")"/. "$(basename "$RD")"
|
||||||
|
cp "$RD" "$RDC"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -s "$RDC" ]; then
|
if [ ! -s "$RDC" ]; then
|
||||||
|
|
||||||
|
rm -f "$RD"
|
||||||
|
rm -f "$RDC"
|
||||||
|
|
||||||
MSG="Downloading installer..."
|
MSG="Downloading installer..."
|
||||||
PRG="Downloading installer ([P])..."
|
PRG="Downloading installer ([P])..."
|
||||||
info "Install: $MSG" && html "$MSG"
|
info "Install: $MSG" && html "$MSG"
|
||||||
|
|
||||||
RD="$TMP/rd.gz"
|
SIZE=5394188
|
||||||
POS="65627648-71021835"
|
POS="65627648-71021835"
|
||||||
VERIFY="b4215a4b213ff5154db0488f92c87864"
|
VERIFY="b4215a4b213ff5154db0488f92c87864"
|
||||||
LOC="$DL/release/7.0.1/42218/DSM_VirtualDSM_42218.pat"
|
LOC="$DL/release/7.0.1/42218/DSM_VirtualDSM_42218.pat"
|
||||||
|
[[ "${URL,,}" == *"_42218.pat" ]] && LOC="$URL"
|
||||||
|
|
||||||
rm -f "$RD"
|
/run/progress.sh "$RD" "$SIZE" "$PRG" &
|
||||||
rm -f "$RDC"
|
{ curl -r "$POS" -sfk --connect-timeout 10 -S -o "$RD" "$LOC"; rc=$?; } || :
|
||||||
/run/progress.sh "$RD" "$PRG" &
|
|
||||||
{ curl -r "$POS" -sfk -S -o "$RD" "$LOC"; rc=$?; } || :
|
|
||||||
|
|
||||||
fKill "progress.sh"
|
fKill "progress.sh"
|
||||||
|
|
||||||
|
(( rc == 4 )) && error "Failed to download $LOC , network failure!" && exit 60
|
||||||
|
|
||||||
if (( rc != 0 )); then
|
if (( rc != 0 )); then
|
||||||
if (( rc != 22 )) && (( rc != 56 )); then
|
if (( rc != 22 )) && (( rc != 56 )); then
|
||||||
error "Failed to download $LOC, reason: $rc" && exit 60
|
error "Failed to download $LOC, reason: $rc" && exit 60
|
||||||
@@ -141,14 +163,17 @@ if [ ! -s "$RDC" ]; then
|
|||||||
if [ "$SUM" != "$VERIFY" ]; then
|
if [ "$SUM" != "$VERIFY" ]; then
|
||||||
|
|
||||||
PAT="/install.pat"
|
PAT="/install.pat"
|
||||||
|
SIZE=379637760
|
||||||
|
|
||||||
rm -f "$RD"
|
rm -f "$RD"
|
||||||
rm -f "$PAT"
|
rm -f "$PAT"
|
||||||
|
|
||||||
html "$MSG"
|
html "$MSG"
|
||||||
/run/progress.sh "$PAT" "$PRG" &
|
/run/progress.sh "$PAT" "$SIZE" "$PRG" &
|
||||||
{ wget "$LOC" -O "$PAT" -q --no-check-certificate --show-progress "$PROGRESS"; rc=$?; } || :
|
{ wget "$LOC" -O "$PAT" -q --no-check-certificate --timeout=10 --show-progress "$PROGRESS"; rc=$?; } || :
|
||||||
|
|
||||||
fKill "progress.sh"
|
fKill "progress.sh"
|
||||||
|
(( rc == 4 )) && error "Failed to download $LOC , network failure!" && exit 60
|
||||||
(( rc != 0 )) && error "Failed to download $LOC , reason: $rc" && exit 60
|
(( rc != 0 )) && error "Failed to download $LOC , reason: $rc" && exit 60
|
||||||
|
|
||||||
tar --extract --file="$PAT" --directory="$(dirname "$RD")"/. "$(basename "$RD")"
|
tar --extract --file="$PAT" --directory="$(dirname "$RD")"/. "$(basename "$RD")"
|
||||||
@@ -214,11 +239,16 @@ if [[ "$URL" == "file://"* ]]; then
|
|||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
/run/progress.sh "$PAT" "$PRG" &
|
SIZE=0
|
||||||
|
[[ "${URL,,}" == *"_69057.pat" ]] && SIZE=363837333
|
||||||
|
[[ "${URL,,}" == *"_42218.pat" ]] && SIZE=379637760
|
||||||
|
|
||||||
{ wget "$URL" -O "$PAT" -q --no-check-certificate --show-progress "$PROGRESS"; rc=$?; } || :
|
/run/progress.sh "$PAT" "$SIZE" "$PRG" &
|
||||||
|
|
||||||
|
{ wget "$URL" -O "$PAT" -q --no-check-certificate --timeout=10 --show-progress "$PROGRESS"; rc=$?; } || :
|
||||||
|
|
||||||
fKill "progress.sh"
|
fKill "progress.sh"
|
||||||
|
(( rc == 4 )) && error "Failed to download $URL , network failure!" && exit 69
|
||||||
(( rc != 0 )) && error "Failed to download $URL , reason: $rc" && exit 69
|
(( rc != 0 )) && error "Failed to download $URL , reason: $rc" && exit 69
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -240,6 +240,23 @@ closeNetwork() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkOS() {
|
||||||
|
|
||||||
|
local name
|
||||||
|
local os=""
|
||||||
|
name=$(uname -a)
|
||||||
|
|
||||||
|
[[ "${name,,}" == *"darwin"* ]] && os="MacOS"
|
||||||
|
[[ "${name,,}" == *"microsoft"* ]] && os="Windows"
|
||||||
|
|
||||||
|
if [ -n "$os" ]; then
|
||||||
|
error "You are using Docker Desktop for $os which does not support macvlan, please revert to bridge networking!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
getInfo() {
|
getInfo() {
|
||||||
|
|
||||||
if [ -z "$VM_NET_DEV" ]; then
|
if [ -z "$VM_NET_DEV" ]; then
|
||||||
@@ -306,6 +323,8 @@ fi
|
|||||||
|
|
||||||
if [[ "$DHCP" == [Yy1]* ]]; then
|
if [[ "$DHCP" == [Yy1]* ]]; then
|
||||||
|
|
||||||
|
! checkOS && exit 19
|
||||||
|
|
||||||
if [[ "$GATEWAY" == "172."* ]]; then
|
if [[ "$GATEWAY" == "172."* ]]; then
|
||||||
warn "your gateway IP starts with 172.* which is often a sign that you are not on a macvlan network (required for DHCP)!"
|
warn "your gateway IP starts with 172.* which is often a sign that you are not on a macvlan network (required for DHCP)!"
|
||||||
fi
|
fi
|
||||||
@@ -318,6 +337,10 @@ if [[ "$DHCP" == [Yy1]* ]]; then
|
|||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
|
if [[ "$GATEWAY" != "172."* ]]; then
|
||||||
|
! checkOS && exit 19
|
||||||
|
fi
|
||||||
|
|
||||||
# Shutdown nginx
|
# Shutdown nginx
|
||||||
nginx -s stop 2> /dev/null
|
nginx -s stop 2> /dev/null
|
||||||
fWait "nginx"
|
fWait "nginx"
|
||||||
|
|||||||
19
src/proc.sh
19
src/proc.sh
@@ -9,7 +9,10 @@ set -Eeuo pipefail
|
|||||||
: "${CPU_MODEL:=""}"
|
: "${CPU_MODEL:=""}"
|
||||||
: "${DEF_MODEL:="qemu64"}"
|
: "${DEF_MODEL:="qemu64"}"
|
||||||
|
|
||||||
[ "$ARCH" != "amd64" ] && KVM="N"
|
if [[ "${ARCH,,}" != "amd64" ]]; then
|
||||||
|
KVM="N"
|
||||||
|
warn "your CPU architecture is ${ARCH^^} and cannot provide KVM acceleration for x64 instructions, this will cause a major loss of performance."
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$KVM" != [Nn]* ]]; then
|
if [[ "$KVM" != [Nn]* ]]; then
|
||||||
|
|
||||||
@@ -30,9 +33,17 @@ if [[ "$KVM" != [Nn]* ]]; then
|
|||||||
|
|
||||||
if [ -n "$KVM_ERR" ]; then
|
if [ -n "$KVM_ERR" ]; then
|
||||||
KVM="N"
|
KVM="N"
|
||||||
error "KVM acceleration not available $KVM_ERR, this will cause a major loss of performance."
|
if [[ "$OSTYPE" =~ ^darwin ]]; then
|
||||||
error "See the FAQ on how to enable it, or continue without KVM by setting KVM=N (not recommended)."
|
warn "you are using MacOS which has no KVM support, this will cause a major loss of performance."
|
||||||
[[ "$DEBUG" != [Yy1]* ]] && exit 88
|
else
|
||||||
|
if grep -qi Microsoft /proc/version; then
|
||||||
|
warn "you are using Windows 10 which has no KVM support, this will cause a major loss of performance."
|
||||||
|
else
|
||||||
|
error "KVM acceleration not available $KVM_ERR, this will cause a major loss of performance."
|
||||||
|
error "See the FAQ on how to enable it, or continue without KVM by setting KVM=N (not recommended)."
|
||||||
|
[[ "$DEBUG" != [Yy1]* ]] && exit 88
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ escape () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
file="$1"
|
file="$1"
|
||||||
body=$(escape "$2")
|
total="$2"
|
||||||
|
body=$(escape "$3")
|
||||||
info="/run/shm/msg.html"
|
info="/run/shm/msg.html"
|
||||||
|
|
||||||
if [[ "$body" == *"..." ]]; then
|
if [[ "$body" == *"..." ]]; then
|
||||||
@@ -24,7 +25,12 @@ do
|
|||||||
if [ -s "$file" ]; then
|
if [ -s "$file" ]; then
|
||||||
bytes=$(du -sb "$file" | cut -f1)
|
bytes=$(du -sb "$file" | cut -f1)
|
||||||
if (( bytes > 1000 )); then
|
if (( bytes > 1000 )); then
|
||||||
size=$(echo "$bytes" | numfmt --to=iec --suffix=B | sed -r 's/([A-Z])/ \1/')
|
if [ -z "$total" ] || [[ "$total" == "0" ]]; then
|
||||||
|
size=$(numfmt --to=iec --suffix=B "$bytes" | sed -r 's/([A-Z])/ \1/')
|
||||||
|
else
|
||||||
|
size=$(printf '%.1f\n' "$((bytes*100*100/total))e-2")
|
||||||
|
size="$size%"
|
||||||
|
fi
|
||||||
echo "${body//(\[P\])/($size)}"> "$info"
|
echo "${body//(\[P\])/($size)}"> "$info"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
19
src/reset.sh
19
src/reset.sh
@@ -42,7 +42,6 @@ HOST=$(hostname -s)
|
|||||||
KERNEL=$(echo "$SYS" | cut -b 1)
|
KERNEL=$(echo "$SYS" | cut -b 1)
|
||||||
MINOR=$(echo "$SYS" | cut -d '.' -f2)
|
MINOR=$(echo "$SYS" | cut -d '.' -f2)
|
||||||
ARCH=$(dpkg --print-architecture)
|
ARCH=$(dpkg --print-architecture)
|
||||||
RAM="$(free -g | grep Mem: | awk '{print $7}')/$(free -g | grep Mem: | awk '{print $2}') GB"
|
|
||||||
CPU=$(lscpu | grep -m 1 'Model name' | cut -f 2 -d ":" | awk '{$1=$1}1' | sed 's# @.*##g' | sed s/"(R)"//g | sed 's/[^[:alnum:] ]\+/ /g' | sed 's/ */ /g')
|
CPU=$(lscpu | grep -m 1 'Model name' | cut -f 2 -d ":" | awk '{$1=$1}1' | sed 's# @.*##g' | sed s/"(R)"//g | sed 's/[^[:alnum:] ]\+/ /g' | sed 's/ */ /g')
|
||||||
|
|
||||||
# Check system
|
# Check system
|
||||||
@@ -67,15 +66,31 @@ if [[ "${FS,,}" == "ecryptfs" ]] || [[ "${FS,,}" == "tmpfs" ]]; then
|
|||||||
DISK_CACHE="writeback"
|
DISK_CACHE="writeback"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Read memory
|
||||||
|
RAM_AVAIL=$(free -b | grep -m 1 Mem: | awk '{print $7}')
|
||||||
|
RAM_TOTAL=$(free -b | grep -m 1 Mem: | awk '{print $2}')
|
||||||
|
RAM_SIZE=$(echo "${RAM_SIZE^^}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
|
||||||
|
RAM_WANTED=$(numfmt --from=iec "$RAM_SIZE")
|
||||||
|
AVAIL_GB=$(( (RAM_AVAIL + 1073741823)/1073741824 ))
|
||||||
|
TOTAL_GB=$(( (RAM_TOTAL + 1073741823)/1073741824 ))
|
||||||
|
WANTED_GB=$(( (RAM_WANTED + 1073741823)/1073741824 ))
|
||||||
|
|
||||||
# Print system info
|
# Print system info
|
||||||
SYS="${SYS/-generic/}"
|
SYS="${SYS/-generic/}"
|
||||||
FS="${FS/ext2\/ext3/ext4}"
|
FS="${FS/ext2\/ext3/ext4}"
|
||||||
SPACE=$(df --output=avail -B 1 "$STORAGE" | tail -n 1)
|
SPACE=$(df --output=avail -B 1 "$STORAGE" | tail -n 1)
|
||||||
SPACE_GB=$(( (SPACE + 1073741823)/1073741824 ))
|
SPACE_GB=$(( (SPACE + 1073741823)/1073741824 ))
|
||||||
|
|
||||||
echo "❯ CPU: ${CPU} | RAM: ${RAM} | DISK: $SPACE_GB GB (${FS}) | HOST: ${SYS}..."
|
echo "❯ CPU: ${CPU} | RAM: $AVAIL_GB/$TOTAL_GB GB | DISK: $SPACE_GB GB (${FS}) | HOST: ${SYS}..."
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
# Check memory
|
||||||
|
|
||||||
|
if (( (RAM_WANTED + 500000000) > RAM_AVAIL )); then
|
||||||
|
error "Your configured RAM_SIZE of $WANTED_GB GB is higher than the $AVAIL_GB GB of memory available, please set a lower value."
|
||||||
|
exit 17
|
||||||
|
fi
|
||||||
|
|
||||||
# Cleanup files
|
# Cleanup files
|
||||||
rm -f /run/shm/qemu.*
|
rm -f /run/shm/qemu.*
|
||||||
rm -f /run/shm/dsm.url
|
rm -f /run/shm/dsm.url
|
||||||
|
|||||||
Reference in New Issue
Block a user