mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-11-06 18:13:43 +08:00
Compare commits
6 Commits
v7.40
...
b694d6faf8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b694d6faf8 | ||
|
|
7acd1f6cdb | ||
|
|
09ca3bf118 | ||
|
|
6cac45c397 | ||
|
|
f18663d840 | ||
|
|
fefe1af9e6 |
2
.github/workflows/hub.yml
vendored
2
.github/workflows/hub.yml
vendored
@@ -15,7 +15,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
-
|
-
|
||||||
name: Docker Hub Description
|
name: Docker Hub Description
|
||||||
uses: peter-evans/dockerhub-description@v4
|
uses: peter-evans/dockerhub-description@v5
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|||||||
@@ -509,9 +509,6 @@ addDevice () {
|
|||||||
if [ -n "$physical" ]; then
|
if [ -n "$physical" ]; then
|
||||||
if [[ "$physical" != "512" ]]; then
|
if [[ "$physical" != "512" ]]; then
|
||||||
sectors=",logical_block_size=$logical,physical_block_size=$physical"
|
sectors=",logical_block_size=$logical,physical_block_size=$physical"
|
||||||
if [[ "$physical" != "4096" && "$physical" != "32768" ]]; then
|
|
||||||
warn "Unknown physical sector size: $physical for $DISK_DEV"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
warn "Failed to determine the sector size for $DISK_DEV"
|
warn "Failed to determine the sector size for $DISK_DEV"
|
||||||
@@ -522,7 +519,9 @@ addDevice () {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
html "Initializing disks..."
|
msg="Initializing disks..."
|
||||||
|
html "$msg"
|
||||||
|
[[ "$DEBUG" == [Yy1]* ]] && echo "$msg"
|
||||||
|
|
||||||
[ -z "${DISK_OPTS:-}" ] && DISK_OPTS=""
|
[ -z "${DISK_OPTS:-}" ] && DISK_OPTS=""
|
||||||
[ -z "${DISK_TYPE:-}" ] && DISK_TYPE="scsi"
|
[ -z "${DISK_TYPE:-}" ] && DISK_TYPE="scsi"
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ if [[ "$GPU" != [Yy1]* || "$CPU_VENDOR" != "GenuineIntel" || "$ARCH" != "amd64"
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
msg="Configuring display drivers..."
|
||||||
|
html "$msg"
|
||||||
|
[[ "$DEBUG" == [Yy1]* ]] && echo "$msg"
|
||||||
|
|
||||||
DISPLAY_OPTS="-display egl-headless,rendernode=$RENDERNODE"
|
DISPLAY_OPTS="-display egl-headless,rendernode=$RENDERNODE"
|
||||||
DISPLAY_OPTS+=" -vga $VGA"
|
DISPLAY_OPTS+=" -vga $VGA"
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ set -Eeuo pipefail
|
|||||||
|
|
||||||
cd /run
|
cd /run
|
||||||
|
|
||||||
|
. start.sh # Placeholder
|
||||||
. utils.sh # Load functions
|
. utils.sh # Load functions
|
||||||
. reset.sh # Initialize system
|
. reset.sh # Initialize system
|
||||||
. install.sh # Run installation
|
. install.sh # Run installation
|
||||||
|
|||||||
@@ -31,8 +31,9 @@ if [ -n "$URL" ] && [ ! -s "$FILE" ] && [ ! -d "$DIR" ]; then
|
|||||||
BASE=$(basename "$URL" .pat)
|
BASE=$(basename "$URL" .pat)
|
||||||
if [ ! -s "$STORAGE/$BASE.system.img" ]; then
|
if [ ! -s "$STORAGE/$BASE.system.img" ]; then
|
||||||
BASE=$(basename "${URL%%\?*}" .pat)
|
BASE=$(basename "${URL%%\?*}" .pat)
|
||||||
: "${BASE//+/ }"; printf -v BASE '%b' "${_//%/\\x}"
|
BASE="${BASE//+/ }"
|
||||||
BASE=$(echo "$BASE" | sed -e 's/[^A-Za-z0-9._-]/_/g')
|
printf -v BASE '%b' "${BASE//%/\\x}"
|
||||||
|
BASE="${BASE//[!A-Za-z0-9._-]/_}"
|
||||||
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
|
||||||
@@ -65,8 +66,9 @@ fi
|
|||||||
|
|
||||||
if [ ! -s "$FILE" ]; then
|
if [ ! -s "$FILE" ]; then
|
||||||
BASE=$(basename "${URL%%\?*}" .pat)
|
BASE=$(basename "${URL%%\?*}" .pat)
|
||||||
: "${BASE//+/ }"; printf -v BASE '%b' "${_//%/\\x}"
|
BASE="${BASE//+/ }"
|
||||||
BASE=$(echo "$BASE" | sed -e 's/[^A-Za-z0-9._-]/_/g')
|
printf -v BASE '%b' "${BASE//%/\\x}"
|
||||||
|
BASE="${BASE//[!A-Za-z0-9._-]/_}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$URL" != "file://$STORAGE/$BASE.pat" ]]; then
|
if [[ "$URL" != "file://$STORAGE/$BASE.pat" ]]; then
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ ADD_ERR="Please add the following setting to your container:"
|
|||||||
|
|
||||||
configureDHCP() {
|
configureDHCP() {
|
||||||
|
|
||||||
|
[[ "$DEBUG" == [Yy1]* ]] && echo "Configuring MACVTAP networking..."
|
||||||
|
|
||||||
# Create the necessary file structure for /dev/vhost-net
|
# Create the necessary file structure for /dev/vhost-net
|
||||||
if [ ! -c /dev/vhost-net ]; then
|
if [ ! -c /dev/vhost-net ]; then
|
||||||
if mknod /dev/vhost-net c 10 238; then
|
if mknod /dev/vhost-net c 10 238; then
|
||||||
@@ -105,6 +107,9 @@ configureDHCP() {
|
|||||||
|
|
||||||
configureDNS() {
|
configureDNS() {
|
||||||
|
|
||||||
|
local log="/var/log/dnsmasq.log"
|
||||||
|
rm -f "$log"
|
||||||
|
|
||||||
# Create lease file for faster resolve
|
# Create lease file for faster resolve
|
||||||
echo "0 $VM_NET_MAC $VM_NET_IP $VM_NET_HOST 01:$VM_NET_MAC" > /var/lib/misc/dnsmasq.leases
|
echo "0 $VM_NET_MAC $VM_NET_IP $VM_NET_HOST 01:$VM_NET_MAC" > /var/lib/misc/dnsmasq.leases
|
||||||
chmod 644 /var/lib/misc/dnsmasq.leases
|
chmod 644 /var/lib/misc/dnsmasq.leases
|
||||||
@@ -123,17 +128,21 @@ configureDNS() {
|
|||||||
|
|
||||||
# Add DNS entry for container
|
# Add DNS entry for container
|
||||||
DNSMASQ_OPTS+=" --address=/host.lan/${VM_NET_IP%.*}.1"
|
DNSMASQ_OPTS+=" --address=/host.lan/${VM_NET_IP%.*}.1"
|
||||||
|
DNSMASQ_OPTS+=" --log-facility=$log"
|
||||||
|
|
||||||
DNSMASQ_OPTS=$(echo "$DNSMASQ_OPTS" | sed 's/\t/ /g' | tr -s ' ' | sed 's/^ *//')
|
DNSMASQ_OPTS=$(echo "$DNSMASQ_OPTS" | sed 's/\t/ /g' | tr -s ' ' | sed 's/^ *//')
|
||||||
|
|
||||||
if [[ "${DEBUG_DNS:-}" == [Yy1]* ]]; then
|
[[ "$DEBUG" == [Yy1]* ]] && echo "Starting Dnsmasq daemon..."
|
||||||
DNSMASQ_OPTS+=" -d"
|
|
||||||
$DNSMASQ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS} &
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! $DNSMASQ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS}; then
|
if ! $DNSMASQ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS}; then
|
||||||
error "Failed to start dnsmasq, reason: $?" && return 1
|
local msg="Failed to start Dnsmasq, reason: $?"
|
||||||
|
[ -f "$log" ] && cat "$log"
|
||||||
|
error "$msg"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${DEBUG_DNS:-}" == [Yy1]* ]]; then
|
||||||
|
tail -fn +0 "$log" &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@@ -188,6 +197,8 @@ getHostPorts() {
|
|||||||
|
|
||||||
configureUser() {
|
configureUser() {
|
||||||
|
|
||||||
|
[[ "$DEBUG" == [Yy1]* ]] && echo "Configuring SLIRP networking..."
|
||||||
|
|
||||||
if [ -z "$IP6" ]; then
|
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"
|
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
|
else
|
||||||
@@ -206,6 +217,8 @@ configureNAT() {
|
|||||||
local tuntap="TUN device is missing. $ADD_ERR --device /dev/net/tun"
|
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"
|
local tables="The 'ip_tables' kernel module is not loaded. Try this command: sudo modprobe ip_tables iptable_nat"
|
||||||
|
|
||||||
|
[[ "$DEBUG" == [Yy1]* ]] && echo "Configuring NAT networking..."
|
||||||
|
|
||||||
# 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
|
[[ "$PODMAN" == [Yy1]* ]] && return 1
|
||||||
@@ -393,11 +406,30 @@ getInfo() {
|
|||||||
error "$ADD_ERR -e \"VM_NET_DEV=NAME\" to specify another interface name." && exit 26
|
error "$ADD_ERR -e \"VM_NET_DEV=NAME\" to specify another interface name." && exit 26
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NIC=$(ethtool -i "$VM_NET_DEV" | grep -m 1 -i 'driver:' | awk '{print $(2)}')
|
local result nic bus
|
||||||
|
result=$(ethtool -i "$VM_NET_DEV")
|
||||||
|
nic=$(grep -m 1 -i 'driver:' <<< "$result" | awk '{print $(2)}')
|
||||||
|
bus=$(grep -m 1 -i 'bus-info:' <<< "$result" | awk '{print $(2)}')
|
||||||
|
|
||||||
|
if [[ "${bus,,}" != "" && "${bus,,}" != "n/a" ]]; then
|
||||||
|
[[ "$DEBUG" == [Yy1]* ]] && info "Detected BUS: $bus"
|
||||||
|
error "This container does not support host mode networking!"
|
||||||
|
exit 29
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$DHCP" == [Yy1]* ]]; then
|
||||||
|
|
||||||
|
if [[ "${nic,,}" == "ipvlan" ]]; then
|
||||||
|
error "This container does not support IPVLAN networking when DHCP=Y."
|
||||||
|
exit 29
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${nic,,}" != "macvlan" ]]; then
|
||||||
|
[[ "$DEBUG" == [Yy1]* ]] && info "Detected NIC: $nic"
|
||||||
|
error "The container needs to be in a MACVLAN network when DHCP=Y."
|
||||||
|
exit 29
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "${NIC,,}" != "veth" && "${NIC,,}" != "macvlan" ]]; then
|
|
||||||
[[ "$DEBUG" == [Yy1]* ]] && info "Detected NIC: $NIC"
|
|
||||||
error "This container does not support host mode networking!" && exit 29
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
BASE_IP="${VM_NET_IP%.*}."
|
BASE_IP="${VM_NET_IP%.*}."
|
||||||
@@ -468,6 +500,8 @@ if [[ "$NETWORK" == [Nn]* ]]; then
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
[[ "$DEBUG" == [Yy1]* ]] && echo "Retrieving network information..."
|
||||||
|
|
||||||
getInfo
|
getInfo
|
||||||
html "Initializing network..."
|
html "Initializing network..."
|
||||||
|
|
||||||
@@ -487,6 +521,9 @@ 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!"
|
warn "your container IP starts with 172.17.* which will cause conflicts when you install the Container Manager package inside DSM!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Clean up old files
|
||||||
|
rm -f /var/run/dnsmasq.pid
|
||||||
|
|
||||||
if [[ -d "/sys/class/net/$VM_NET_TAP" ]]; then
|
if [[ -d "/sys/class/net/$VM_NET_TAP" ]]; then
|
||||||
info "Lingering interface will be removed..."
|
info "Lingering interface will be removed..."
|
||||||
ip link delete "$VM_NET_TAP" || true
|
ip link delete "$VM_NET_TAP" || true
|
||||||
@@ -496,10 +533,6 @@ if [[ "$DHCP" == [Yy1]* ]]; then
|
|||||||
|
|
||||||
checkOS
|
checkOS
|
||||||
|
|
||||||
if [[ "$IP" == "172."* ]]; then
|
|
||||||
warn "container IP starts with 172.* which is often a sign that you are not on a macvlan network (required for DHCP)!"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Configure for macvtap interface
|
# Configure for macvtap interface
|
||||||
configureDHCP || exit 20
|
configureDHCP || exit 20
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
trap 'error "Status $? while: $BASH_COMMAND (line $LINENO/$BASH_LINENO)"' ERR
|
trap 'error "Status $? while: $BASH_COMMAND (line $LINENO/$BASH_LINENO)"' ERR
|
||||||
|
[[ "${TRACE:-}" == [Yy1]* ]] && set -o functrace && trap 'echo "# $BASH_COMMAND" >&2' DEBUG
|
||||||
|
|
||||||
[ ! -f "/run/entry.sh" ] && error "Script must run inside Docker container!" && exit 11
|
[ ! -f "/run/entry.sh" ] && error "Script must run inside Docker container!" && exit 11
|
||||||
[ "$(id -u)" -ne "0" ] && error "Script must be executed with root privileges." && exit 12
|
[ "$(id -u)" -ne "0" ] && error "Script must be executed with root privileges." && exit 12
|
||||||
|
|||||||
4
src/start.sh
Normal file
4
src/start.sh
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
# Override this placeholder file using a Docker bind to execute a script during startup!
|
||||||
@@ -126,8 +126,8 @@ cpu() {
|
|||||||
cpu="${cpu// [0-9] Core}"
|
cpu="${cpu// [0-9] Core}"
|
||||||
cpu="${cpu// [0-9][0-9] Core}"
|
cpu="${cpu// [0-9][0-9] Core}"
|
||||||
cpu="${cpu// [0-9][0-9][0-9] Core}"
|
cpu="${cpu// [0-9][0-9][0-9] Core}"
|
||||||
cpu="${cpu// [0-9]th Gen}"
|
cpu="${cpu//[0-9]th Gen }"
|
||||||
cpu="${cpu// [0-9][0-9]th Gen}"
|
cpu="${cpu//[0-9][0-9]th Gen }"
|
||||||
cpu="${cpu// Processor/}"
|
cpu="${cpu// Processor/}"
|
||||||
cpu="${cpu// Quad core/}"
|
cpu="${cpu// Quad core/}"
|
||||||
cpu="${cpu// Dual core/}"
|
cpu="${cpu// Dual core/}"
|
||||||
|
|||||||
Reference in New Issue
Block a user