mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-11-08 02:53:45 +08:00
Compare commits
28 Commits
v7.34
...
0a0cd98de3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a0cd98de3 | ||
|
|
17187dd23a | ||
|
|
10237b31cf | ||
|
|
6883efb857 | ||
|
|
1ca55cad8f | ||
|
|
f841eb1ef1 | ||
|
|
1ee49332f3 | ||
|
|
095e618785 | ||
|
|
57a902ad9f | ||
|
|
a7e229aaae | ||
|
|
10466d7851 | ||
|
|
238ebd273b | ||
|
|
0b08f4212e | ||
|
|
9aec5d20e3 | ||
|
|
a19bf2f066 | ||
|
|
bee68ee548 | ||
|
|
520c70ab22 | ||
|
|
67a7fbc94b | ||
|
|
1b8054e847 | ||
|
|
631a558a9f | ||
|
|
d5805b4e08 | ||
|
|
1dc15ce2e0 | ||
|
|
4145e811df | ||
|
|
fe8615d7d3 | ||
|
|
27ea5506bc | ||
|
|
394131a0d7 | ||
|
|
4d0d16023f | ||
|
|
60dd794b29 |
2
.github/ISSUE_TEMPLATE/1-issue.yml
vendored
2
.github/ISSUE_TEMPLATE/1-issue.yml
vendored
@@ -21,6 +21,7 @@ body:
|
|||||||
attributes:
|
attributes:
|
||||||
label: Docker compose
|
label: Docker compose
|
||||||
description: The compose file (or otherwise the `docker run` command used).
|
description: The compose file (or otherwise the `docker run` command used).
|
||||||
|
render: yaml
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
@@ -28,6 +29,7 @@ body:
|
|||||||
attributes:
|
attributes:
|
||||||
label: Docker log
|
label: Docker log
|
||||||
description: The logfile of the container (as shown by `docker logs dsm`).
|
description: The logfile of the container (as shown by `docker logs dsm`).
|
||||||
|
render: shell
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
|
|||||||
2
.github/ISSUE_TEMPLATE/3-bug.yml
vendored
2
.github/ISSUE_TEMPLATE/3-bug.yml
vendored
@@ -23,6 +23,7 @@ body:
|
|||||||
attributes:
|
attributes:
|
||||||
label: Docker compose
|
label: Docker compose
|
||||||
description: The compose file (or otherwise the `docker run` command used).
|
description: The compose file (or otherwise the `docker run` command used).
|
||||||
|
render: yaml
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
@@ -30,6 +31,7 @@ body:
|
|||||||
attributes:
|
attributes:
|
||||||
label: Docker log
|
label: Docker log
|
||||||
description: The logfile of the container (as shown by `docker logs dsm`).
|
description: The logfile of the container (as shown by `docker logs dsm`).
|
||||||
|
render: shell
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
|
|||||||
16
.github/workflows/build.yml
vendored
16
.github/workflows/build.yml
vendored
@@ -2,20 +2,6 @@ name: Build
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
paths-ignore:
|
|
||||||
- '**/*.md'
|
|
||||||
- '**/*.yml'
|
|
||||||
- '**/*.js'
|
|
||||||
- '**/*.css'
|
|
||||||
- '**/*.html'
|
|
||||||
- 'web/**'
|
|
||||||
- '.gitignore'
|
|
||||||
- '.dockerignore'
|
|
||||||
- '.github/**'
|
|
||||||
- '.github/workflows/**'
|
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: build
|
group: build
|
||||||
@@ -36,7 +22,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
-
|
-
|
||||||
|
|||||||
4
.github/workflows/check.yml
vendored
4
.github/workflows/check.yml
vendored
@@ -9,7 +9,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Run ShellCheck
|
name: Run ShellCheck
|
||||||
uses: ludeeus/action-shellcheck@master
|
uses: ludeeus/action-shellcheck@master
|
||||||
@@ -17,7 +17,7 @@ jobs:
|
|||||||
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
|
name: Lint Dockerfile
|
||||||
uses: hadolint/hadolint-action@v3.1.0
|
uses: hadolint/hadolint-action@v3.3.0
|
||||||
with:
|
with:
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
ignore: DL3008,DL3003,DL3006,DL3013
|
ignore: DL3008,DL3003,DL3006,DL3013
|
||||||
|
|||||||
2
.github/workflows/hub.yml
vendored
2
.github/workflows/hub.yml
vendored
@@ -12,7 +12,7 @@ jobs:
|
|||||||
dockerHubDescription:
|
dockerHubDescription:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Docker Hub Description
|
name: Docker Hub Description
|
||||||
uses: peter-evans/dockerhub-description@v4
|
uses: peter-evans/dockerhub-description@v4
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
FROM qemux/qemu-host:2.05 AS builder
|
FROM qemux/qemu-host:2.05 AS builder
|
||||||
|
|
||||||
# FROM golang as builder
|
# FROM golang as builder
|
||||||
@@ -61,9 +63,9 @@ ADD --chmod=775 https://raw.githubusercontent.com/sud0woodo/patology/refs/heads/
|
|||||||
VOLUME /storage
|
VOLUME /storage
|
||||||
EXPOSE 22 139 445 5000
|
EXPOSE 22 139 445 5000
|
||||||
|
|
||||||
ENV RAM_SIZE="1G"
|
ENV RAM_SIZE="2G"
|
||||||
|
ENV CPU_CORES="2"
|
||||||
ENV DISK_SIZE="16G"
|
ENV DISK_SIZE="16G"
|
||||||
ENV CPU_CORES="1"
|
|
||||||
|
|
||||||
HEALTHCHECK --interval=60s --start-period=45s --retries=2 CMD /run/check.sh
|
HEALTHCHECK --interval=60s --start-period=45s --retries=2 CMD /run/check.sh
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ services:
|
|||||||
##### Via Docker CLI:
|
##### Via Docker CLI:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -it --rm --name dsm -p 5000:5000 --device=/dev/kvm --device=/dev/net/tun --cap-add NET_ADMIN -v ${PWD:-.}/dsm:/storage --stop-timeout 120 vdsm/virtual-dsm
|
docker run -it --rm --name dsm -p 5000:5000 --device=/dev/kvm --device=/dev/net/tun --cap-add NET_ADMIN -v "${PWD:-.}/dsm:/storage" --stop-timeout 120 vdsm/virtual-dsm
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Via Kubernetes:
|
##### Via Kubernetes:
|
||||||
@@ -135,7 +135,7 @@ kubectl apply -f https://raw.githubusercontent.com/vdsm/virtual-dsm/refs/heads/m
|
|||||||
|
|
||||||
### How do I change the amount of CPU or RAM?
|
### How do I change the amount of CPU or RAM?
|
||||||
|
|
||||||
By default, the container will be allowed to use a maximum of 1 CPU core and 1 GB of RAM.
|
By default, the container will be allowed to use a maximum of 2 CPU cores and 2 GB of RAM.
|
||||||
|
|
||||||
If you want to adjust this, you can specify the desired amount using the following environment variables:
|
If you want to adjust this, you can specify the desired amount using the following environment variables:
|
||||||
|
|
||||||
|
|||||||
12
src/disk.sh
12
src/disk.sh
@@ -82,7 +82,7 @@ isCow() {
|
|||||||
supportsDirect() {
|
supportsDirect() {
|
||||||
local FS=$1
|
local FS=$1
|
||||||
|
|
||||||
if [[ "${FS,,}" == "ecryptfs" ]] || [[ "${FS,,}" == "tmpfs" ]]; then
|
if [[ "${FS,,}" == "ecryptfs" || "${FS,,}" == "tmpfs" ]]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -320,7 +320,7 @@ convertDisk() {
|
|||||||
|
|
||||||
msg="Conversion of $DISK_DESC"
|
msg="Conversion of $DISK_DESC"
|
||||||
html "$msg completed..."
|
html "$msg completed..."
|
||||||
info "$msg to $DST_FMT completed succesfully!"
|
info "$msg to $DST_FMT completed successfully!"
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -507,7 +507,7 @@ addDevice () {
|
|||||||
physical="${physical%% *}"
|
physical="${physical%% *}"
|
||||||
|
|
||||||
if [ -n "$physical" ]; then
|
if [ -n "$physical" ]; then
|
||||||
if [[ "$physical" == "512" ]] || [[ "$physical" == "4096" ]]; then
|
if [[ "$physical" == "512" || "$physical" == "4096" ]]; then
|
||||||
if [[ "$physical" == "4096" ]]; then
|
if [[ "$physical" == "4096" ]]; then
|
||||||
sectors=",logical_block_size=$logical,physical_block_size=$physical"
|
sectors=",logical_block_size=$logical,physical_block_size=$physical"
|
||||||
fi
|
fi
|
||||||
@@ -554,7 +554,7 @@ DISK_OPTS+=$(createDevice "$BOOT" "$DISK_TYPE" "1" "0xa" "raw" "$DISK_IO" "$DISK
|
|||||||
DISK_OPTS+=$(createDevice "$SYSTEM" "$DISK_TYPE" "2" "0xb" "raw" "$DISK_IO" "$DISK_CACHE" "" "")
|
DISK_OPTS+=$(createDevice "$SYSTEM" "$DISK_TYPE" "2" "0xb" "raw" "$DISK_IO" "$DISK_CACHE" "" "")
|
||||||
|
|
||||||
DISK1_FILE="$STORAGE/${DISK_NAME}"
|
DISK1_FILE="$STORAGE/${DISK_NAME}"
|
||||||
if [[ ! -f "$DISK1_FILE.img" ]] && [[ -f "$STORAGE/data${DISK_SIZE}.img" ]]; then
|
if [[ ! -f "$DISK1_FILE.img" && -f "$STORAGE/data${DISK_SIZE}.img" ]]; then
|
||||||
# Fallback for legacy installs
|
# Fallback for legacy installs
|
||||||
mv "$STORAGE/data${DISK_SIZE}.img" "$DISK1_FILE.img"
|
mv "$STORAGE/data${DISK_SIZE}.img" "$DISK1_FILE.img"
|
||||||
fi
|
fi
|
||||||
@@ -563,7 +563,7 @@ DISK2_FILE="/storage2/${DISK_NAME}2"
|
|||||||
if [ ! -f "$DISK2_FILE.img" ]; then
|
if [ ! -f "$DISK2_FILE.img" ]; then
|
||||||
# Fallback for legacy installs
|
# Fallback for legacy installs
|
||||||
FALLBACK="/storage2/data.img"
|
FALLBACK="/storage2/data.img"
|
||||||
if [[ -f "$DISK1_FILE.img" ]] && [[ -f "$FALLBACK" ]]; then
|
if [[ -f "$DISK1_FILE.img" && -f "$FALLBACK" ]]; then
|
||||||
SIZE1=$(stat -c%s "$FALLBACK")
|
SIZE1=$(stat -c%s "$FALLBACK")
|
||||||
SIZE2=$(stat -c%s "$DISK1_FILE.img")
|
SIZE2=$(stat -c%s "$DISK1_FILE.img")
|
||||||
if [[ SIZE1 -ne SIZE2 ]]; then
|
if [[ SIZE1 -ne SIZE2 ]]; then
|
||||||
@@ -576,7 +576,7 @@ DISK3_FILE="/storage3/${DISK_NAME}3"
|
|||||||
if [ ! -f "$DISK3_FILE.img" ]; then
|
if [ ! -f "$DISK3_FILE.img" ]; then
|
||||||
# Fallback for legacy installs
|
# Fallback for legacy installs
|
||||||
FALLBACK="/storage3/data.img"
|
FALLBACK="/storage3/data.img"
|
||||||
if [[ -f "$DISK1_FILE.img" ]] && [[ -f "$FALLBACK" ]]; then
|
if [[ -f "$DISK1_FILE.img" && -f "$FALLBACK" ]]; then
|
||||||
SIZE1=$(stat -c%s "$FALLBACK")
|
SIZE1=$(stat -c%s "$FALLBACK")
|
||||||
SIZE2=$(stat -c%s "$DISK1_FILE.img")
|
SIZE2=$(stat -c%s "$DISK1_FILE.img")
|
||||||
if [[ SIZE1 -ne SIZE2 ]]; then
|
if [[ SIZE1 -ne SIZE2 ]]; then
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ set -Eeuo pipefail
|
|||||||
: "${DISPLAY:="none"}" # Display type
|
: "${DISPLAY:="none"}" # Display type
|
||||||
: "${RENDERNODE:="/dev/dri/renderD128"}" # Render node
|
: "${RENDERNODE:="/dev/dri/renderD128"}" # Render node
|
||||||
|
|
||||||
if [[ "$GPU" != [Yy1]* ]] || [[ "$ARCH" != "amd64" ]]; then
|
CPU_VENDOR=$(lscpu | awk '/Vendor ID/{print $3}')
|
||||||
|
|
||||||
|
if [[ "$GPU" != [Yy1]* || "$CPU_VENDOR" != "GenuineIntel" || "$ARCH" != "amd64" ]]; then
|
||||||
|
|
||||||
[[ "${DISPLAY,,}" == "none" ]] && VGA="none"
|
[[ "${DISPLAY,,}" == "none" ]] && VGA="none"
|
||||||
DISPLAY_OPTS="-display $DISPLAY -vga $VGA"
|
DISPLAY_OPTS="-display $DISPLAY -vga $VGA"
|
||||||
|
|||||||
@@ -13,18 +13,18 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
FN="boot.pat"
|
FN="boot.pat"
|
||||||
DIR=$(find / -maxdepth 1 -type d -iname "$FN" | head -n 1)
|
DIR=$(find / -maxdepth 1 -type d -iname "$FN" -print -quit)
|
||||||
[ ! -d "$DIR" ] && DIR=$(find "$STORAGE" -maxdepth 1 -type d -iname "$FN" | head -n 1)
|
[ ! -d "$DIR" ] && DIR=$(find "$STORAGE" -maxdepth 1 -type d -iname "$FN" -print -quit)
|
||||||
|
|
||||||
if [ -d "$DIR" ]; then
|
if [ -d "$DIR" ]; then
|
||||||
BASE="DSM_VirtualDSM" && URL="file://$DIR"
|
BASE="DSM_VirtualDSM" && URL="file://$DIR"
|
||||||
if [[ ! -s "$STORAGE/$BASE.boot.img" ]] || [[ ! -s "$STORAGE/$BASE.system.img" ]]; then
|
if [[ ! -s "$STORAGE/$BASE.boot.img" || ! -s "$STORAGE/$BASE.system.img" ]]; then
|
||||||
error "The bind $DIR maps to a file that does not exist!" && exit 65
|
error "The bind $DIR maps to a file that does not exist!" && exit 65
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FILE=$(find / -maxdepth 1 -type f -iname "$FN" | head -n 1)
|
FILE=$(find / -maxdepth 1 -type f -iname "$FN" -print -quit)
|
||||||
[ ! -s "$FILE" ] && FILE=$(find "$STORAGE" -maxdepth 1 -type f -iname "$FN" | head -n 1)
|
[ ! -s "$FILE" ] && FILE=$(find "$STORAGE" -maxdepth 1 -type f -iname "$FN" -print -quit)
|
||||||
[ -s "$FILE" ] && BASE="DSM_VirtualDSM" && URL="file://$FILE"
|
[ -s "$FILE" ] && BASE="DSM_VirtualDSM" && URL="file://$FILE"
|
||||||
|
|
||||||
if [ -n "$URL" ] && [ ! -s "$FILE" ] && [ ! -d "$DIR" ]; then
|
if [ -n "$URL" ] && [ ! -s "$FILE" ] && [ ! -d "$DIR" ]; then
|
||||||
@@ -34,13 +34,13 @@ if [ -n "$URL" ] && [ ! -s "$FILE" ] && [ ! -d "$DIR" ]; 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"* ]] && [[ "${URL,,}" != "file:"* ]] ; then
|
if [[ "${URL,,}" != "http"* && "${URL,,}" != "file:"* ]] ; then
|
||||||
[ ! -s "$STORAGE/$BASE.pat" ] && error "Invalid URL: $URL" && exit 65
|
[ ! -s "$STORAGE/$BASE.pat" ] && error "Invalid URL: $URL" && exit 65
|
||||||
URL="file://$STORAGE/$BASE.pat"
|
URL="file://$STORAGE/$BASE.pat"
|
||||||
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
|
||||||
return 0 # Previous installation found
|
return 0 # Previous installation found
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ 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,,}" == "ecryptfs" ]] || [[ "${FS,,}" == "tmpfs" ]]; then
|
if [[ "${FS,,}" == "ecryptfs" || "${FS,,}" == "tmpfs" ]]; then
|
||||||
info "Warning: the filesystem of $STORAGE is $FS, which does not support O_DIRECT mode, adjusting settings..."
|
info "Warning: the filesystem of $STORAGE is $FS, which does not support O_DIRECT mode, adjusting settings..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ configureDHCP() {
|
|||||||
fi ;;
|
fi ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ "$MTU" != "0" ]] && [[ "$MTU" != "1500" ]]; then
|
if [[ "$MTU" != "0" && "$MTU" != "1500" ]]; then
|
||||||
if ! ip link set dev "$VM_NET_TAP" mtu "$MTU"; then
|
if ! ip link set dev "$VM_NET_TAP" mtu "$MTU"; then
|
||||||
warn "Failed to set MTU size.."
|
warn "Failed to set MTU size.."
|
||||||
fi
|
fi
|
||||||
@@ -78,7 +78,7 @@ configureDHCP() {
|
|||||||
IFS=: read -r MAJOR MINOR < <(cat /sys/devices/virtual/net/"$VM_NET_TAP"/tap*/dev)
|
IFS=: read -r MAJOR MINOR < <(cat /sys/devices/virtual/net/"$VM_NET_TAP"/tap*/dev)
|
||||||
(( MAJOR < 1)) && error "Cannot find: sys/devices/virtual/net/$VM_NET_TAP" && return 1
|
(( MAJOR < 1)) && error "Cannot find: sys/devices/virtual/net/$VM_NET_TAP" && return 1
|
||||||
|
|
||||||
[[ ! -e "$TAP_PATH" ]] && [[ -e "/dev0/${TAP_PATH##*/}" ]] && ln -s "/dev0/${TAP_PATH##*/}" "$TAP_PATH"
|
[[ ! -e "$TAP_PATH" && -e "/dev0/${TAP_PATH##*/}" ]] && ln -s "/dev0/${TAP_PATH##*/}" "$TAP_PATH"
|
||||||
|
|
||||||
if [[ ! -e "$TAP_PATH" ]]; then
|
if [[ ! -e "$TAP_PATH" ]]; then
|
||||||
{ mknod "$TAP_PATH" c "$MAJOR" "$MINOR" ; rc=$?; } || :
|
{ mknod "$TAP_PATH" c "$MAJOR" "$MINOR" ; rc=$?; } || :
|
||||||
@@ -152,7 +152,18 @@ getUserPorts() {
|
|||||||
list="${list%% }"
|
list="${list%% }"
|
||||||
|
|
||||||
for port in $list; do
|
for port in $list; do
|
||||||
args+="hostfwd=tcp::$port-$VM_NET_IP:$port,"
|
proto="tcp"
|
||||||
|
num="$port"
|
||||||
|
|
||||||
|
if [[ "$port" == */udp ]]; then
|
||||||
|
proto="udp"
|
||||||
|
num="${port%/udp}"
|
||||||
|
elif [[ "$port" == */tcp ]]; then
|
||||||
|
proto="tcp"
|
||||||
|
num="${port%/tcp}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
args+="hostfwd=$proto::$num-$VM_NET_IP:$num,"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "${args%?}"
|
echo "${args%?}"
|
||||||
@@ -176,7 +187,11 @@ getHostPorts() {
|
|||||||
|
|
||||||
configureUser() {
|
configureUser() {
|
||||||
|
|
||||||
NET_OPTS="-netdev user,id=hostnet0,host=${VM_NET_IP%.*}.1,net=${VM_NET_IP%.*}.0/24,dhcpstart=$VM_NET_IP,hostname=$VM_NET_HOST"
|
if [ -z "$IP6" ]; then
|
||||||
|
NET_OPTS="-netdev user,id=hostnet0,host=${VM_NET_IP%.*}.1,net=${VM_NET_IP%.*}.0/24,dhcpstart=$VM_NET_IP,hostname=$VM_NET_HOST"
|
||||||
|
else
|
||||||
|
NET_OPTS="-netdev user,id=hostnet0,ipv4=on,host=${VM_NET_IP%.*}.1,net=${VM_NET_IP%.*}.0/24,dhcpstart=$VM_NET_IP,ipv6=on,hostname=$VM_NET_HOST"
|
||||||
|
fi
|
||||||
|
|
||||||
local forward
|
local forward
|
||||||
forward=$(getUserPorts "$USER_PORTS")
|
forward=$(getUserPorts "$USER_PORTS")
|
||||||
@@ -192,6 +207,7 @@ configureNAT() {
|
|||||||
|
|
||||||
# Create the necessary file structure for /dev/net/tun
|
# Create the necessary file structure for /dev/net/tun
|
||||||
if [ ! -c /dev/net/tun ]; then
|
if [ ! -c /dev/net/tun ]; then
|
||||||
|
[[ "$PODMAN" == [Yy1]* ]] && return 1
|
||||||
[ ! -d /dev/net ] && mkdir -m 755 /dev/net
|
[ ! -d /dev/net ] && mkdir -m 755 /dev/net
|
||||||
if mknod /dev/net/tun c 10 200; then
|
if mknod /dev/net/tun c 10 200; then
|
||||||
chmod 666 /dev/net/tun
|
chmod 666 /dev/net/tun
|
||||||
@@ -199,15 +215,15 @@ configureNAT() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -c /dev/net/tun ]; then
|
if [ ! -c /dev/net/tun ]; then
|
||||||
[[ "$PODMAN" != [Yy1]* ]] && error "$tuntap"
|
error "$tuntap" && return 1
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check port forwarding flag
|
# Check port forwarding flag
|
||||||
if [[ $(< /proc/sys/net/ipv4/ip_forward) -eq 0 ]]; then
|
if [[ $(< /proc/sys/net/ipv4/ip_forward) -eq 0 ]]; then
|
||||||
{ sysctl -w net.ipv4.ip_forward=1 > /dev/null; rc=$?; } || :
|
{ sysctl -w net.ipv4.ip_forward=1 > /dev/null 2>&1; rc=$?; } || :
|
||||||
if (( rc != 0 )) || [[ $(< /proc/sys/net/ipv4/ip_forward) -eq 0 ]]; then
|
if (( rc != 0 )) || [[ $(< /proc/sys/net/ipv4/ip_forward) -eq 0 ]]; then
|
||||||
[[ "$PODMAN" != [Yy1]* ]] && error "IP forwarding is disabled. $ADD_ERR --sysctl net.ipv4.ip_forward=1"
|
[[ "$PODMAN" == [Yy1]* ]] && return 1
|
||||||
|
error "IP forwarding is disabled. $ADD_ERR --sysctl net.ipv4.ip_forward=1"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -233,7 +249,7 @@ configureNAT() {
|
|||||||
error "$tuntap" && return 1
|
error "$tuntap" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$MTU" != "0" ]] && [[ "$MTU" != "1500" ]]; then
|
if [[ "$MTU" != "0" && "$MTU" != "1500" ]]; then
|
||||||
if ! ip link set dev "$VM_NET_TAP" mtu "$MTU"; then
|
if ! ip link set dev "$VM_NET_TAP" mtu "$MTU"; then
|
||||||
warn "Failed to set MTU size.."
|
warn "Failed to set MTU size.."
|
||||||
fi
|
fi
|
||||||
@@ -310,7 +326,7 @@ closeBridge() {
|
|||||||
|
|
||||||
closeNetwork() {
|
closeNetwork() {
|
||||||
|
|
||||||
if [[ "$DHCP" == [Yy1]* ]]; then
|
if [[ "${WEB:-}" != [Nn]* && "$DHCP" == [Yy1]* ]]; then
|
||||||
|
|
||||||
# Shutdown nginx
|
# Shutdown nginx
|
||||||
nginx -s stop 2> /dev/null
|
nginx -s stop 2> /dev/null
|
||||||
@@ -391,7 +407,7 @@ getInfo() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${ADAPTER,,}" != "virtio-net-pci" ]]; then
|
if [[ "${ADAPTER,,}" != "virtio-net-pci" ]]; then
|
||||||
if [[ "$MTU" != "0" ]] && [[ "$MTU" != "1500" ]]; then
|
if [[ "$MTU" != "0" && "$MTU" != "1500" ]]; then
|
||||||
warn "MTU size is $MTU, but cannot be set for $ADAPTER adapters!" && MTU="0"
|
warn "MTU size is $MTU, but cannot be set for $ADAPTER adapters!" && MTU="0"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -450,7 +466,7 @@ html "Initializing network..."
|
|||||||
if [[ "$DEBUG" == [Yy1]* ]]; then
|
if [[ "$DEBUG" == [Yy1]* ]]; then
|
||||||
mtu=$(cat "/sys/class/net/$VM_NET_DEV/mtu")
|
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"
|
line="Host: $HOST IP: $IP Gateway: $GATEWAY Interface: $VM_NET_DEV MAC: $VM_NET_MAC MTU: $mtu"
|
||||||
[[ "$MTU" != "0" ]] && [[ "$MTU" != "$mtu" ]] && line+=" ($MTU)"
|
[[ "$MTU" != "0" && "$MTU" != "$mtu" ]] && line+=" ($MTU)"
|
||||||
info "$line"
|
info "$line"
|
||||||
if [ -f /etc/resolv.conf ]; then
|
if [ -f /etc/resolv.conf ]; then
|
||||||
nameservers=$(grep '^nameserver*' /etc/resolv.conf | head -c -1 | sed 's/nameserver //g;' | sed -z 's/\n/, /g')
|
nameservers=$(grep '^nameserver*' /etc/resolv.conf | head -c -1 | sed 's/nameserver //g;' | sed -z 's/\n/, /g')
|
||||||
@@ -484,13 +500,17 @@ if [[ "$DHCP" == [Yy1]* ]]; then
|
|||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
if [[ "$IP" != "172."* ]] && [[ "$IP" != "10.8"* ]] && [[ "$IP" != "10.9"* ]]; then
|
if [[ "$IP" != "172."* && "$IP" != "10.8"* && "$IP" != "10.9"* ]]; then
|
||||||
checkOS
|
checkOS
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Shutdown nginx
|
if [[ "${WEB:-}" != [Nn]* ]]; then
|
||||||
nginx -s stop 2> /dev/null
|
|
||||||
fWait "nginx"
|
# Shutdown nginx
|
||||||
|
nginx -s stop 2> /dev/null
|
||||||
|
fWait "nginx"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "${NETWORK,,}" != "user"* ]]; then
|
if [[ "${NETWORK,,}" != "user"* ]]; then
|
||||||
|
|
||||||
@@ -522,6 +542,6 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
NET_OPTS+=" -device $ADAPTER,id=net0,netdev=hostnet0,romfile=,mac=$VM_NET_MAC"
|
NET_OPTS+=" -device $ADAPTER,id=net0,netdev=hostnet0,romfile=,mac=$VM_NET_MAC"
|
||||||
[[ "$MTU" != "0" ]] && [[ "$MTU" != "1500" ]] && NET_OPTS+=",host_mtu=$MTU"
|
[[ "$MTU" != "0" && "$MTU" != "1500" ]] && NET_OPTS+=",host_mtu=$MTU"
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ set -Eeuo pipefail
|
|||||||
# Configure QEMU for graceful shutdown
|
# Configure QEMU for graceful shutdown
|
||||||
|
|
||||||
API_CMD=6
|
API_CMD=6
|
||||||
API_TIMEOUT=50
|
|
||||||
API_HOST="127.0.0.1:2210"
|
API_HOST="127.0.0.1:2210"
|
||||||
|
: "${API_TIMEOUT:="50"}" # API Call timeout
|
||||||
|
|
||||||
QEMU_TERM=""
|
QEMU_TERM=""
|
||||||
QEMU_PORT=7100
|
QEMU_PORT=7100
|
||||||
QEMU_TIMEOUT=50
|
: "${QEMU_TIMEOUT:="50"}" # QEMU Termination timeout
|
||||||
QEMU_DIR="/run/shm"
|
QEMU_DIR="/run/shm"
|
||||||
QEMU_PID="$QEMU_DIR/qemu.pid"
|
QEMU_PID="$QEMU_DIR/qemu.pid"
|
||||||
QEMU_LOG="$QEMU_DIR/qemu.log"
|
QEMU_LOG="$QEMU_DIR/qemu.log"
|
||||||
|
|||||||
24
src/proc.sh
24
src/proc.sh
@@ -128,6 +128,30 @@ else
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "$ARGUMENTS" == *"-cpu host,"* ]]; then
|
||||||
|
|
||||||
|
args="${ARGUMENTS} "
|
||||||
|
prefix="${args/-cpu host,*/}"
|
||||||
|
suffix="${args/*-cpu host,/}"
|
||||||
|
param="${suffix%% *}"
|
||||||
|
suffix="${suffix#* }"
|
||||||
|
args="${prefix}${suffix}"
|
||||||
|
ARGUMENTS="${args::-1}"
|
||||||
|
|
||||||
|
if [ -z "$CPU_FLAGS" ]; then
|
||||||
|
CPU_FLAGS="$param"
|
||||||
|
else
|
||||||
|
CPU_FLAGS+=",$param"
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
if [[ "$ARGUMENTS" == *"-cpu host"* ]]; then
|
||||||
|
ARGUMENTS="${ARGUMENTS//-cpu host/}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$CPU_FLAGS" ]; then
|
if [ -z "$CPU_FLAGS" ]; then
|
||||||
if [ -z "$CPU_FEATURES" ]; then
|
if [ -z "$CPU_FEATURES" ]; then
|
||||||
CPU_FLAGS="$CPU_MODEL"
|
CPU_FLAGS="$CPU_MODEL"
|
||||||
|
|||||||
49
src/reset.sh
49
src/reset.sh
@@ -17,8 +17,8 @@ echo "❯ For support visit $SUPPORT"
|
|||||||
: "${CONSOLE:="N"}" # Disable console mode
|
: "${CONSOLE:="N"}" # Disable console mode
|
||||||
: "${ALLOCATE:=""}" # Preallocate diskspace
|
: "${ALLOCATE:=""}" # Preallocate diskspace
|
||||||
: "${ARGUMENTS:=""}" # Extra QEMU parameters
|
: "${ARGUMENTS:=""}" # Extra QEMU parameters
|
||||||
: "${CPU_CORES:="1"}" # Amount of CPU cores
|
: "${CPU_CORES:="2"}" # Amount of CPU cores
|
||||||
: "${RAM_SIZE:="1G"}" # Maximum RAM amount
|
: "${RAM_SIZE:="2G"}" # Maximum RAM amount
|
||||||
: "${RAM_CHECK:="Y"}" # Check available RAM
|
: "${RAM_CHECK:="Y"}" # Check available RAM
|
||||||
: "${DISK_SIZE:="16G"}" # Initial data disk size
|
: "${DISK_SIZE:="16G"}" # Initial data disk size
|
||||||
: "${STORAGE:="/storage"}" # Storage folder location
|
: "${STORAGE:="/storage"}" # Storage folder location
|
||||||
@@ -48,8 +48,15 @@ else
|
|||||||
SOCKETS=$(lscpu | grep -m 1 -i 'socket(s)' | awk '{print $(2)}')
|
SOCKETS=$(lscpu | grep -m 1 -i 'socket(s)' | awk '{print $(2)}')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
CPU_CORES="${CPU_CORES// /}"
|
||||||
|
[[ "${CPU_CORES,,}" == "max" ]] && CPU_CORES="$CORES"
|
||||||
[ -n "${CPU_CORES//[0-9 ]}" ] && error "Invalid amount of CPU_CORES: $CPU_CORES" && exit 15
|
[ -n "${CPU_CORES//[0-9 ]}" ] && error "Invalid amount of CPU_CORES: $CPU_CORES" && exit 15
|
||||||
|
|
||||||
|
if [ "$CPU_CORES" -gt "$CORES" ]; then
|
||||||
|
warn "The amount for CPU_CORES (${CPU_CORES}) exceeds the amount of physical cores, so will be limited to ${CORES}."
|
||||||
|
CPU_CORES="$CORES"
|
||||||
|
fi
|
||||||
|
|
||||||
# Check system
|
# Check system
|
||||||
|
|
||||||
if [ ! -d "/dev/shm" ]; then
|
if [ ! -d "/dev/shm" ]; then
|
||||||
@@ -69,10 +76,14 @@ if [ ! -d "$STORAGE" ]; then
|
|||||||
error "Storage folder ($STORAGE) not found!" && exit 13
|
error "Storage folder ($STORAGE) not found!" && exit 13
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -w "$STORAGE" ]; then
|
||||||
|
error "Storage folder ($STORAGE) is not writeable!" && exit 13
|
||||||
|
fi
|
||||||
|
|
||||||
# Check filesystem
|
# Check filesystem
|
||||||
FS=$(stat -f -c %T "$STORAGE")
|
FS=$(stat -f -c %T "$STORAGE")
|
||||||
|
|
||||||
if [[ "${FS,,}" == "ecryptfs" ]] || [[ "${FS,,}" == "tmpfs" ]]; then
|
if [[ "${FS,,}" == "ecryptfs" || "${FS,,}" == "tmpfs" ]]; then
|
||||||
DISK_IO="threads"
|
DISK_IO="threads"
|
||||||
DISK_CACHE="writeback"
|
DISK_CACHE="writeback"
|
||||||
fi
|
fi
|
||||||
@@ -85,6 +96,12 @@ RAM_TOTAL=$(free -b | grep -m 1 Mem: | awk '{print $2}')
|
|||||||
RAM_SIZE="${RAM_SIZE// /}"
|
RAM_SIZE="${RAM_SIZE// /}"
|
||||||
[ -z "$RAM_SIZE" ] && error "RAM_SIZE not specified!" && exit 16
|
[ -z "$RAM_SIZE" ] && error "RAM_SIZE not specified!" && exit 16
|
||||||
|
|
||||||
|
if [[ "${RAM_SIZE,,}" == "max" ]]; then
|
||||||
|
RAM_WANTED=(( RAM_AVAIL - RAM_SPARE - RAM_SPARE))
|
||||||
|
RAM_WANTED=(( RAM_WANTED / 1073741825 ))
|
||||||
|
RAM_SIZE="${RAM_WANTED}G"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "${RAM_SIZE//[0-9. ]}" ]; then
|
if [ -z "${RAM_SIZE//[0-9. ]}" ]; then
|
||||||
[ "${RAM_SIZE%%.*}" -lt "130" ] && RAM_SIZE="${RAM_SIZE}G" || RAM_SIZE="${RAM_SIZE}M"
|
[ "${RAM_SIZE%%.*}" -lt "130" ] && RAM_SIZE="${RAM_SIZE}G" || RAM_SIZE="${RAM_SIZE}M"
|
||||||
fi
|
fi
|
||||||
@@ -156,6 +173,7 @@ setCountry() {
|
|||||||
[ -z "$COUNTRY" ] && getCountry "https://ifconfig.co/json" ".country_iso"
|
[ -z "$COUNTRY" ] && getCountry "https://ifconfig.co/json" ".country_iso"
|
||||||
[ -z "$COUNTRY" ] && getCountry "https://api.ip2location.io" ".country_code"
|
[ -z "$COUNTRY" ] && getCountry "https://api.ip2location.io" ".country_code"
|
||||||
[ -z "$COUNTRY" ] && getCountry "https://ipinfo.io/json" ".country"
|
[ -z "$COUNTRY" ] && getCountry "https://ipinfo.io/json" ".country"
|
||||||
|
[ -z "$COUNTRY" ] && getCountry "https://api.ipquery.io/?format=json" ".location.country_code"
|
||||||
[ -z "$COUNTRY" ] && getCountry "https://api.myip.com" ".cc"
|
[ -z "$COUNTRY" ] && getCountry "https://api.myip.com" ".cc"
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@@ -184,20 +202,25 @@ addPackage() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# shellcheck disable=SC2143
|
cp -r /var/www/* /run/shm
|
||||||
if [ -f /proc/net/if_inet6 ] && [ -n "$(ifconfig -a | grep inet6)" ]; then
|
html "Starting $APP for Docker..."
|
||||||
|
|
||||||
sed -i "s/listen 5000 default_server;/listen [::]:5000 default_server ipv6only=off;/g" /etc/nginx/sites-enabled/web.conf
|
if [[ "${WEB:-}" != [Nn]* ]]; then
|
||||||
|
|
||||||
|
# shellcheck disable=SC2143
|
||||||
|
if [ -f /proc/net/if_inet6 ] && [ -n "$(ifconfig -a | grep inet6)" ]; then
|
||||||
|
|
||||||
else
|
sed -i "s/listen 5000 default_server;/listen [::]:5000 default_server ipv6only=off;/g" /etc/nginx/sites-enabled/web.conf
|
||||||
|
|
||||||
sed -i "s/listen [::]:5000 default_server ipv6only=off;/listen 5000 default_server;/g" /etc/nginx/sites-enabled/web.conf
|
else
|
||||||
|
|
||||||
|
sed -i "s/listen [::]:5000 default_server ipv6only=off;/listen 5000 default_server;/g" /etc/nginx/sites-enabled/web.conf
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start webserver
|
||||||
|
nginx -e stderr
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Start webserver
|
|
||||||
cp -r /var/www/* /run/shm
|
|
||||||
html "Starting $APP for Docker..."
|
|
||||||
nginx -e stderr
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
33
src/utils.sh
33
src/utils.sh
@@ -113,41 +113,32 @@ cpu() {
|
|||||||
local cpu=""
|
local cpu=""
|
||||||
|
|
||||||
ret=$(lscpu)
|
ret=$(lscpu)
|
||||||
|
|
||||||
if grep -qi "model name" <<< "$ret"; then
|
if grep -qi "model name" <<< "$ret"; then
|
||||||
cpu=$(echo "$ret" | 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=$(echo "$ret" | 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')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${cpu// /}" ] && grep -qi "model:" <<< "$ret"; then
|
if [ -z "${cpu// /}" ] && grep -qi "model:" <<< "$ret"; then
|
||||||
cpu=$(echo "$ret" | 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')
|
cpu=$(echo "$ret" | 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
|
fi
|
||||||
|
|
||||||
cpu="${cpu// CPU/}"
|
cpu="${cpu// CPU/}"
|
||||||
cpu="${cpu// 4 Core/}"
|
cpu="${cpu// [0-9] Core}"
|
||||||
cpu="${cpu// 6 Core/}"
|
cpu="${cpu// [0-9][0-9] Core}"
|
||||||
cpu="${cpu// 8 Core/}"
|
cpu="${cpu// [0-9][0-9][0-9] Core}"
|
||||||
cpu="${cpu// 10 Core/}"
|
cpu="${cpu// [0-9]th Gen}"
|
||||||
cpu="${cpu// 12 Core/}"
|
cpu="${cpu// [0-9][0-9]th Gen}"
|
||||||
cpu="${cpu// 16 Core/}"
|
|
||||||
cpu="${cpu// 32 Core/}"
|
|
||||||
cpu="${cpu// 64 Core/}"
|
|
||||||
cpu="${cpu//7th Gen /}"
|
|
||||||
cpu="${cpu//8th Gen /}"
|
|
||||||
cpu="${cpu//9th Gen /}"
|
|
||||||
cpu="${cpu//10th Gen /}"
|
|
||||||
cpu="${cpu//11th Gen /}"
|
|
||||||
cpu="${cpu//12th Gen /}"
|
|
||||||
cpu="${cpu//13th Gen /}"
|
|
||||||
cpu="${cpu//14th Gen /}"
|
|
||||||
cpu="${cpu//15th Gen /}"
|
|
||||||
cpu="${cpu// Processor/}"
|
cpu="${cpu// Processor/}"
|
||||||
cpu="${cpu// Quad core/}"
|
cpu="${cpu// Quad core/}"
|
||||||
cpu="${cpu// Dual core/}"
|
cpu="${cpu// Dual core/}"
|
||||||
cpu="${cpu// Octa core/}"
|
cpu="${cpu// Octa core/}"
|
||||||
|
cpu="${cpu// Hexa core/}"
|
||||||
cpu="${cpu// Core TM/ Core}"
|
cpu="${cpu// Core TM/ Core}"
|
||||||
cpu="${cpu// with Radeon Graphics/}"
|
cpu="${cpu// with Radeon Graphics/}"
|
||||||
cpu="${cpu// with Radeon Vega Graphics/}"
|
cpu="${cpu// with Radeon Vega Graphics/}"
|
||||||
|
cpu="${cpu// with Radeon Vega Mobile Gfx/}"
|
||||||
|
cpu="${cpu// w Radeon [0-9][0-9][0-9]M Graphics/}"
|
||||||
|
|
||||||
[ -z "${cpu// /}" ] && cpu="Unknown"
|
[ -z "${cpu// /}" ] && cpu="Unknown"
|
||||||
|
|
||||||
echo "$cpu"
|
echo "$cpu"
|
||||||
|
|||||||
Reference in New Issue
Block a user