mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-11-07 02:23:42 +08:00
Compare commits
40 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1e9936572 | ||
|
|
3675a50129 | ||
|
|
91229152bd | ||
|
|
a1993e590a | ||
|
|
52fe712b6f | ||
|
|
7f400b6b59 | ||
|
|
9cb88a99e6 | ||
|
|
b967a471b5 | ||
|
|
f40127df01 | ||
|
|
8c5e0ee274 | ||
|
|
2adf0b292b | ||
|
|
1c9b793c75 | ||
|
|
00c4ef7795 | ||
|
|
619657adf2 | ||
|
|
41db7c1035 | ||
|
|
d71834a777 | ||
|
|
d078af0397 | ||
|
|
2827d1d375 | ||
|
|
898499a4e3 | ||
|
|
eb010cc215 | ||
|
|
84440d5159 | ||
|
|
ff3744ead9 | ||
|
|
d00fe4b3eb | ||
|
|
72a86a5d7f | ||
|
|
811ab622df | ||
|
|
e76b72cddf | ||
|
|
e9edacc9c3 | ||
|
|
a6694a6b29 | ||
|
|
59323cd375 | ||
|
|
6dc714e449 | ||
|
|
5d75a9b039 | ||
|
|
92b4cf5997 | ||
|
|
906e61b1b2 | ||
|
|
dab230f9d5 | ||
|
|
5e8bcda9fc | ||
|
|
d4bf83ae86 | ||
|
|
8244a48511 | ||
|
|
43ffa18a5f | ||
|
|
b131a32d0c | ||
|
|
c81787b837 |
@@ -35,12 +35,16 @@ RUN set -eu && extra="" && \
|
||||
dnsmasq \
|
||||
fakeroot \
|
||||
net-tools \
|
||||
e2fsprogs \
|
||||
qemu-utils \
|
||||
iputils-ping \
|
||||
ca-certificates \
|
||||
netcat-openbsd \
|
||||
qemu-system-x86 \
|
||||
"$extra" && \
|
||||
apt-get clean && \
|
||||
mkdir -p /etc/qemu && \
|
||||
echo "allow br0" > /etc/qemu/bridge.conf && \
|
||||
unlink /etc/nginx/sites-enabled/default && \
|
||||
sed -i 's/^worker_processes.*/worker_processes 1;/' /etc/nginx/nginx.conf && \
|
||||
echo "$VERSION_ARG" > /run/version && \
|
||||
@@ -49,7 +53,7 @@ RUN set -eu && extra="" && \
|
||||
COPY --chmod=755 ./src /run/
|
||||
COPY --chmod=755 ./web /var/www/
|
||||
COPY --chmod=755 --from=builder /qemu-host.bin /run/host.bin
|
||||
COPY --chmod=744 ./web/nginx.conf /etc/nginx/sites-enabled/web.conf
|
||||
COPY --chmod=744 ./web/conf/nginx.conf /etc/nginx/sites-enabled/web.conf
|
||||
|
||||
VOLUME /storage
|
||||
EXPOSE 22 139 445 5000
|
||||
|
||||
@@ -6,6 +6,7 @@ services:
|
||||
DISK_SIZE: "16G"
|
||||
devices:
|
||||
- /dev/kvm
|
||||
- /dev/net/tun
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
ports:
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
@@ -16,44 +17,51 @@ metadata:
|
||||
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
|
||||
securityContext:
|
||||
privileged: true
|
||||
env:
|
||||
- name: RAM_SIZE
|
||||
value: 1G
|
||||
value: "1G"
|
||||
- name: CPU_CORES
|
||||
value: "1"
|
||||
- name: DISK_SIZE
|
||||
value: "16G" # Kubernetes uses Gi, but DSM uses GB
|
||||
value: "16G"
|
||||
ports:
|
||||
- containerPort: 5000
|
||||
securityContext:
|
||||
capabilities:
|
||||
add:
|
||||
- NET_ADMIN
|
||||
privileged: true
|
||||
volumeMounts:
|
||||
- mountPath: /storage
|
||||
name: storage
|
||||
- mountPath: /dev/kvm
|
||||
name: dev-kvm
|
||||
- mountPath: /dev/net/tun
|
||||
name: dev-tun
|
||||
terminationGracePeriodSeconds: 120
|
||||
volumes:
|
||||
- name: storage
|
||||
persistentVolumeClaim:
|
||||
claimName: dsm-pvc
|
||||
- name: dev-kvm
|
||||
hostPath:
|
||||
- hostPath:
|
||||
path: /dev/kvm
|
||||
name: dev-kvm
|
||||
- hostPath:
|
||||
path: /dev/net/tun
|
||||
type: CharDevice
|
||||
name: dev-tun
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: dsm
|
||||
spec:
|
||||
type: NodePort
|
||||
selector:
|
||||
name: dsm
|
||||
ports:
|
||||
- name: tcp-5000
|
||||
port: 5000
|
||||
targetPort: 5000
|
||||
selector:
|
||||
name: dsm
|
||||
type: NodePort
|
||||
|
||||
37
readme.md
37
readme.md
@@ -33,27 +33,39 @@ services:
|
||||
DISK_SIZE: "16G"
|
||||
devices:
|
||||
- /dev/kvm
|
||||
- /dev/net/tun
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
ports:
|
||||
- 5000:5000
|
||||
volumes:
|
||||
- /var/dsm:/storage
|
||||
restart: always
|
||||
stop_grace_period: 2m
|
||||
```
|
||||
|
||||
Via Docker CLI:
|
||||
|
||||
```bash
|
||||
docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-timeout 120 vdsm/virtual-dsm
|
||||
docker run -it --rm -p 5000:5000 --device=/dev/kvm --device=/dev/net/tun --cap-add NET_ADMIN --stop-timeout 120 vdsm/virtual-dsm
|
||||
```
|
||||
|
||||
Via Kubernetes:
|
||||
|
||||
```shell
|
||||
kubectl apply -f kubernetes.yml
|
||||
kubectl apply -f https://raw.githubusercontent.com/vdsm/virtual-dsm/refs/heads/master/kubernetes.yml
|
||||
```
|
||||
|
||||
## Compatibility ⚙️
|
||||
|
||||
| **Product** | **Platform** | |
|
||||
|---|---|---|
|
||||
| Docker Engine | Linux| ✅ |
|
||||
| Docker Desktop | Linux | ❌ |
|
||||
| Docker Desktop | macOS | ❌ |
|
||||
| Docker Desktop | Windows 11 | ✅ |
|
||||
| Docker Desktop | Windows 10 | ❌ |
|
||||
|
||||
## FAQ 💬
|
||||
|
||||
### How do I use it?
|
||||
@@ -64,7 +76,7 @@ kubectl apply -f kubernetes.yml
|
||||
|
||||
- Wait until DSM is ready, choose an username and password, and you will be taken to the desktop.
|
||||
|
||||
Enjoy your brand new machine, and don't forget to star this repo!
|
||||
Enjoy your brand new NAS, and don't forget to star this repo!
|
||||
|
||||
### How do I change the storage location?
|
||||
|
||||
@@ -147,24 +159,28 @@ kubectl apply -f kubernetes.yml
|
||||
|
||||
### How do I verify if my system supports KVM?
|
||||
|
||||
To verify that your system supports KVM, run the following commands:
|
||||
Only Linux and Windows 11 support KVM virtualization, macOS and Windows 10 do not unfortunately.
|
||||
|
||||
You can run the following commands in Linux to check your system:
|
||||
|
||||
```bash
|
||||
sudo apt install cpu-checker
|
||||
sudo kvm-ok
|
||||
```
|
||||
|
||||
If you receive an error from `kvm-ok` indicating that KVM acceleration can't be used, please check whether:
|
||||
If you receive an error from `kvm-ok` indicating that KVM cannot be used, please check whether:
|
||||
|
||||
- the virtualization extensions (`Intel VT-x` or `AMD SVM`) are enabled in your BIOS.
|
||||
|
||||
- you are running an operating system that supports them, like Linux or Windows 11 (macOS and Windows 10 do not unfortunately).
|
||||
|
||||
- you enabled "nested virtualization" if you are running the container inside a virtual machine.
|
||||
|
||||
- you are not using a cloud provider, as most of them do not allow nested virtualization for their VPS's.
|
||||
|
||||
If you didn't receive any error from `kvm-ok` at all, but the container still complains that `/dev/kvm` is missing, it might help to add `privileged: true` to your compose file (or `--privileged` to your `run` command), to rule out any permission issue.
|
||||
If you do not receive any error from `kvm-ok` but the container still complains about KVM, please check whether:
|
||||
|
||||
- you are not using "Docker Desktop for Linux" as it does not support KVM, instead make use of Docker Engine directly.
|
||||
|
||||
- it could help to add `privileged: true` to your compose file (or `sudo` to your `docker run` command), to rule out any permission issue.
|
||||
|
||||
### How do I assign an individual IP address to the container?
|
||||
|
||||
@@ -207,7 +223,7 @@ kubectl apply -f kubernetes.yml
|
||||
|
||||
After configuring the container for [macvlan](#how-do-i-assign-an-individual-ip-address-to-the-container), it is possible for DSM to become part of your home network by requesting an IP from your router, just like your other devices.
|
||||
|
||||
To enable this mode, add the following lines to your compose file:
|
||||
To enable this mode, in which the container and DSM will have separate IP addresses, add the following lines to your compose file:
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
@@ -218,9 +234,6 @@ kubectl apply -f kubernetes.yml
|
||||
- 'c *:* rwm'
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> In this mode, the container and DSM will each have their own separate IPs.
|
||||
|
||||
### How do I pass-through the GPU?
|
||||
|
||||
To pass-through your Intel GPU, add the following lines to your compose file:
|
||||
|
||||
18
src/disk.sh
18
src/disk.sh
@@ -3,9 +3,9 @@ set -Eeuo pipefail
|
||||
|
||||
# Docker environment variables
|
||||
|
||||
: "${DISK_IO:="native"}" # I/O Mode, can be set to 'native', 'threads' or 'io_turing'
|
||||
: "${DISK_IO:="native"}" # I/O Mode, can be set to 'native', 'threads' or 'io_uring'
|
||||
: "${DISK_FMT:="raw"}" # Disk file format, 'raw' by default for best performance
|
||||
: "${DISK_TYPE:=""}" # Device type to be used, choose "ide", "usb", "blk" or "scsi"
|
||||
: "${DISK_TYPE:=""}" # Device type to be used, "sata", "nvme", "blk" or "scsi"
|
||||
: "${DISK_FLAGS:=""}" # Specifies the options for use with the qcow2 disk format
|
||||
: "${DISK_CACHE:="none"}" # Caching mode, can be set to 'writeback' for better performance
|
||||
: "${DISK_DISCARD:="on"}" # Controls whether unmap (TRIM) commands are passed to the host.
|
||||
@@ -369,6 +369,7 @@ createDevice () {
|
||||
local result=" -drive file=$DISK_FILE,id=$DISK_ID,format=$DISK_FMT,cache=$DISK_CACHE,aio=$DISK_IO,discard=$DISK_DISCARD,detect-zeroes=on"
|
||||
|
||||
case "${DISK_TYPE,,}" in
|
||||
"none" ) ;;
|
||||
"auto" )
|
||||
echo "$result"
|
||||
;;
|
||||
@@ -377,7 +378,12 @@ createDevice () {
|
||||
-device usb-storage,drive=${DISK_ID}${index}"
|
||||
echo "$result"
|
||||
;;
|
||||
"ide" )
|
||||
"nvme" )
|
||||
result+=",if=none \
|
||||
-device nvme,drive=${DISK_ID}${index},serial=deadbeaf${DISK_INDEX}"
|
||||
echo "$result"
|
||||
;;
|
||||
"ide" | "sata" )
|
||||
result+=",if=none \
|
||||
-device ich9-ahci,id=ahci${DISK_INDEX},addr=$DISK_ADDRESS \
|
||||
-device ide-hd,drive=${DISK_ID},bus=ahci$DISK_INDEX.0,rotation_rate=$DISK_ROTATION${index}"
|
||||
@@ -385,7 +391,7 @@ createDevice () {
|
||||
;;
|
||||
"blk" | "virtio-blk" )
|
||||
result+=",if=none \
|
||||
-device virtio-blk-pci,drive=${DISK_ID},scsi=off,bus=pcie.0,addr=$DISK_ADDRESS,iothread=io2${index}"
|
||||
-device virtio-blk-pci,drive=${DISK_ID},bus=pcie.0,addr=$DISK_ADDRESS,iothread=io2${index}"
|
||||
echo "$result"
|
||||
;;
|
||||
"scsi" | "virtio-scsi" )
|
||||
@@ -410,7 +416,7 @@ addDisk () {
|
||||
local DISK_FMT=$7
|
||||
local DISK_IO=$8
|
||||
local DISK_CACHE=$9
|
||||
local DISK_EXT DIR DATA_SIZE FS PREV_FMT PREV_EXT CUR_SIZE OPTS
|
||||
local DISK_EXT DIR DATA_SIZE FS PREV_FMT PREV_EXT CUR_SIZE
|
||||
|
||||
DISK_EXT=$(fmt2ext "$DISK_FMT")
|
||||
local DISK_FILE="$DISK_BASE.$DISK_EXT"
|
||||
@@ -495,7 +501,7 @@ html "Initializing disks..."
|
||||
[ -z "${DISK_NAME:-}" ] && DISK_NAME="data"
|
||||
|
||||
case "${DISK_TYPE,,}" in
|
||||
"ide" | "usb" | "scsi" | "blk" | "auto" ) ;;
|
||||
"ide" | "sata" | "nvme" | "usb" | "scsi" | "blk" | "auto" | "none" ) ;;
|
||||
* ) error "Invalid DISK_TYPE specified, value \"$DISK_TYPE\" is not recognized!" && exit 80 ;;
|
||||
esac
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ set -Eeuo pipefail
|
||||
: "${GPU:="N"}" # GPU passthrough
|
||||
: "${VGA:="virtio"}" # VGA adaptor
|
||||
: "${DISPLAY:="none"}" # Display type
|
||||
: "${RENDERNODE:="/dev/dri/renderD128"}" # Render node
|
||||
|
||||
if [[ "$GPU" != [Yy1]* ]] || [[ "$ARCH" != "amd64" ]]; then
|
||||
|
||||
@@ -15,20 +16,24 @@ if [[ "$GPU" != [Yy1]* ]] || [[ "$ARCH" != "amd64" ]]; then
|
||||
|
||||
fi
|
||||
|
||||
DISPLAY_OPTS="-display egl-headless,rendernode=/dev/dri/renderD128"
|
||||
DISPLAY_OPTS="-display egl-headless,rendernode=$RENDERNODE"
|
||||
DISPLAY_OPTS+=" -vga $VGA"
|
||||
|
||||
[ ! -d /dev/dri ] && mkdir -m 755 /dev/dri
|
||||
|
||||
if [ ! -c /dev/dri/card0 ]; then
|
||||
if mknod /dev/dri/card0 c 226 0; then
|
||||
chmod 666 /dev/dri/card0
|
||||
# Extract the card number from the render node
|
||||
CARD_NUMBER=$(echo "$RENDERNODE" | grep -oP '(?<=renderD)\d+')
|
||||
CARD_DEVICE="/dev/dri/card$((CARD_NUMBER - 128))"
|
||||
|
||||
if [ ! -c "$CARD_DEVICE" ]; then
|
||||
if mknod "$CARD_DEVICE" c 226 $((CARD_NUMBER - 128)); then
|
||||
chmod 666 "$CARD_DEVICE"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -c /dev/dri/renderD128 ]; then
|
||||
if mknod /dev/dri/renderD128 c 226 128; then
|
||||
chmod 666 /dev/dri/renderD128
|
||||
if [ ! -c "$RENDERNODE" ]; then
|
||||
if mknod "$RENDERNODE" c 226 "$CARD_NUMBER"; then
|
||||
chmod 666 "$RENDERNODE"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
APP="Virtual DSM"
|
||||
SUPPORT="https://github.com/vdsm/virtual-dsm"
|
||||
: "${APP:="Virtual DSM"}"
|
||||
: "${SUPPORT:="https://github.com/vdsm/virtual-dsm"}"
|
||||
|
||||
cd /run
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ if [ ! -s "$RDC" ]; then
|
||||
|
||||
html "$MSG..."
|
||||
/run/progress.sh "$PAT" "$SIZE" "$MSG ([P])..." &
|
||||
{ wget "$LOC" -O "$PAT" -q --no-check-certificate --timeout=10 --show-progress "$PROGRESS"; rc=$?; } || :
|
||||
{ wget "$LOC" -O "$PAT" -q --no-check-certificate --timeout=10 --no-http-keep-alive --show-progress "$PROGRESS"; rc=$?; } || :
|
||||
|
||||
fKill "progress.sh"
|
||||
|
||||
@@ -251,7 +251,7 @@ else
|
||||
|
||||
/run/progress.sh "$PAT" "$SIZE" "$MSG ([P])..." &
|
||||
|
||||
{ wget "$URL" -O "$PAT" -q --no-check-certificate --timeout=10 --show-progress "$PROGRESS"; rc=$?; } || :
|
||||
{ wget "$URL" -O "$PAT" -q --no-check-certificate --timeout=10 --no-http-keep-alive --show-progress "$PROGRESS"; rc=$?; } || :
|
||||
|
||||
fKill "progress.sh"
|
||||
|
||||
|
||||
@@ -4,10 +4,12 @@ set -Eeuo pipefail
|
||||
# Docker environment variables
|
||||
|
||||
: "${MAC:=""}"
|
||||
: "${MTU:=""}"
|
||||
: "${DHCP:="N"}"
|
||||
: "${NETWORK:="Y"}"
|
||||
: "${HOST_PORTS:=""}"
|
||||
: "${USER_PORTS:=""}"
|
||||
: "${HOST_PORTS:=""}"
|
||||
: "${ADAPTER:="virtio-net-pci"}"
|
||||
|
||||
: "${VM_NET_DEV:=""}"
|
||||
: "${VM_NET_TAP:="dsm"}"
|
||||
@@ -35,11 +37,32 @@ configureDHCP() {
|
||||
fi
|
||||
|
||||
# Create a macvtap network for the VM guest
|
||||
{ ip link add link "$VM_NET_DEV" name "$VM_NET_TAP" address "$VM_NET_MAC" type macvtap mode bridge ; rc=$?; } || :
|
||||
{ msg=$(ip link add link "$VM_NET_DEV" name "$VM_NET_TAP" address "$VM_NET_MAC" type macvtap mode bridge 2>&1); rc=$?; } || :
|
||||
|
||||
case "$msg" in
|
||||
"RTNETLINK answers: File exists"* )
|
||||
while ! ip link add link "$VM_NET_DEV" name "$VM_NET_TAP" address "$VM_NET_MAC" type macvtap mode bridge; do
|
||||
info "Waiting for macvtap interface to become available.."
|
||||
sleep 5
|
||||
done ;;
|
||||
"RTNETLINK answers: Invalid argument"* )
|
||||
error "Cannot create macvtap interface. Please make sure that the network type of the container is 'macvlan' and not 'ipvlan'."
|
||||
return 1 ;;
|
||||
"RTNETLINK answers: Operation not permitted"* )
|
||||
error "No permission to create macvtap interface. Please make sure that your host kernel supports it and that the NET_ADMIN capability is set."
|
||||
return 1 ;;
|
||||
*)
|
||||
[ -n "$msg" ] && echo "$msg" >&2
|
||||
if (( rc != 0 )); then
|
||||
error "Cannot create macvtap interface. Please make sure that the network type is 'macvlan' and not 'ipvlan',"
|
||||
error "that your kernel is recent (>4) and supports it, and that the container has the NET_ADMIN capability set." && return 1
|
||||
error "Cannot create macvtap interface."
|
||||
return 1
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
if [[ "$MTU" != "0" ]] && [[ "$MTU" != "1500" ]]; then
|
||||
if ! ip link set dev "$VM_NET_TAP" mtu "$MTU"; then
|
||||
warn "Failed to set MTU size.."
|
||||
fi
|
||||
fi
|
||||
|
||||
while ! ip link set "$VM_NET_TAP" up; do
|
||||
@@ -152,6 +175,9 @@ configureUser() {
|
||||
|
||||
configureNAT() {
|
||||
|
||||
local tuntap="TUN device is missing. $ADD_ERR --device /dev/net/tun"
|
||||
local tables="The 'ip_tables' kernel module is not loaded. Try this command: sudo modprobe ip_tables iptable_nat"
|
||||
|
||||
# Create the necessary file structure for /dev/net/tun
|
||||
if [ ! -c /dev/net/tun ]; then
|
||||
[ ! -d /dev/net ] && mkdir -m 755 /dev/net
|
||||
@@ -161,7 +187,7 @@ configureNAT() {
|
||||
fi
|
||||
|
||||
if [ ! -c /dev/net/tun ]; then
|
||||
error "TUN device missing. $ADD_ERR --device /dev/net/tun --cap-add NET_ADMIN" && return 1
|
||||
error "$tuntap" && return 1
|
||||
fi
|
||||
|
||||
# Check port forwarding flag
|
||||
@@ -172,9 +198,6 @@ configureNAT() {
|
||||
fi
|
||||
fi
|
||||
|
||||
local tables="The 'ip_tables' kernel module is not loaded. Try this command: sudo modprobe ip_tables iptable_nat"
|
||||
local tuntap="The 'tun' kernel module is not available. Try this command: 'sudo modprobe tun' or run the container with 'privileged: true'."
|
||||
|
||||
# Create a bridge with a static IP for the VM guest
|
||||
|
||||
{ ip link add dev dockerbridge type bridge ; rc=$?; } || :
|
||||
@@ -197,6 +220,18 @@ configureNAT() {
|
||||
error "$tuntap" && return 1
|
||||
fi
|
||||
|
||||
if [[ "$MTU" != "0" ]] && [[ "$MTU" != "1500" ]]; then
|
||||
if ! ip link set dev "$VM_NET_TAP" mtu "$MTU"; then
|
||||
warn "Failed to set MTU size.."
|
||||
fi
|
||||
fi
|
||||
|
||||
GATEWAY_MAC=$(echo "$VM_NET_MAC" | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/')
|
||||
|
||||
if ! ip link set dev "$VM_NET_TAP" address "$GATEWAY_MAC"; then
|
||||
warn "Failed to set gateway MAC address.."
|
||||
fi
|
||||
|
||||
while ! ip link set "$VM_NET_TAP" up promisc on; do
|
||||
info "Waiting for TAP to become available..."
|
||||
sleep 2
|
||||
@@ -239,7 +274,7 @@ configureNAT() {
|
||||
|
||||
NET_OPTS+=",script=no,downscript=no"
|
||||
|
||||
! configureDNS && return 1
|
||||
configureDNS || return 1
|
||||
|
||||
return 0
|
||||
}
|
||||
@@ -286,13 +321,19 @@ checkOS() {
|
||||
|
||||
local name
|
||||
local os=""
|
||||
local if="macvlan"
|
||||
name=$(uname -a)
|
||||
|
||||
[[ "${name,,}" == *"darwin"* ]] && os="MacOS"
|
||||
[[ "${name,,}" == *"microsoft"* ]] && os="Windows"
|
||||
[[ "${name,,}" == *"darwin"* ]] && os="Docker Desktop for macOS"
|
||||
[[ "${name,,}" == *"microsoft"* ]] && os="Docker Desktop for Windows"
|
||||
|
||||
if [[ "$DHCP" == [Yy1]* ]]; then
|
||||
if="macvtap"
|
||||
[[ "${name,,}" == *"synology"* ]] && os="Synology Container Manager"
|
||||
fi
|
||||
|
||||
if [ -n "$os" ]; then
|
||||
warn "you are using Docker Desktop for $os which does not support macvlan, please revert to bridge networking!"
|
||||
warn "you are using $os which does not support $if, please revert to bridge networking!"
|
||||
fi
|
||||
|
||||
return 0
|
||||
@@ -316,6 +357,20 @@ getInfo() {
|
||||
error "$ADD_ERR -e \"VM_NET_DEV=NAME\" to specify another interface name." && exit 27
|
||||
fi
|
||||
|
||||
if [ -z "$MTU" ]; then
|
||||
MTU=$(cat "/sys/class/net/$VM_NET_DEV/mtu")
|
||||
fi
|
||||
|
||||
if [ "$MTU" -gt "1500" ]; then
|
||||
info "MTU size is too large: $MTU, ignoring..." && MTU="0"
|
||||
fi
|
||||
|
||||
if [[ "${ADAPTER,,}" != "virtio-net-pci" ]]; then
|
||||
if [[ "$MTU" != "0" ]] && [[ "$MTU" != "1500" ]]; then
|
||||
warn "MTU size is $MTU, but cannot be set for $ADAPTER adapters!" && MTU="0"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$VM_NET_MAC" ]; then
|
||||
local file="$STORAGE/dsm.mac"
|
||||
[ -s "$file" ] && VM_NET_MAC=$(<"$file")
|
||||
@@ -358,7 +413,10 @@ getInfo
|
||||
html "Initializing network..."
|
||||
|
||||
if [[ "$DEBUG" == [Yy1]* ]]; then
|
||||
info "Host: $HOST IP: $IP Gateway: $GATEWAY Interface: $VM_NET_DEV MAC: $VM_NET_MAC"
|
||||
mtu=$(cat "/sys/class/net/$VM_NET_DEV/mtu")
|
||||
line="Host: $HOST IP: $IP Gateway: $GATEWAY Interface: $VM_NET_DEV MAC: $VM_NET_MAC MTU: $mtu"
|
||||
[[ "$MTU" != "0" ]] && [[ "$MTU" != "$mtu" ]] && line+=" ($MTU)"
|
||||
info "$line"
|
||||
[ -f /etc/resolv.conf ] && grep '^nameserver*' /etc/resolv.conf
|
||||
echo
|
||||
fi
|
||||
@@ -367,6 +425,11 @@ if [[ "$IP" == "172.17."* ]]; then
|
||||
warn "your container IP starts with 172.17.* which will cause conflicts when you install the Container Manager package inside DSM!"
|
||||
fi
|
||||
|
||||
if [[ -d "/sys/class/net/$VM_NET_TAP" ]]; then
|
||||
info "Lingering interface will be removed..."
|
||||
ip link delete "$VM_NET_TAP" || true
|
||||
fi
|
||||
|
||||
if [[ "$DHCP" == [Yy1]* ]]; then
|
||||
|
||||
checkOS
|
||||
@@ -376,7 +439,7 @@ if [[ "$DHCP" == [Yy1]* ]]; then
|
||||
fi
|
||||
|
||||
# Configure for macvtap interface
|
||||
! configureDHCP && exit 20
|
||||
configureDHCP || exit 20
|
||||
|
||||
MSG="Booting DSM instance..."
|
||||
html "$MSG"
|
||||
@@ -397,7 +460,7 @@ else
|
||||
if ! configureNAT; then
|
||||
|
||||
NETWORK="user"
|
||||
warn "falling back to usermode networking! Performance will be bad and port forwarding will not work."
|
||||
warn "falling back to usermode networking! Performance will be bad and port mapping will not work."
|
||||
|
||||
ip link set "$VM_NET_TAP" down promisc off &> null || true
|
||||
ip link delete "$VM_NET_TAP" &> null || true
|
||||
@@ -412,12 +475,13 @@ else
|
||||
if [[ "${NETWORK,,}" == "user"* ]]; then
|
||||
|
||||
# Configure for usermode networking (slirp)
|
||||
! configureUser && exit 24
|
||||
configureUser || exit 24
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
NET_OPTS+=" -device virtio-net-pci,romfile=,netdev=hostnet0,mac=$VM_NET_MAC,id=net0"
|
||||
NET_OPTS+=" -device $ADAPTER,id=net0,netdev=hostnet0,romfile=,mac=$VM_NET_MAC"
|
||||
[[ "$MTU" != "0" ]] && [[ "$MTU" != "1500" ]] && NET_OPTS+=",host_mtu=$MTU"
|
||||
|
||||
return 0
|
||||
|
||||
@@ -34,17 +34,13 @@ if [[ "$KVM" != [Nn]* ]]; then
|
||||
if [ -n "$KVM_ERR" ]; then
|
||||
KVM="N"
|
||||
if [[ "$OSTYPE" =~ ^darwin ]]; then
|
||||
warn "you are using MacOS which has no KVM support, this will cause a major loss of performance."
|
||||
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."
|
||||
warn "you are using macOS 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 diagnose the cause, or continue without KVM by setting KVM=N (not recommended)."
|
||||
[[ "$DEBUG" != [Yy1]* ]] && exit 88
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
|
||||
34
src/reset.sh
34
src/reset.sh
@@ -17,6 +17,7 @@ echo "❯ For support visit $SUPPORT"
|
||||
|
||||
: "${TZ:=""}" # System local timezone
|
||||
: "${DEBUG:="N"}" # Disable debugging mode
|
||||
: "${COMMIT:="N"}" # Commit to local image
|
||||
: "${COUNTRY:=""}" # Country code for mirror
|
||||
: "${CONSOLE:="N"}" # Disable console mode
|
||||
: "${ALLOCATE:=""}" # Preallocate diskspace
|
||||
@@ -25,13 +26,13 @@ echo "❯ For support visit $SUPPORT"
|
||||
: "${RAM_SIZE:="1G"}" # Maximum RAM amount
|
||||
: "${RAM_CHECK:="Y"}" # Check available RAM
|
||||
: "${DISK_SIZE:="16G"}" # Initial data disk size
|
||||
: "${STORAGE:="/storage"}" # Storage folder location
|
||||
|
||||
# Helper variables
|
||||
|
||||
PROCESS="${APP,,}"
|
||||
PROCESS="${PROCESS// /-}"
|
||||
|
||||
STORAGE="/storage"
|
||||
INFO="/run/shm/msg.html"
|
||||
PAGE="/run/shm/index.html"
|
||||
TEMPLATE="/var/www/index.html"
|
||||
@@ -53,12 +54,28 @@ else
|
||||
fi
|
||||
|
||||
if ! grep -qi "model name" <<< "$CPI"; then
|
||||
CPU="Unknown"
|
||||
CPU=""
|
||||
else
|
||||
CPU=$(echo "$CPI" | grep -m 1 -i '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="${CPU// with Radeon Graphics/}"
|
||||
fi
|
||||
|
||||
if [ -z "${CPU// /}" ] && grep -qi "model:" <<< "$CPI"; then
|
||||
CPU=$(echo "$CPI" | grep -m 1 -i 'model:' | cut -f 2 -d ":" | awk '{$1=$1}1' | sed 's# @.*##g' | sed s/"(R)"//g | sed 's/[^[:alnum:] ]\+/ /g' | sed 's/ */ /g')
|
||||
fi
|
||||
|
||||
CPU="${CPU// CPU/}"
|
||||
CPU="${CPU// 8 Core/}"
|
||||
CPU="${CPU// 16 Core/}"
|
||||
CPU="${CPU// 32 Core/}"
|
||||
CPU="${CPU// 64 Core/}"
|
||||
CPU="${CPU// Processor/}"
|
||||
CPU="${CPU// Quad core/}"
|
||||
CPU="${CPU// Core TM/ Core}"
|
||||
CPU="${CPU// with Radeon Graphics/}"
|
||||
CPU="${CPU// with Radeon Vega Graphics/}"
|
||||
|
||||
[ -z "${CPU// /}" ] && CPU="Unknown"
|
||||
|
||||
# Check system
|
||||
|
||||
if [ ! -d "/dev/shm" ]; then
|
||||
@@ -69,8 +86,13 @@ fi
|
||||
|
||||
# Check folder
|
||||
|
||||
if [ ! -d "$STORAGE" ]; then
|
||||
if [[ "$COMMIT" != [Nn]* ]]; then
|
||||
STORAGE="/local"
|
||||
mkdir -p "$STORAGE"
|
||||
else
|
||||
if [ ! -d "$STORAGE" ]; then
|
||||
error "Storage folder ($STORAGE) not found!" && exit 13
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check filesystem
|
||||
@@ -93,11 +115,13 @@ WANTED_GB=$(( (RAM_WANTED + 1073741823)/1073741824 ))
|
||||
|
||||
# Print system info
|
||||
SYS="${SYS/-generic/}"
|
||||
FS="${FS/UNKNOWN //}"
|
||||
FS="${FS/ext2\/ext3/ext4}"
|
||||
FS=$(echo "$FS" | sed 's/[)(]//g')
|
||||
SPACE=$(df --output=avail -B 1 "$STORAGE" | tail -n 1)
|
||||
SPACE_GB=$(( (SPACE + 1073741823)/1073741824 ))
|
||||
|
||||
echo "❯ CPU: ${CPU} | RAM: $AVAIL_GB/$TOTAL_GB GB | DISK: $SPACE_GB GB (${FS}) | HOST: ${SYS}..."
|
||||
echo "❯ CPU: ${CPU} | RAM: $AVAIL_GB/$TOTAL_GB GB | DISK: $SPACE_GB GB (${FS}) | KERNEL: ${SYS}..."
|
||||
echo
|
||||
|
||||
# Check memory
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
[1]
|
||||
<meta http-equiv="Cache-Control" content="no-cache" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="stylesheet" type="text/css" href="/css/style.css" />
|
||||
<link rel="icon" href="/img/favicon.svg" type="image/x-icon">
|
||||
<link rel="stylesheet" type="text/css" href="css/style.css" />
|
||||
<link rel="icon" href="img/favicon.svg" type="image/x-icon">
|
||||
[2]
|
||||
</head>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
[5]
|
||||
</footer>
|
||||
</div>
|
||||
<script type="text/javascript" src="/js/script.js"></script>
|
||||
<script type="text/javascript" src="js/script.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@@ -3,7 +3,7 @@ var interval = 1000;
|
||||
|
||||
function getInfo() {
|
||||
|
||||
var url = "/msg.html";
|
||||
var url = "msg.html";
|
||||
|
||||
try {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user