Compare commits

..

33 Commits
v5.18 ... v5.25

Author SHA1 Message Date
Kroese
a70338ec3c feat: Print filesystem on error (#635) 2024-02-17 05:56:40 +01:00
Kroese
a84878abfc fix: Detect Mac Journal filesystem (#634) 2024-02-17 03:55:30 +01:00
Kroese
8421a391b7 fix: Prevent re-entry during shutdown (#633) 2024-02-16 16:03:37 +01:00
Kroese
f9340ec3d6 docs: Readme (#630) 2024-02-10 00:33:21 +01:00
Kroese
0cca9c5f83 feat: Disable CoW check on XFS (#629) 2024-02-09 23:53:18 +01:00
Kroese
13d60b7f47 build: Notify after build (#628) 2024-02-09 14:45:38 +01:00
Kroese
f74771a9cc fix: Convert MAC address to uppercase (#627) 2024-02-08 17:33:11 +01:00
Kroese
f24ba41930 fix: Convert dashes in custom MAC addresses (#626) 2024-02-08 17:03:30 +01:00
Kroese
f412580a4a feat: Add DNS entry for container (#624) 2024-02-07 22:26:29 +01:00
Kroese
5cde1b4438 feat: Set process name (#623) 2024-02-07 13:04:29 +01:00
Kroese
7cfb57b1bc docs: Readme (#621) 2024-02-05 16:18:13 +01:00
Kroese
a478b58f97 feat: Set KVM tick policy (#620) 2024-02-05 12:09:12 +01:00
Kroese
8297f4f880 fix: Support CPU's without SSE4 (#619) 2024-02-05 07:41:47 +01:00
Kroese
4c67343d33 feat: Enable L3 cache and multi-threaded TCG (#618) 2024-02-04 19:25:22 +01:00
Kroese
53cc6998f0 fix: CPU features 2024-02-02 22:44:43 +01:00
Kroese
d857d71e0d fix: Merge drive function (#614) 2024-02-01 11:05:33 +01:00
Kroese
003c2766ce docs: Readme (#613) 2024-01-31 04:28:24 +01:00
Kroese
78594098cc feat: Disable CoW check on ZFS (#612) 2024-01-31 03:54:40 +01:00
Kroese
3c31bc91e4 feat: Generate unique MAC address (#611) 2024-01-30 04:46:44 +01:00
Kroese
72141bab7a build: Lint Dockerfile (#610) 2024-01-29 11:51:28 +01:00
Kroese
bc52463aa4 fix: Process signal faster (#609) 2024-01-29 05:54:22 +01:00
Kroese
9fa68908a9 feat: Show download progress (#608) 2024-01-29 05:40:06 +01:00
Kroese
740dbec1b1 build: Exclude web folder (#607) 2024-01-29 02:29:05 +01:00
Kroese
440d203730 fix: Stylesheet (#606) 2024-01-29 02:27:04 +01:00
Kroese
1a83c67e2c feat: Font smoothing (#605) 2024-01-29 02:01:51 +01:00
Kroese
34a707a2a5 docs: Readme (#603) 2024-01-27 19:51:26 +01:00
Kroese
cabb2cdfc9 docs: Readme (#602) 2024-01-27 19:10:43 +01:00
Kroese
dc52ccf172 docs: Readme (#601) 2024-01-27 19:06:10 +01:00
Kroese
bdd7fec3c3 fix: Space after URL (#600) 2024-01-27 02:01:27 +01:00
Kroese
bd8b03d089 docs: Readme (#599) 2024-01-26 06:29:15 +01:00
Kroese
a10588b0ce fix: Check dnsmasq (#598) 2024-01-26 02:19:31 +01:00
renovate[bot]
3503b86e12 chore(deps): update peter-evans/dockerhub-description action to v4 (#597)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-25 17:05:28 +01:00
Kroese
9e124980cd fix: Disk message (#596) 2024-01-25 17:02:50 +01:00
15 changed files with 345 additions and 189 deletions

View File

@@ -8,6 +8,10 @@ on:
paths-ignore: paths-ignore:
- '**/*.md' - '**/*.md'
- '**/*.yml' - '**/*.yml'
- '**/*.js'
- '**/*.css'
- '**/*.html'
- 'web/**'
- '.gitignore' - '.gitignore'
- '.dockerignore' - '.dockerignore'
- '.github/**' - '.github/**'
@@ -99,3 +103,15 @@ jobs:
url: ${{ secrets.GITLAB_URL }} url: ${{ secrets.GITLAB_URL }}
token: ${{ secrets.GITLAB_TOKEN }} token: ${{ secrets.GITLAB_TOKEN }}
username: ${{ secrets.GITLAB_USERNAME }} username: ${{ secrets.GITLAB_USERNAME }}
-
name: Send mail
uses: action-pack/send-mail@v1
with:
to: ${{secrets.MAILTO}}
from: Github Actions <${{secrets.MAILTO}}>
connection_url: ${{secrets.MAIL_CONNECTION}}
subject: Build of ${{ github.event.repository.name }} v${{ steps.meta.outputs.version }} completed
body: |
The build job of ${{ github.event.repository.name }} v${{ steps.meta.outputs.version }} was completed successfully!
See https://github.com/${{ github.repository }}/actions for more information.

View File

@@ -7,8 +7,18 @@ jobs:
name: shellcheck name: shellcheck
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 -
- name: Run ShellCheck name: Checkout
uses: actions/checkout@v4
-
name: Run ShellCheck
uses: ludeeus/action-shellcheck@master uses: ludeeus/action-shellcheck@master
env: env:
SHELLCHECK_OPTS: -x --source-path=src -e SC2001 -e SC2034 -e SC2064 -e SC2317 -e SC2153 -e SC2028 SHELLCHECK_OPTS: -x --source-path=src -e SC2001 -e SC2034 -e SC2064 -e SC2317 -e SC2153 -e SC2028
-
name: Lint Dockerfile
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile
ignore: DL3008,DL3003,DL3006
failure-threshold: warning

View File

@@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- -
name: Docker Hub Description name: Docker Hub Description
uses: peter-evans/dockerhub-description@v3 uses: peter-evans/dockerhub-description@v4
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}

View File

@@ -3,6 +3,7 @@ on:
pull_request: pull_request:
paths: paths:
- '**/*.sh' - '**/*.sh'
- 'Dockerfile'
- '.github/workflows/test.yml' - '.github/workflows/test.yml'
- '.github/workflows/check.yml' - '.github/workflows/check.yml'

264
readme.md
View File

@@ -1,6 +1,6 @@
<h1 align="center">Virtual DSM<br /> <h1 align="center">Virtual DSM<br />
<div align="center"> <div align="center">
<img src="https://github.com/vdsm/virtual-dsm/raw/master/.github/screen.jpg" title="Screenshot" style="max-width:100%;" width="432" /> <a href="https://github.com/vdsm/virtual-dsm"><img src="https://github.com/vdsm/virtual-dsm/raw/master/.github/screen.jpg" title="Screenshot" style="max-width:100%;" width="432" /></a>
</div> </div>
<div align="center"> <div align="center">
@@ -17,7 +17,6 @@ Virtual DSM in a docker container.
- Multiple disks - Multiple disks
- KVM acceleration - KVM acceleration
- GPU pass-through
- Upgrades supported - Upgrades supported
## Usage ## Usage
@@ -52,190 +51,191 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
## FAQ ## FAQ
* ### How do I use it? * ### How do I use it?
Very simple! These are the steps: Very simple! These are the steps:
- Start the container and get some coffee. - Start the container and connect to [port 5000](http://localhost:5000) using your web browser.
- Connect to [port 5000](http://localhost:5000) of the container in your web browser. - 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!
- Wait until DSM is ready, choose an username and password, and you will be taken to the desktop. * ### How do I change the size of the disk?
- Enjoy your brand new machine, and don't forget to star this repo! To expand the default size of 16 GB, locate the `DISK_SIZE` setting in your compose file and modify it to your preferred capacity:
* ### How do I change the size of the disk? ```yaml
environment:
DISK_SIZE: "128G"
```
This can also be used to resize the existing disk to a larger capacity without any data loss.
To expand the default size of 16 GB, locate the `DISK_SIZE` setting in your compose file and modify it to your preferred capacity: * ### How do I change the storage location?
```yaml To change the storage location, include the following bind mount in your compose file:
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? ```yaml
volumes:
- /var/dsm:/storage
```
To change the storage location, include the following bind mount in your compose file: Replace the example path `/var/dsm` with the desired storage folder.
```yaml * ### How do I create a growable disk?
volumes:
- /var/dsm:/storage
```
Replace the example path `/var/dsm` with the desired storage folder. By default, the entire capacity of the disk is reserved in advance.
* ### How do I create a growable disk? To create a growable disk that only allocates space that is actually used, add the following environment variable:
By default, the entire capacity of the disk is reserved in advance. ```yaml
environment:
DISK_FMT: "qcow2"
```
To create a growable disk that only allocates space that is actually used, add the following environment variable: Please note that this may reduce the write performance of the disk.
```yaml * ### How do I add multiple disks?
environment:
DISK_FMT: "qcow2"
```
Please note that this may reduce the write performance of the disk. 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 add multiple disks? * ### How do I pass-through a disk?
To create additional disks, modify your compose file like this: It is possible to pass-through disk devices directly by adding them to your compose file in this way:
```yaml
environment:
DISK2_SIZE: "32G"
DISK3_SIZE: "64G"
volumes:
- /home/example:/storage2
- /mnt/data/example:/storage3
```
* ### How do I pass-through a disk? ```yaml
environment:
DEVICE2: "/dev/sda"
DEVICE3: "/dev/sdb"
devices:
- /dev/sda
- /dev/sdb
```
It is possible to pass-through disk devices directly by adding them to your compose file in this way: Please note that the device needs to be totally empty (without any partition table) otherwise DSM does not always format it into a volume.
```yaml 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.
environment:
DEVICE2: "/dev/sda"
DEVICE3: "/dev/sdb"
devices:
- /dev/sda
- /dev/sdb
```
Please note that the device needs to be totally empty (without any partition table) otherwise DSM does not always format it into a volume. * ### How do I increase the amount of CPU or RAM?
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. By default, a single CPU core and 1 GB of RAM are allocated to the container.
* ### How do I increase the amount of CPU or RAM? To increase this, add the following environment variables:
By default, a single CPU core and 1 GB of RAM are allocated to the container. ```yaml
environment:
RAM_SIZE: "4G"
CPU_CORES: "4"
```
To increase this, add the following environment variables: * ### How do I verify if my system supports KVM?
```yaml To verify if your system supports KVM, run the following commands:
environment:
RAM_SIZE: "4G"
CPU_CORES: "4"
```
* ### How do I verify if my system supports KVM? ```bash
sudo apt install cpu-checker
sudo kvm-ok
```
To verify if your system supports KVM, run the following commands: If you receive an error from `kvm-ok` indicating that KVM acceleration can't be used, check the virtualization settings in the BIOS.
```bash * ### How do I assign an individual IP address to the container?
sudo apt install cpu-checker
sudo kvm-ok
```
If you receive an error from `kvm-ok` indicating that KVM acceleration can't be used, check the virtualization settings in the BIOS. By default, the container uses bridge networking, which shares the IP address with the host.
* ### How do I assign an individual IP address to the container? If you want to assign an individual IP address to the container, you can create a macvlan network as follows:
By default, the container uses bridge networking, which shares the IP address with the host. ```bash
docker network create -d macvlan \
--subnet=192.168.0.0/24 \
--gateway=192.168.0.1 \
--ip-range=192.168.0.100/28 \
-o parent=eth0 vdsm
```
Be sure to modify these values to match your local subnet.
If you want to assign an individual IP address to the container, you can create a macvlan network as follows: Once you have created the network, change your compose file to look as follows:
```bash ```yaml
docker network create -d macvlan \ services:
--subnet=192.168.0.0/24 \ dsm:
--gateway=192.168.0.1 \ container_name: dsm
--ip-range=192.168.0.100/28 \ ..<snip>..
-o parent=eth0 vdsm networks:
``` vdsm:
ipv4_address: 192.168.0.100
Be sure to modify these values to match your local subnet.
Once you have created the network, change your compose file to look as follows: networks:
vdsm:
external: true
```
An added benefit of this approach is that you won't have to perform any port mapping anymore, since all ports will be exposed by default.
```yaml Please note that this IP address won't be accessible from the Docker host due to the design of macvlan, which doesn't permit communication between the two. If this is a concern, you need to create a [second macvlan](https://blog.oddbit.com/post/2018-03-12-using-docker-macvlan-networks/#host-access) as a workaround.
services:
dsm:
container_name: dsm
..<snip>..
networks:
vdsm:
ipv4_address: 192.168.0.100
networks: * ### How can DSM acquire an IP address from my router?
vdsm:
external: true
```
An added benefit of this approach is that you won't have to perform any port mapping anymore, since all ports will be exposed by default.
Please note that this IP address won't be accessible from the Docker host due to the design of macvlan, which doesn't permit communication between the two. If this is a concern, you need to create a [second macvlan](https://blog.oddbit.com/post/2018-03-12-using-docker-macvlan-networks/#host-access) as a workaround. After configuring the container for macvlan (see above), it is possible for DSM to become part of your home network by requesting an IP from your router, just like your other devices.
* ### How can DSM acquire an IP address from my router? To enable this mode, add the following lines to your compose file:
After configuring the container for macvlan (see above), it is possible for DSM to become part of your home network by requesting an IP from your router, just like your other devices. ```yaml
environment:
DHCP: "Y"
device_cgroup_rules:
- 'c *:* rwm'
```
To enable this feature, add the following lines to your compose file: Please note that even if you don't need DHCP, it's still recommended to enable this mode, as it prevents NAT issues and increases performance by using a `macvtap` interface. You can just set a static IP from the DSM control panel afterwards.
```yaml * ### How do I pass-through the GPU?
environment:
DHCP: "Y"
device_cgroup_rules:
- 'c *:* rwm'
```
Please note that even if you don't want DHCP, it's still recommended to enable this feature, as it prevents NAT issues and increases performance by using a `macvtap` interface. In that case, just set a static IP from the DSM control panel after you enabled this mode. To pass-through your Intel GPU, add the following lines to your compose file:
* ### How do I pass-through the GPU? ```yaml
environment:
GPU: "Y"
devices:
- /dev/dri
```
To pass-through your Intel GPU, add the following lines to your compose file: This can be used to enable the facial recognition function in Synology Photos for example.
```yaml * ### How do I install a specific version of vDSM?
environment:
GPU: "Y"
devices:
- /dev/dri
```
This can be used to enable the facial recognition function in Synology Photos for example. By default, version 7.2 will be installed, but if you prefer an older version, you can add its download URL to your compose file as follows:
* ### How do I install a specific version of vDSM? ```yaml
environment:
URL: "https://global.synologydownload.com/download/DSM/release/7.0.1/42218/DSM_VirtualDSM_42218.pat"
```
By default, version 7.2 will be installed, but if you prefer an older version, you can add its download URL to your compose file as follows: With this method, it is even possible to switch between different versions while keeping all your file data intact.
```yaml * ### What are the differences compared to the standard DSM?
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. There are only two minor differences: the Virtual Machine Manager package is not available, and Surveillance Station will not include any free licenses.
* ### Is this project legal?
* ### What are the differences compared to the standard DSM? Yes, this project contains only open-source code and does not distribute any copyrighted material. Neither does it try to circumvent any copyright protection measures. So under all applicable laws, this project would be considered legal.
However, by installing Synology's Virtual DSM, you must accept their end-user license agreement, which does not permit installation on non-Synology hardware. So only run this project on an official Synology NAS, as any other use will be a violation of their terms and conditions.
There are only two minor differences: the Virtual Machine Manager package is not available, and Surveillance Station will not include any free licenses. ## Stars
[![Stars](https://starchart.cc/vdsm/virtual-dsm.svg?variant=adaptive)](https://starchart.cc/vdsm/virtual-dsm)
* ### Is this project legal?
Yes, this project contains only open-source code and does not distribute any copyrighted material. Neither does it try to circumvent any copyright protection measures. So under all applicable laws, this project would be considered legal.
However, by installing Synology's Virtual DSM, you must accept their end-user license agreement, which does not permit installation on non-Synology hardware. So only run this project on an official Synology NAS, as any other use will be a violation of their terms and conditions.
## Disclaimer ## Disclaimer

View File

@@ -80,7 +80,7 @@ getSize() {
isCow() { isCow() {
local FS=$1 local FS=$1
if [[ "${FS,,}" == "xfs" || "${FS,,}" == "zfs" || "${FS,,}" == "btrfs" || "${FS,,}" == "bcachefs" ]]; then if [[ "${FS,,}" == "btrfs" ]]; then
return 0 return 0
fi fi
@@ -113,7 +113,7 @@ createDisk() {
fi fi
html "Creating a $DISK_DESC image..." html "Creating a $DISK_DESC image..."
info "Creating a $DISK_TYPE $DISK_DESC image in $DISK_FMT format with a size of $DISK_SPACE..." info "Creating a $DISK_SPACE $DISK_TYPE $DISK_DESC image in $DISK_FMT format..."
local FAIL="Could not create a $DISK_TYPE $DISK_FMT $DISK_DESC image of $DISK_SPACE ($DISK_FILE)" local FAIL="Could not create a $DISK_TYPE $DISK_FMT $DISK_DESC image of $DISK_SPACE ($DISK_FILE)"
@@ -341,6 +341,21 @@ checkFS () {
return 0 return 0
} }
createDevice () {
local DISK_ID=$1
local DISK_FILE=$2
local DISK_INDEX=$3
local DISK_ADDRESS=$4
local DISK_FMT=$5
echo "-drive file=$DISK_FILE,if=none,id=drive-$DISK_ID,format=$DISK_FMT,cache=$DISK_CACHE,aio=$DISK_IO,discard=$DISK_DISCARD,detect-zeroes=on \
-device virtio-scsi-pci,id=hw-$DISK_ID,iothread=io2,bus=pcie.0,addr=$DISK_ADDRESS \
-device scsi-hd,bus=hw-$DISK_ID.0,channel=0,scsi-id=0,lun=0,drive=drive-$DISK_ID,id=$DISK_ID,rotation_rate=$DISK_ROTATION,bootindex=$DISK_INDEX"
return 0
}
addDisk () { addDisk () {
local DISK_ID=$1 local DISK_ID=$1
local DISK_BASE=$2 local DISK_BASE=$2
@@ -351,7 +366,7 @@ addDisk () {
local DISK_ADDRESS=$7 local DISK_ADDRESS=$7
local DISK_FMT=$8 local DISK_FMT=$8
local DISK_FILE="$DISK_BASE.$DISK_EXT" local DISK_FILE="$DISK_BASE.$DISK_EXT"
local DIR DATA_SIZE FS PREV_FMT PREV_EXT CUR_SIZE local DIR DATA_SIZE FS PREV_FMT PREV_EXT CUR_SIZE OPTS
DIR=$(dirname "$DISK_FILE") DIR=$(dirname "$DISK_FILE")
[ ! -d "$DIR" ] && return 0 [ ! -d "$DIR" ] && return 0
@@ -399,10 +414,8 @@ addDisk () {
fi fi
DISK_OPTS="$DISK_OPTS \ OPTS=$(createDevice "$DISK_ID" "$DISK_FILE" "$DISK_INDEX" "$DISK_ADDRESS" "$DISK_FMT")
-device virtio-scsi-pci,id=hw-$DISK_ID,iothread=io2,bus=pcie.0,addr=$DISK_ADDRESS \ DISK_OPTS="$DISK_OPTS $OPTS"
-drive file=$DISK_FILE,if=none,id=drive-$DISK_ID,format=$DISK_FMT,cache=$DISK_CACHE,aio=$DISK_IO,discard=$DISK_DISCARD,detect-zeroes=on \
-device scsi-hd,bus=hw-$DISK_ID.0,channel=0,scsi-id=0,lun=0,drive=drive-$DISK_ID,id=$DISK_ID,rotation_rate=$DISK_ROTATION,bootindex=$DISK_INDEX"
return 0 return 0
} }
@@ -418,10 +431,9 @@ addDevice () {
[ -z "$DISK_DEV" ] && return 0 [ -z "$DISK_DEV" ] && return 0
[ ! -b "$DISK_DEV" ] && error "Device $DISK_DEV cannot be found! Please add it to the 'devices' section of your compose file." && exit 55 [ ! -b "$DISK_DEV" ] && error "Device $DISK_DEV cannot be found! Please add it to the 'devices' section of your compose file." && exit 55
DISK_OPTS="$DISK_OPTS \ local OPTS
-device virtio-scsi-pci,id=hw-$DISK_ID,iothread=io2,bus=pcie.0,addr=$DISK_ADDRESS \ OPTS=$(createDevice "$DISK_ID" "$DISK_DEV" "$DISK_INDEX" "$DISK_ADDRESS" "raw")
-drive file=$DISK_DEV,if=none,id=drive-$DISK_ID,format=raw,cache=$DISK_CACHE,aio=$DISK_IO,discard=$DISK_DISCARD,detect-zeroes=on \ DISK_OPTS="$DISK_OPTS $OPTS"
-device scsi-hd,bus=hw-$DISK_ID.0,channel=0,scsi-id=0,lun=0,drive=drive-$DISK_ID,id=$DISK_ID,rotation_rate=$DISK_ROTATION,bootindex=$DISK_INDEX"
return 0 return 0
} }

View File

@@ -15,7 +15,8 @@ if [[ "$GPU" != [Yy1]* ]] || [[ "$ARCH" != "amd64" ]]; then
fi fi
DISPLAY_OPTS="-display egl-headless,rendernode=/dev/dri/renderD128 -vga $VGA" DISPLAY_OPTS="-display egl-headless,rendernode=/dev/dri/renderD128"
DISPLAY_OPTS="$DISPLAY_OPTS -vga $VGA"
[ ! -d /dev/dri ] && mkdir -m 755 /dev/dri [ ! -d /dev/dri ] && mkdir -m 755 /dev/dri

View File

@@ -65,7 +65,11 @@ if [[ "${FS,,}" == "fuse"* ]]; then
info "Warning: the filesystem of $STORAGE is FUSE, this extra layer will negatively affect performance!" info "Warning: the filesystem of $STORAGE is FUSE, this extra layer will negatively affect performance!"
fi fi
if [[ "${FS,,}" != "fat"* && "${FS,,}" != "vfat"* && "${FS,,}" != "exfat"* && "${FS,,}" != "ntfs"* && "${FS,,}" != "msdos"* ]]; then if [[ "${FS,,}" == "fat"* || "${FS,,}" == "vfat"* || "${FS,,}" == "msdos"* ]]; then
error "Unable to install on $FS filesystems, please use a different filesystem for /storage." && exit 61
fi
if [[ "${FS,,}" != "exfat"* && "${FS,,}" != "ntfs"* && "${FS,,}" != "unknown"* ]]; then
TMP="$STORAGE/tmp" TMP="$STORAGE/tmp"
else else
TMP="/tmp/dsm" TMP="/tmp/dsm"
@@ -105,6 +109,7 @@ RDC="$STORAGE/dsm.rd"
if [ ! -f "$RDC" ]; then if [ ! -f "$RDC" ]; then
MSG="Downloading installer..." MSG="Downloading installer..."
PRG="Downloading installer ([P])..."
info "Install: $MSG" && html "$MSG" info "Install: $MSG" && html "$MSG"
RD="$TMP/rd.gz" RD="$TMP/rd.gz"
@@ -112,7 +117,11 @@ if [ ! -f "$RDC" ]; then
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"
rm -f "$RD"
/run/progress.sh "$RD" "$PRG" &
{ curl -r "$POS" -sfk -S -o "$RD" "$LOC"; rc=$?; } || : { curl -r "$POS" -sfk -S -o "$RD" "$LOC"; rc=$?; } || :
fKill "progress.sh"
(( rc != 0 )) && error "Failed to download $LOC, reason: $rc" && exit 60 (( rc != 0 )) && error "Failed to download $LOC, reason: $rc" && exit 60
SUM=$(md5sum "$RD" | cut -f 1 -d " ") SUM=$(md5sum "$RD" | cut -f 1 -d " ")
@@ -123,8 +132,12 @@ if [ ! -f "$RDC" ]; then
rm "$RD" rm "$RD"
rm -f "$PAT" rm -f "$PAT"
html "$MSG"
/run/progress.sh "$PAT" "$PRG" &
{ wget "$LOC" -O "$PAT" -q --no-check-certificate --show-progress "$PROGRESS"; rc=$?; } || : { wget "$LOC" -O "$PAT" -q --no-check-certificate --show-progress "$PROGRESS"; rc=$?; } || :
(( rc != 0 )) && error "Failed to download $LOC, reason: $rc" && exit 60
fKill "progress.sh"
(( 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")"
rm "$PAT" rm "$PAT"
@@ -138,14 +151,14 @@ fi
if [ -f "$RDC" ]; then 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 on $FS, reason $rc" && exit 91
{ (cd "$TMP" && cpio -idm <"$TMP/rd" 2>/dev/null); rc=$?; } || : { (cd "$TMP" && cpio -idm <"$TMP/rd" 2>/dev/null); rc=$?; } || :
if (( rc != 0 )); then if (( rc != 0 )); then
ROOT="N" ROOT="N"
{ (cd "$TMP" && fakeroot cpio -idmu <"$TMP/rd" 2>/dev/null); rc=$?; } || : { (cd "$TMP" && fakeroot cpio -idmu <"$TMP/rd" 2>/dev/null); rc=$?; } || :
(( rc != 0 )) && error "Failed to extract $RDC, reason $rc" && exit 92 (( rc != 0 )) && error "Failed to extract $RDC on $FS, reason $rc" && exit 92
fi fi
rm -rf /run/extract && mkdir -p /run/extract rm -rf /run/extract && mkdir -p /run/extract
@@ -175,7 +188,10 @@ fi
rm -rf "$TMP" && mkdir -p "$TMP" rm -rf "$TMP" && mkdir -p "$TMP"
info "Install: Downloading $BASE.pat..." info "Install: Downloading $BASE.pat..."
html "Install: Downloading DSM from Synology..."
MSG="Downloading DSM..."
PRG="Downloading DSM ([P])..."
html "$MSG"
PAT="/$BASE.pat" PAT="/$BASE.pat"
rm -f "$PAT" rm -f "$PAT"
@@ -186,8 +202,12 @@ if [[ "$URL" == "file://"* ]]; then
else else
/run/progress.sh "$PAT" "$PRG" &
{ wget "$URL" -O "$PAT" -q --no-check-certificate --show-progress "$PROGRESS"; rc=$?; } || : { wget "$URL" -O "$PAT" -q --no-check-certificate --show-progress "$PROGRESS"; rc=$?; } || :
(( rc != 0 )) && error "Failed to download $URL, reason: $rc" && exit 69
fKill "progress.sh"
(( rc != 0 )) && error "Failed to download $URL , reason: $rc" && exit 69
fi fi
@@ -249,11 +269,11 @@ if ! touch "$SYSTEM"; then
error "Could not create file $SYSTEM for the system disk." && exit 98 error "Could not create file $SYSTEM for the system disk." && exit 98
fi fi
if [[ "${FS,,}" == "xfs" || "${FS,,}" == "zfs" || "${FS,,}" == "btrfs" || "${FS,,}" == "bcachefs" ]]; then if [[ "${FS,,}" == "btrfs" ]]; then
{ chattr +C "$SYSTEM"; } || : { chattr +C "$SYSTEM"; } || :
FA=$(lsattr "$SYSTEM") FA=$(lsattr "$SYSTEM")
if [[ "$FA" != *"C"* ]]; then if [[ "$FA" != *"C"* ]]; then
error "Failed to disable COW for system image $SYSTEM on ${FS^^} filesystem (returned $FA)" error "Failed to disable COW for system image $SYSTEM on ${FS^^} filesystem."
fi fi
fi fi

View File

@@ -3,8 +3,8 @@ set -Eeuo pipefail
# Docker environment variables # Docker environment variables
: "${MAC:=""}"
: "${DHCP:="N"}" : "${DHCP:="N"}"
: "${MAC:="02:11:32:AA:BB:CC"}"
: "${VM_NET_DEV:=""}" : "${VM_NET_DEV:=""}"
: "${VM_NET_TAP:="dsm"}" : "${VM_NET_TAP:="dsm"}"
@@ -33,7 +33,7 @@ configureDHCP() {
fi fi
while ! ip link set "$VM_NET_TAP" up; do while ! ip link set "$VM_NET_TAP" up; do
info "Waiting for address to become available..." info "Waiting for MAC address $VM_NET_MAC to become available..."
sleep 2 sleep 2
done done
@@ -80,10 +80,16 @@ configureDNS() {
# Set DNS server and gateway # Set DNS server and gateway
DNSMASQ_OPTS="$DNSMASQ_OPTS --dhcp-option=option:dns-server,${VM_NET_IP%.*}.1 --dhcp-option=option:router,${VM_NET_IP%.*}.1" DNSMASQ_OPTS="$DNSMASQ_OPTS --dhcp-option=option:dns-server,${VM_NET_IP%.*}.1 --dhcp-option=option:router,${VM_NET_IP%.*}.1"
DNSMASQ_OPTS=$(echo "$DNSMASQ_OPTS" | sed 's/\t/ /g' | tr -s ' ' | sed 's/^ *//')
# Add DNS entry for container
DNSMASQ_OPTS="$DNSMASQ_OPTS --address=/host.lan/${VM_NET_IP%.*}.1"
DNSMASQ_OPTS=$(echo "$DNSMASQ_OPTS" | sed 's/\t/ /g' | tr -s ' ' | sed 's/^ *//')
[[ "$DEBUG" == [Yy1]* ]] && set -x [[ "$DEBUG" == [Yy1]* ]] && set -x
$DNSMASQ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS}
if ! $DNSMASQ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS}; then
error "Failed to start dnsmasq, reason: $?" && exit 29
fi
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
[[ "$DEBUG" == [Yy1]* ]] && echo [[ "$DEBUG" == [Yy1]* ]] && echo
@@ -115,7 +121,6 @@ configureNAT() {
# Create a bridge with a static IP for the VM guest # Create a bridge with a static IP for the VM guest
VM_NET_IP='20.20.20.21' VM_NET_IP='20.20.20.21'
[[ "$DEBUG" == [Yy1]* ]] && set -x
{ ip link add dev dockerbridge type bridge ; rc=$?; } || : { ip link add dev dockerbridge type bridge ; rc=$?; } || :
@@ -126,7 +131,7 @@ configureNAT() {
ip address add ${VM_NET_IP%.*}.1/24 broadcast ${VM_NET_IP%.*}.255 dev dockerbridge ip address add ${VM_NET_IP%.*}.1/24 broadcast ${VM_NET_IP%.*}.255 dev dockerbridge
while ! ip link set dockerbridge up; do while ! ip link set dockerbridge up; do
info "Waiting for address to become available..." info "Waiting for IP address to become available..."
sleep 2 sleep 2
done done
@@ -134,7 +139,7 @@ configureNAT() {
ip tuntap add dev "$VM_NET_TAP" mode tap ip tuntap add dev "$VM_NET_TAP" mode tap
while ! ip link set "$VM_NET_TAP" up promisc on; do while ! ip link set "$VM_NET_TAP" up promisc on; do
info "Waiting for tap to become available..." info "Waiting for TAP to become available..."
sleep 2 sleep 2
done done
@@ -153,9 +158,6 @@ configureNAT() {
iptables -A POSTROUTING -t mangle -p udp --dport bootpc -j CHECKSUM --checksum-fill || true iptables -A POSTROUTING -t mangle -p udp --dport bootpc -j CHECKSUM --checksum-fill || true
fi fi
{ set +x; } 2>/dev/null
[[ "$DEBUG" == [Yy1]* ]] && echo
NET_OPTS="-netdev tap,ifname=$VM_NET_TAP,script=no,downscript=no,id=hostnet0" NET_OPTS="-netdev tap,ifname=$VM_NET_TAP,script=no,downscript=no,id=hostnet0"
{ exec 40>>/dev/vhost-net; rc=$?; } 2>/dev/null || : { exec 40>>/dev/vhost-net; rc=$?; } 2>/dev/null || :
@@ -209,14 +211,21 @@ getInfo() {
error "$ADD_ERR -e \"VM_NET_DEV=NAME\" to specify another interface name." && exit 27 error "$ADD_ERR -e \"VM_NET_DEV=NAME\" to specify another interface name." && exit 27
fi fi
if [ -z "$VM_NET_MAC" ]; then
# Generate MAC address based on Docker container ID in hostname
VM_NET_MAC=$(echo "$HOST" | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:11:32:\3:\4:\5/')
fi
VM_NET_MAC="${VM_NET_MAC^^}"
VM_NET_MAC="${VM_NET_MAC//-/:}" VM_NET_MAC="${VM_NET_MAC//-/:}"
if [[ ${#VM_NET_MAC} == 12 ]]; then if [[ ${#VM_NET_MAC} == 12 ]]; then
m="$VM_NET_MAC" m="$VM_NET_MAC"
VM_NET_MAC="${m:0:2}:${m:2:2}:${m:4:2}:${m:6:2}:${m:8:2}:${m:10:2}" VM_NET_MAC="${m:0:2}:${m:2:2}:${m:4:2}:${m:6:2}:${m:8:2}:${m:10:2}"
fi fi
if [[ ${#VM_NET_MAC} != 17 ]]; then if [[ ${#VM_NET_MAC} != 17 ]]; then
error "Invalid mac address: '$VM_NET_MAC', should be 12 or 17 digits long!" && exit 28 error "Invalid MAC address: '$VM_NET_MAC', should be 12 or 17 digits long!" && exit 28
fi fi
GATEWAY=$(ip r | grep default | awk '{print $3}') GATEWAY=$(ip r | grep default | awk '{print $3}')
@@ -240,15 +249,15 @@ getInfo
html "Initializing network..." html "Initializing network..."
if [[ "$DEBUG" == [Yy1]* ]]; then if [[ "$DEBUG" == [Yy1]* ]]; then
info "Container IP is $IP with gateway $GATEWAY on interface $VM_NET_DEV" && echo info "Host: $HOST IP: $IP Gateway: $GATEWAY Interface: $VM_NET_DEV MAC: $VM_NET_MAC"
[ -f /etc/resolv.conf ] && grep '^nameserver*' /etc/resolv.conf
echo
fi fi
if [[ "$DHCP" == [Yy1]* ]]; then if [[ "$DHCP" == [Yy1]* ]]; then
if [[ "$GATEWAY" == "172."* ]]; then if [[ "$GATEWAY" == "172."* ]] && [[ "$DEBUG" != [Yy1]* ]]; then
if [[ "$DEBUG" != [Yy1]* ]]; then error "You can only enable DHCP while the container is on a macvlan network!" && exit 26
error "You can only enable DHCP while the container is on a macvlan network!" && exit 26
fi
fi fi
# Configuration for DHCP IP # Configuration for DHCP IP

View File

@@ -34,6 +34,8 @@ finish() {
local pid local pid
local reason=$1 local reason=$1
touch "$QEMU_END"
if [ -f "$QEMU_PID" ]; then if [ -f "$QEMU_PID" ]; then
pid=$(<"$QEMU_PID") pid=$(<"$QEMU_PID")
@@ -168,6 +170,7 @@ _graceful_shutdown() {
MON_OPTS="\ MON_OPTS="\
-pidfile $QEMU_PID \ -pidfile $QEMU_PID \
-name $PROCESS,process=$PROCESS,debug-threads=on \
-monitor telnet:localhost:$QEMU_PORT,server,nowait,nodelay" -monitor telnet:localhost:$QEMU_PORT,server,nowait,nodelay"
if [[ "$CONSOLE" != [Yy]* ]]; then if [[ "$CONSOLE" != [Yy]* ]]; then

View File

@@ -6,7 +6,8 @@ set -Eeuo pipefail
: "${KVM:="Y"}" : "${KVM:="Y"}"
: "${HOST_CPU:=""}" : "${HOST_CPU:=""}"
: "${CPU_FLAGS:=""}" : "${CPU_FLAGS:=""}"
: "${CPU_MODEL:="host"}" : "${CPU_MODEL:=""}"
: "${DEF_MODEL:="qemu64"}"
[ "$ARCH" != "amd64" ] && KVM="N" [ "$ARCH" != "amd64" ] && KVM="N"
@@ -28,7 +29,7 @@ if [[ "$KVM" != [Nn]* ]]; then
if [ -n "$KVM_ERR" ]; then if [ -n "$KVM_ERR" ]; then
KVM="N" KVM="N"
error "KVM acceleration not detected $KVM_ERR, this will cause a major loss of performance." 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)." error "See the FAQ on how to enable it, or continue without KVM by setting KVM=N (not recommended)."
[[ "$DEBUG" != [Yy1]* ]] && exit 88 [[ "$DEBUG" != [Yy1]* ]] && exit 88
fi fi
@@ -37,35 +38,54 @@ fi
if [[ "$KVM" != [Nn]* ]]; then if [[ "$KVM" != [Nn]* ]]; then
CPU_FEATURES="kvm=on" CPU_FEATURES="kvm=on,l3-cache=on"
KVM_OPTS=",accel=kvm -enable-kvm" KVM_OPTS=",accel=kvm -enable-kvm -global kvm-pit.lost_tick_policy=discard"
if ! grep -qE '^flags.* (sse4_2)' /proc/cpuinfo; then if ! grep -qE '^flags.* (sse4_2)' /proc/cpuinfo; then
error "Your host CPU does not have the SSE4.2 instruction set that Virtual DSM requires to boot." info "Your CPU does not have the SSE4 instruction set that Virtual DSM requires, it will be emulated..."
error "Disable KVM by setting KVM=N to emulate a compatible CPU, at the cost of performance." [ -z "$CPU_MODEL" ] && CPU_MODEL="$DEF_MODEL"
[[ "$DEBUG" != [Yy1]* ]] && exit 89 CPU_FEATURES="$CPU_FEATURES,+ssse3,+sse4.1,+sse4.2"
fi
if [ -z "$CPU_MODEL" ]; then
CPU_MODEL="host"
CPU_FEATURES="$CPU_FEATURES,migratable=no"
fi fi
else else
KVM_OPTS="" KVM_OPTS=""
CPU_FEATURES="+ssse3,+sse4.1,+sse4.2" CPU_FEATURES="l3-cache=on"
if [[ "${CPU_MODEL,,}" == "host"* ]]; then if [[ "$ARCH" == "amd64" ]]; then
KVM_OPTS=" -accel tcg,thread=multi"
fi
if [ -z "$CPU_MODEL" ]; then
if [[ "$ARCH" == "amd64" ]]; then if [[ "$ARCH" == "amd64" ]]; then
CPU_MODEL="max" CPU_MODEL="max"
CPU_FEATURES="$CPU_FEATURES,migratable=no"
else else
CPU_MODEL="qemu64" CPU_MODEL="$DEF_MODEL"
fi fi
fi fi
CPU_FEATURES="$CPU_FEATURES,+ssse3,+sse4.1,+sse4.2"
fi fi
if [ -z "$CPU_FLAGS" ]; then if [ -z "$CPU_FLAGS" ]; then
CPU_FLAGS="$CPU_MODEL,$CPU_FEATURES" if [ -z "$CPU_FEATURES" ]; then
CPU_FLAGS="$CPU_MODEL"
else
CPU_FLAGS="$CPU_MODEL,$CPU_FEATURES"
fi
else else
CPU_FLAGS="$CPU_MODEL,$CPU_FEATURES,$CPU_FLAGS" if [ -z "$CPU_FEATURES" ]; then
CPU_FLAGS="$CPU_MODEL,$CPU_FLAGS"
else
CPU_FLAGS="$CPU_MODEL,$CPU_FEATURES,$CPU_FLAGS"
fi
fi fi
if [ -z "$HOST_CPU" ]; then if [ -z "$HOST_CPU" ]; then

32
src/progress.sh Normal file
View File

@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -Eeuo pipefail
escape () {
local s
s=${1//&/\&amp;}
s=${s//</\&lt;}
s=${s//>/\&gt;}
s=${s//'"'/\&quot;}
printf -- %s "$s"
return 0
}
file="$1"
body=$(escape "$2")
info="/run/shm/msg.html"
if [[ "$body" == *"..." ]]; then
body="<p class=\"loading\">${body/.../}</p>"
fi
while true
do
if [ -f "$file" ]; then
bytes=$(du -sb "$file" | cut -f1)
if (( bytes > 1000 )); then
size=$(echo "$bytes" | numfmt --to=iec --suffix=B | sed -r 's/([A-Z])/ \1/')
echo "${body//(\[P\])/($size)}"> "$info"
fi
fi
sleep 1 & wait $!
done

View File

@@ -28,6 +28,9 @@ echo
# Helper variables # Helper variables
PROCESS="${APP,,}"
PROCESS="${PROCESS// /-}"
STORAGE="/storage" STORAGE="/storage"
INFO="/run/shm/msg.html" INFO="/run/shm/msg.html"
PAGE="/run/shm/index.html" PAGE="/run/shm/index.html"
@@ -35,6 +38,7 @@ TEMPLATE="/var/www/index.html"
FOOTER1="$APP for Docker v$(</run/version)" FOOTER1="$APP for Docker v$(</run/version)"
FOOTER2="<a href='$SUPPORT'>$SUPPORT</a>" FOOTER2="<a href='$SUPPORT'>$SUPPORT</a>"
HOST=$(hostname -s)
KERNEL=$(uname -r | cut -b 1) KERNEL=$(uname -r | cut -b 1)
MINOR=$(uname -r | cut -d '.' -f2) MINOR=$(uname -r | cut -d '.' -f2)
ARCH=$(dpkg --print-architecture) ARCH=$(dpkg --print-architecture)

View File

@@ -9,6 +9,21 @@ set -Eeuo pipefail
: "${HOST_MODEL:=""}" : "${HOST_MODEL:=""}"
: "${GUEST_SERIAL:=""}" : "${GUEST_SERIAL:=""}"
if [ -n "$HOST_MAC" ]; then
HOST_MAC="${HOST_MAC//-/:}"
if [[ ${#HOST_MAC} == 12 ]]; then
m="$HOST_MAC"
HOST_MAC="${m:0:2}:${m:2:2}:${m:4:2}:${m:6:2}:${m:8:2}:${m:10:2}"
fi
if [[ ${#HOST_MAC} != 17 ]]; then
error "Invalid HOST_MAC address: '$HOST_MAC', should be 12 or 17 digits long!" && exit 28
fi
fi
HOST_ARGS=() HOST_ARGS=()
HOST_ARGS+=("-cpu=$CPU_CORES") HOST_ARGS+=("-cpu=$CPU_CORES")
HOST_ARGS+=("-cpu_arch=$HOST_CPU") HOST_ARGS+=("-cpu_arch=$HOST_CPU")

View File

@@ -1,7 +1,14 @@
body { body {
color: white; color: white;
background-color: #125bdb; background-color: #125bdb;
font-family: Verdana, Arial, sans-serif; font-smoothing: antialiased;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-family: Verdana, Geneva, sans-serif;
}
#info {
text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.25);
} }
#content { #content {
@@ -17,6 +24,7 @@ footer {
height: 40px; height: 40px;
text-align: center; text-align: center;
color: #0c8aeb; color: #0c8aeb;
text-shadow: 0 0 1px #0c8aeb;
} }
#empty { #empty {
@@ -33,8 +41,13 @@ a:visited {
footer a:link, footer a:link,
footer a:visited, footer a:visited,
footer a:active { color: #0c8aeb; } footer a:active {
footer a:hover { color: #73e6ff; } color: #0c8aeb;
}
footer a:hover {
color: #73e6ff;
}
.loading:after { .loading:after {
content: " ."; content: " .";