mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2026-08-29 04:07:02 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1b56f394a | ||
|
|
1a983ebcd1 | ||
|
|
41c76198fa | ||
|
|
222b5649b0 | ||
|
|
e14fd4b711 |
+268
-1
@@ -1 +1,268 @@
|
||||
build.sh
|
||||
##############################
|
||||
# Operating System Files
|
||||
##############################
|
||||
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
Desktop.ini
|
||||
Icon?
|
||||
$RECYCLE.BIN/
|
||||
.Spotlight-V100/
|
||||
.Trashes/
|
||||
.fseventsd
|
||||
|
||||
##############################
|
||||
# IDEs
|
||||
##############################
|
||||
|
||||
.vscode/
|
||||
.idea/
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
##############################
|
||||
# VS Code
|
||||
##############################
|
||||
|
||||
.history/
|
||||
*.code-workspace
|
||||
|
||||
##############################
|
||||
# Vim
|
||||
##############################
|
||||
|
||||
*.swp
|
||||
*.swo
|
||||
Session.vim
|
||||
|
||||
##############################
|
||||
# Sublime
|
||||
##############################
|
||||
|
||||
*.sublime-workspace
|
||||
*.sublime-project
|
||||
|
||||
##############################
|
||||
# Temporary Files
|
||||
##############################
|
||||
|
||||
*.tmp
|
||||
*.temp
|
||||
*.bak
|
||||
*.old
|
||||
*.orig
|
||||
*.rej
|
||||
*.save
|
||||
|
||||
##############################
|
||||
# Logs
|
||||
##############################
|
||||
|
||||
*.log
|
||||
logs/
|
||||
log/
|
||||
*.out
|
||||
*.err
|
||||
*.trace
|
||||
|
||||
##############################
|
||||
# Runtime
|
||||
##############################
|
||||
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
##############################
|
||||
# Secrets
|
||||
##############################
|
||||
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
*.pem
|
||||
*.key
|
||||
*.crt
|
||||
*.cer
|
||||
*.p12
|
||||
*.pfx
|
||||
*.kdbx
|
||||
*.secret
|
||||
*.token
|
||||
|
||||
##############################
|
||||
# SSH
|
||||
##############################
|
||||
|
||||
.ssh/
|
||||
|
||||
##############################
|
||||
# Docker
|
||||
##############################
|
||||
|
||||
docker-compose.override.yml
|
||||
docker-compose.local.yml
|
||||
|
||||
##############################
|
||||
# VM Storage
|
||||
##############################
|
||||
|
||||
storage/
|
||||
windows/
|
||||
downloads/
|
||||
|
||||
##############################
|
||||
# Disk Images
|
||||
##############################
|
||||
|
||||
*.qcow2
|
||||
*.qcow
|
||||
*.vhd
|
||||
*.vhdx
|
||||
*.vdi
|
||||
*.raw
|
||||
*.img
|
||||
*.iso
|
||||
*.bin
|
||||
|
||||
##############################
|
||||
# QEMU
|
||||
##############################
|
||||
|
||||
*.nvram
|
||||
*.fd
|
||||
*.efi
|
||||
*.sock
|
||||
*.monitor
|
||||
*.serial
|
||||
|
||||
##############################
|
||||
# Samba
|
||||
##############################
|
||||
|
||||
shared/
|
||||
share/
|
||||
|
||||
##############################
|
||||
# Backups
|
||||
##############################
|
||||
|
||||
backup/
|
||||
backups/
|
||||
*.backup
|
||||
|
||||
##############################
|
||||
# Cache
|
||||
##############################
|
||||
|
||||
.cache/
|
||||
.cache-loader/
|
||||
.tmp/
|
||||
temp/
|
||||
tmp/
|
||||
|
||||
##############################
|
||||
# Python
|
||||
##############################
|
||||
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
.pytest_cache/
|
||||
.mypy_cache/
|
||||
.venv/
|
||||
venv/
|
||||
|
||||
##############################
|
||||
# Node
|
||||
##############################
|
||||
|
||||
node_modules/
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
|
||||
##############################
|
||||
# Build
|
||||
##############################
|
||||
|
||||
dist/
|
||||
build/
|
||||
out/
|
||||
release/
|
||||
|
||||
##############################
|
||||
# Coverage
|
||||
##############################
|
||||
|
||||
coverage/
|
||||
.coverage
|
||||
coverage.xml
|
||||
|
||||
##############################
|
||||
# Archives
|
||||
##############################
|
||||
|
||||
*.zip
|
||||
*.tar
|
||||
*.tar.gz
|
||||
*.tgz
|
||||
*.7z
|
||||
*.rar
|
||||
|
||||
##############################
|
||||
# Generated Config
|
||||
##############################
|
||||
|
||||
config.local.*
|
||||
settings.local.*
|
||||
local.env
|
||||
|
||||
##############################
|
||||
# Test Files
|
||||
##############################
|
||||
|
||||
test-output/
|
||||
playwright-report/
|
||||
|
||||
##############################
|
||||
# macOS
|
||||
##############################
|
||||
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
|
||||
##############################
|
||||
# Linux
|
||||
##############################
|
||||
|
||||
*~
|
||||
.nfs*
|
||||
|
||||
##############################
|
||||
# Windows
|
||||
##############################
|
||||
|
||||
*.stackdump
|
||||
|
||||
##############################
|
||||
# Misc
|
||||
##############################
|
||||
|
||||
*.cache
|
||||
*.lock
|
||||
*.lock.json
|
||||
*.bak.*
|
||||
|
||||
##############################
|
||||
# Keep Examples
|
||||
##############################
|
||||
|
||||
!.gitkeep
|
||||
!.env.example
|
||||
|
||||
+5
-5
@@ -8,8 +8,8 @@ An empty default means the variable is unset and its value is determined automat
|
||||
|
||||
| Variable | Default | Description |
|
||||
|---|---|---|
|
||||
| `URL` | | URL or local path to the DSM `.pat` installation file. Downloads the default Virtual DSM image automatically when unset. |
|
||||
| `COUNTRY` | | Country code used to select the Synology download mirror. Detected automatically when unset. |
|
||||
| `URL` | | URL or local path to a custom `.pat` installation file. |
|
||||
| `COUNTRY` | | Country code used to select the Synology download mirror. |
|
||||
| `HOST_MAC` | | MAC address reported to DSM. |
|
||||
| `HOST_MODEL` | | Synology host model reported to DSM. |
|
||||
| `HOST_SERIAL` | | Synology host serial number reported to DSM. |
|
||||
@@ -47,14 +47,14 @@ An empty default means the variable is unset and its value is determined automat
|
||||
| Variable | Default | Description |
|
||||
|---|---|---|
|
||||
| `NETWORK` | | Network mode, such as `nat`, `user`, or `N` to disable networking. |
|
||||
| `DHCP` | `N` | Enables macvtap networking so DSM receives an address from the external LAN through DHCP. |
|
||||
| `HOST` | `VirtualDSM` | Hostname assigned to DSM. |
|
||||
| `DHCP` | `N` | Enables macvtap networking so DSM receives a DHCP address. |
|
||||
| `HOST` | | Hostname assigned to the machine on the network. |
|
||||
| `IP` | | Overrides the automatically selected guest IPv4 address. |
|
||||
| `MAC` | | Guest network adapter MAC address. |
|
||||
| `ADAPTER` | `virtio-net-pci` | QEMU network adapter model. |
|
||||
| `DEV` | `eth0` | Container network interface used as the uplink. |
|
||||
| `MTU` | | MTU assigned to the guest network interface. |
|
||||
| `MASK` | `255.255.255.0` | IPv4 netmask. |
|
||||
| `MASK` | `255.255.255.0` | IPv4 netmask for guest network. |
|
||||
| `TAP` | `dsm` | TAP or macvtap interface name. |
|
||||
| `BRIDGE` | `docker` | Bridge name used for NAT networking. |
|
||||
| `HOST_PORTS` | | Ports excluded from guest forwarding. |
|
||||
|
||||
+64
-5
@@ -2,6 +2,7 @@
|
||||
set -Eeuo pipefail
|
||||
|
||||
info="/run/shm/msg.html"
|
||||
info_tmp="${info}.${BASHPID}.tmp"
|
||||
|
||||
escape() {
|
||||
|
||||
@@ -17,6 +18,23 @@ escape() {
|
||||
return 0
|
||||
}
|
||||
|
||||
writeInfo() {
|
||||
|
||||
local content="$1"
|
||||
|
||||
if ! printf '%s\n' "$content" > "$info_tmp"; then
|
||||
rm -f -- "$info_tmp"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! mv -f -- "$info_tmp" "$info"; then
|
||||
rm -f -- "$info_tmp"
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
getBytes() {
|
||||
|
||||
local path="$1"
|
||||
@@ -48,6 +66,24 @@ getBytes() {
|
||||
return 0
|
||||
}
|
||||
|
||||
getStatus() {
|
||||
|
||||
local file="$1"
|
||||
local bytes total extra=""
|
||||
|
||||
[ -r "$file" ] || return 1
|
||||
read -r bytes total extra < "$file" || return 1
|
||||
|
||||
if [[ ! "$bytes" =~ ^[0-9]+$ ||
|
||||
! "$total" =~ ^[0-9]+$ ||
|
||||
-n "$extra" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
printf '%s %s\n' "$bytes" "$total"
|
||||
return 0
|
||||
}
|
||||
|
||||
formatSize() {
|
||||
|
||||
local bytes="$1"
|
||||
@@ -117,7 +153,9 @@ printSizeProgress() {
|
||||
return 0
|
||||
}
|
||||
|
||||
finishLogProgress() {
|
||||
finishProgress() {
|
||||
|
||||
rm -f -- "$info_tmp"
|
||||
|
||||
if [[ "$output" == "log" && "$printed" == "Y" ]]; then
|
||||
printf '\n'
|
||||
@@ -132,6 +170,7 @@ body=$(escape "$3")
|
||||
output="${4:-}"
|
||||
step_bytes="${5:-536870912}"
|
||||
mode="${6:-apparent}"
|
||||
status_file="${7:-}"
|
||||
|
||||
if [[ -n "$total" && ! "$total" =~ ^(0|[1-9][0-9]*)$ ]]; then
|
||||
printf 'Invalid total size: %s\n' "$total" >&2
|
||||
@@ -168,7 +207,7 @@ if [ -z "$total" ] || [[ "$total" == "0" ]]; then
|
||||
log_mode="size"
|
||||
fi
|
||||
|
||||
trap finishLogProgress EXIT
|
||||
trap finishProgress EXIT
|
||||
trap 'exit 0' HUP INT QUIT TERM
|
||||
|
||||
if [[ "$body" == *"..." ]]; then
|
||||
@@ -178,12 +217,32 @@ fi
|
||||
while true; do
|
||||
|
||||
bytes=$(getBytes "$path" "$mode")
|
||||
effective_total="$total"
|
||||
|
||||
if [ -n "$status_file" ] && status=$(getStatus "$status_file"); then
|
||||
read -r status_bytes status_total <<< "$status"
|
||||
bytes="$status_bytes"
|
||||
|
||||
if (( status_total > 0 )); then
|
||||
effective_total="$status_total"
|
||||
fi
|
||||
fi
|
||||
|
||||
# A real total may become available shortly after aria2 starts.
|
||||
if [[ "$log_mode" == "size" &&
|
||||
"$printed" == "N" &&
|
||||
-n "$effective_total" &&
|
||||
"$effective_total" != "0" ]]; then
|
||||
log_mode="percent"
|
||||
fi
|
||||
|
||||
if (( bytes > 4096 )); then
|
||||
|
||||
write_html="Y"
|
||||
|
||||
if [ -z "$total" ] || [[ "$total" == "0" ]] || (( bytes > total )); then
|
||||
if [ -z "$effective_total" ] ||
|
||||
[[ "$effective_total" == "0" ]] ||
|
||||
(( bytes > effective_total )); then
|
||||
size=$(formatSize "$bytes")
|
||||
|
||||
if [[ "$output" == "log" ]]; then
|
||||
@@ -197,7 +256,7 @@ while true; do
|
||||
fi
|
||||
else
|
||||
# Truncate to one decimal so progress is never reported early.
|
||||
progress=$((bytes * 1000 / total))
|
||||
progress=$((bytes * 1000 / effective_total))
|
||||
(( progress > 1000 )) && progress=1000
|
||||
|
||||
percent=$((progress / 10))
|
||||
@@ -219,7 +278,7 @@ while true; do
|
||||
fi
|
||||
|
||||
if [[ "$write_html" == "Y" ]]; then
|
||||
printf '%s\n' "${body//(\[P\])/($size)}" > "$info"
|
||||
writeInfo "${body//(\[P\])/($size)}"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
+15
-4
@@ -22,17 +22,28 @@ prepareWebFiles() {
|
||||
|
||||
configureWebPorts() {
|
||||
|
||||
sed -i "s/listen 5000 default_server;/listen $WEB_PORT default_server;/g" /etc/nginx/sites-enabled/web.conf
|
||||
sed -i "s/proxy_pass http:\/\/127.0.0.1:8004\/;/proxy_pass http:\/\/127.0.0.1:$WSD_PORT\/;/g" /etc/nginx/sites-enabled/web.conf
|
||||
if ! sed -i \
|
||||
-e "s|listen 5000 default_server;|listen $WEB_PORT default_server;|g" \
|
||||
-e "s|proxy_pass http://127.0.0.1:8004/;|proxy_pass http://127.0.0.1:$WSD_PORT/;|g" \
|
||||
/etc/nginx/sites-enabled/web.conf; then
|
||||
error "Failed to configure webserver ports!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
configureIpv6Listen() {
|
||||
|
||||
# shellcheck disable=SC2143
|
||||
if [ -f /proc/net/if_inet6 ] && [[ "$(cat /proc/sys/net/ipv6/conf/all/disable_ipv6 2>/dev/null)" != "1" ]]; then
|
||||
sed -i "s/listen $WEB_PORT default_server;/listen [::]:$WEB_PORT default_server ipv6only=off;/g" /etc/nginx/sites-enabled/web.conf
|
||||
|
||||
if ! sed -i \
|
||||
"s/listen $WEB_PORT default_server;/listen [::]:$WEB_PORT default_server ipv6only=off;/g" \
|
||||
/etc/nginx/sites-enabled/web.conf; then
|
||||
error "Failed to configure IPv6 webserver listener!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
return 0
|
||||
|
||||
+18
-5
@@ -3,6 +3,8 @@ set -Eeuo pipefail
|
||||
|
||||
lastmsg=""
|
||||
path="/run/shm/msg.html"
|
||||
dir=$(dirname -- "$path")
|
||||
name=$(basename -- "$path")
|
||||
|
||||
refresh() {
|
||||
|
||||
@@ -17,15 +19,26 @@ refresh() {
|
||||
|
||||
lastmsg="$msg"
|
||||
echo "s: $msg"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
refresh
|
||||
|
||||
inotifywait -m "$path" |
|
||||
while read -r fp event fn; do
|
||||
inotifywait \
|
||||
-m -q \
|
||||
-e close_write,moved_to,delete \
|
||||
--format '%e %f' \
|
||||
"$dir" |
|
||||
while read -r event file; do
|
||||
|
||||
[[ "$file" == "$name" ]] || continue
|
||||
|
||||
case "${event,,}" in
|
||||
"modify"* ) refresh ;;
|
||||
"delete_self" ) echo "c: vnc" ;;
|
||||
esac
|
||||
"delete"* )
|
||||
echo "c: vnc" ;;
|
||||
"close_write"* | "moved_to"* )
|
||||
refresh ;;
|
||||
esac
|
||||
|
||||
done
|
||||
|
||||
+21
-2
@@ -300,6 +300,25 @@ writeFile() {
|
||||
return 0
|
||||
}
|
||||
|
||||
writeAtomic() {
|
||||
|
||||
local path="$1"
|
||||
local content="$2"
|
||||
local tmp="${path}.${BASHPID}.tmp"
|
||||
|
||||
if ! printf '%s\n' "$content" > "$tmp"; then
|
||||
rm -f -- "$tmp"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! mv -f -- "$tmp" "$path"; then
|
||||
rm -f -- "$tmp"
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
readFile() {
|
||||
|
||||
local path="$1"
|
||||
@@ -411,8 +430,8 @@ html() {
|
||||
HTML="${HTML/\[4\]/$footer}"
|
||||
HTML="${HTML/\[5\]/$FOOTER2}"
|
||||
|
||||
echo "$HTML" > "$PAGE" || return 1
|
||||
echo "$body" > "$INFO" || return 1
|
||||
writeAtomic "$PAGE" "$HTML" || return 1
|
||||
writeAtomic "$INFO" "$body" || return 1
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
+41
-8
@@ -1,15 +1,27 @@
|
||||
var timer;
|
||||
var request;
|
||||
var booting = false;
|
||||
var interval = 1000;
|
||||
|
||||
function abortRequest() {
|
||||
|
||||
if (!request) {
|
||||
return false;
|
||||
}
|
||||
|
||||
request.onreadystatechange = null;
|
||||
request.abort();
|
||||
request = null;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function getInfo() {
|
||||
|
||||
var url = "msg.html";
|
||||
|
||||
try {
|
||||
if (request) {
|
||||
request.abort();
|
||||
}
|
||||
abortRequest();
|
||||
|
||||
if (window.XMLHttpRequest) {
|
||||
request = new XMLHttpRequest();
|
||||
@@ -56,7 +68,10 @@ function processInfo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
var msg = request.responseText;
|
||||
var response = request;
|
||||
request = null;
|
||||
|
||||
var msg = response.responseText;
|
||||
if (msg == null || msg.length == 0) {
|
||||
|
||||
if (booting) {
|
||||
@@ -68,9 +83,9 @@ function processInfo() {
|
||||
return false;
|
||||
}
|
||||
|
||||
var notFound = (request.status == 404);
|
||||
var notFound = (response.status == 404);
|
||||
|
||||
if (request.status == 200) {
|
||||
if (response.status == 200) {
|
||||
if (msg.toLowerCase().indexOf("<html>") !== -1) {
|
||||
notFound = true;
|
||||
} else {
|
||||
@@ -88,7 +103,7 @@ function processInfo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
setError("Error: Received statuscode " + request.status);
|
||||
setError("Error: Received statuscode " + response.status);
|
||||
return false;
|
||||
|
||||
} catch (e) {
|
||||
@@ -157,7 +172,9 @@ function setError(text) {
|
||||
}
|
||||
|
||||
function schedule() {
|
||||
setTimeout(getInfo, interval);
|
||||
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(getInfo, interval);
|
||||
}
|
||||
|
||||
function reload() {
|
||||
@@ -179,11 +196,27 @@ function connect() {
|
||||
|
||||
switch (cmd) {
|
||||
case "s":
|
||||
|
||||
var aborted = abortRequest();
|
||||
|
||||
processMsg(msg);
|
||||
|
||||
if (aborted &&
|
||||
msg.toLowerCase().indexOf("href=") == -1) {
|
||||
schedule();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "e":
|
||||
|
||||
if (abortRequest()) {
|
||||
schedule();
|
||||
}
|
||||
|
||||
setError(msg);
|
||||
break;
|
||||
|
||||
default:
|
||||
console.warn("Unknown event: " + cmd);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user