Update build.func
This commit is contained in:
parent
b68258ade2
commit
4b20355aed
146
misc/build.func
146
misc/build.func
@ -60,8 +60,6 @@ color() {
|
|||||||
CREATING="${TAB}🚀${TAB}${CL}"
|
CREATING="${TAB}🚀${TAB}${CL}"
|
||||||
ADVANCED="${TAB}🧩${TAB}${CL}"
|
ADVANCED="${TAB}🧩${TAB}${CL}"
|
||||||
FUSE="${TAB}🔧${TAB}${CL}"
|
FUSE="${TAB}🔧${TAB}${CL}"
|
||||||
|
|
||||||
#preflight_checks
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function enables error handling in the script by setting options and defining a trap for the ERR signal.
|
# This function enables error handling in the script by setting options and defining a trap for the ERR signal.
|
||||||
@ -87,72 +85,6 @@ error_handler() {
|
|||||||
echo -e "\n$error_message\n"
|
echo -e "\n$error_message\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
preflight_checks() {
|
|
||||||
local missing=0
|
|
||||||
local min_disk_mb=2048
|
|
||||||
local required_cmds=(curl wget awk grep sed df ip ping dig hostname pct)
|
|
||||||
|
|
||||||
printf "${SEARCH}${BOLD}${DGN}Performing Preflight Checks:${CL}\n"
|
|
||||||
|
|
||||||
for cmd in "${required_cmds[@]}"; do
|
|
||||||
if ! command -v "$cmd" >/dev/null 2>&1; then
|
|
||||||
printf "${CROSS}${RD}Missing required command: ${cmd}${CL}\n"
|
|
||||||
missing=1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
local disk_avail
|
|
||||||
disk_avail=$(df -Pm / | awk 'NR==2 {print $4}')
|
|
||||||
if [[ "$disk_avail" -lt "$min_disk_mb" ]]; then
|
|
||||||
printf "${CROSS}${RD}Disk space is below required threshold: ${disk_avail}MB < ${min_disk_mb}MB${CL}\n"
|
|
||||||
missing=1
|
|
||||||
else
|
|
||||||
printf "${DISKSIZE}${BOLD}${DGN}Free Disk Space: ${BGN}${disk_avail}MB${CL}\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! ping -c1 -W2 1.1.1.1 >/dev/null; then
|
|
||||||
printf "${CROSS}${RD}No Internet connectivity (1.1.1.1 unreachable)${CL}\n"
|
|
||||||
missing=1
|
|
||||||
else
|
|
||||||
printf "${CM}${GN}Internet Connectivity OK${CL}\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! dig +short google.com | grep -qE '^[0-9.]+'; then
|
|
||||||
printf "${CROSS}${RD}DNS resolution failed for google.com${CL}\n"
|
|
||||||
missing=1
|
|
||||||
else
|
|
||||||
printf "${CM}${GN}DNS Resolution OK${CL}\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! ip -4 a | grep -q 'inet '; then
|
|
||||||
printf "${CROSS}${RD}No IPv4 address detected${CL}\n"
|
|
||||||
missing=1
|
|
||||||
else
|
|
||||||
printf "${CM}${GN}IPv4 Detected${CL}\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ip -6 a | grep -q 'inet6' && [[ "$DISABLEIP6" != "yes" ]]; then
|
|
||||||
printf "${CM}${GN}IPv6 Detected${CL}\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! pct list &>/dev/null; then
|
|
||||||
printf "${CROSS}${RD}Proxmox container system not ready (pct not working)${CL}\n"
|
|
||||||
missing=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -s /etc/network/interfaces ]]; then
|
|
||||||
printf "${CROSS}${RD}Network config file missing or empty: /etc/network/interfaces${CL}\n"
|
|
||||||
missing=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$missing" -ne 0 ]]; then
|
|
||||||
printf "\n${CROSS}${RD}Preflight checks failed. Fix above errors and re-run the script.${CL}\n"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf "\n${CM}${GN}All preflight checks passed successfully.${CL}\n\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
# This function displays an informational message with logging support.
|
# This function displays an informational message with logging support.
|
||||||
declare -A MSG_INFO_SHOWN
|
declare -A MSG_INFO_SHOWN
|
||||||
SPINNER_ACTIVE=0
|
SPINNER_ACTIVE=0
|
||||||
@ -1489,24 +1421,30 @@ start() {
|
|||||||
|
|
||||||
# This function collects user settings and integrates all the collected information.
|
# This function collects user settings and integrates all the collected information.
|
||||||
build_container() {
|
build_container() {
|
||||||
if [[ "$CT_TYPE" == "1" ]]; then
|
# if [ "$VERB" == "yes" ]; then set -x; fi
|
||||||
|
|
||||||
|
if [ "$CT_TYPE" == "1" ]; then
|
||||||
FEATURES="keyctl=1,nesting=1"
|
FEATURES="keyctl=1,nesting=1"
|
||||||
else
|
else
|
||||||
FEATURES="nesting=1"
|
FEATURES="nesting=1"
|
||||||
fi
|
fi
|
||||||
|
# 26.03.2025 disabled
|
||||||
|
#if [ "$ENABLE_FUSE" == "yes" ]; then
|
||||||
|
# FEATURES+=",fuse=1"
|
||||||
|
#fi
|
||||||
|
|
||||||
[[ "$DIAGNOSTICS" == "yes" ]] && post_to_api
|
if [[ $DIAGNOSTICS == "yes" ]]; then
|
||||||
|
post_to_api
|
||||||
|
fi
|
||||||
|
|
||||||
FEATURES="${FEATURES#,}"
|
FEATURES="${FEATURES#,}"
|
||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
pushd "$TEMP_DIR" >/dev/null || return 1
|
pushd $TEMP_DIR >/dev/null
|
||||||
|
if [ "$var_os" == "alpine" ]; then
|
||||||
if [[ "$var_os" == "alpine" ]]; then
|
export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/alpine-install.func)"
|
||||||
export FUNCTIONS_FILE_PATH="$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/alpine-install.func)"
|
|
||||||
else
|
else
|
||||||
export FUNCTIONS_FILE_PATH="$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/install.func)"
|
export FUNCTIONS_FILE_PATH="$(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/install.func)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export RANDOM_UUID="$RANDOM_UUID"
|
export RANDOM_UUID="$RANDOM_UUID"
|
||||||
export CACHER="$APT_CACHER"
|
export CACHER="$APT_CACHER"
|
||||||
export CACHER_IP="$APT_CACHER_IP"
|
export CACHER_IP="$APT_CACHER_IP"
|
||||||
@ -1516,13 +1454,14 @@ build_container() {
|
|||||||
export app="$NSAPP"
|
export app="$NSAPP"
|
||||||
export PASSWORD="$PW"
|
export PASSWORD="$PW"
|
||||||
export VERBOSE="$VERB"
|
export VERBOSE="$VERB"
|
||||||
export SSH_ROOT="$SSH"
|
export SSH_ROOT="${SSH}"
|
||||||
export SSH_AUTHORIZED_KEY
|
export SSH_AUTHORIZED_KEY
|
||||||
export CTID="$CT_ID"
|
export CTID="$CT_ID"
|
||||||
export CTTYPE="$CT_TYPE"
|
export CTTYPE="$CT_TYPE"
|
||||||
export PCT_OSTYPE="$var_os"
|
export PCT_OSTYPE="$var_os"
|
||||||
export PCT_OSVERSION="$var_version"
|
export PCT_OSVERSION="$var_version"
|
||||||
export PCT_DISK_SIZE="$DISK_SIZE"
|
export PCT_DISK_SIZE="$DISK_SIZE"
|
||||||
|
#export IPv6="$IPv6"
|
||||||
export PCT_OPTIONS="
|
export PCT_OPTIONS="
|
||||||
-features $FEATURES
|
-features $FEATURES
|
||||||
-hostname $HN
|
-hostname $HN
|
||||||
@ -1537,12 +1476,12 @@ build_container() {
|
|||||||
$PW
|
$PW
|
||||||
"
|
"
|
||||||
|
|
||||||
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/ct/create_lxc.sh)" || return 1
|
# This executes create_lxc.sh and creates the container and .conf file
|
||||||
|
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/ct/create_lxc.sh)" || exit $?
|
||||||
|
|
||||||
local config="/etc/pve/lxc/${CTID}.conf"
|
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
|
||||||
|
if [ "$CT_TYPE" == "0" ]; then
|
||||||
append_usb_passthrough() {
|
cat <<EOF >>$LXC_CONFIG
|
||||||
cat <<EOF >>"$config"
|
|
||||||
# USB passthrough
|
# USB passthrough
|
||||||
lxc.cgroup2.devices.allow: a
|
lxc.cgroup2.devices.allow: a
|
||||||
lxc.cap.drop:
|
lxc.cap.drop:
|
||||||
@ -1554,10 +1493,11 @@ lxc.mount.entry: /dev/ttyUSB1 dev/ttyUSB1 none bind,optional,create=
|
|||||||
lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file
|
lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file
|
||||||
lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file
|
lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file
|
||||||
EOF
|
EOF
|
||||||
}
|
fi
|
||||||
|
|
||||||
append_vaapi_privileged() {
|
if [ "$CT_TYPE" == "0" ]; then
|
||||||
cat <<EOF >>"$config"
|
if [[ "$APP" == "Channels" || "$APP" == "Emby" || "$APP" == "ErsatzTV" || "$APP" == "Frigate" || "$APP" == "Jellyfin" || "$APP" == "Plex" || "$APP" == "Scrypted" || "$APP" == "Tdarr" || "$APP" == "Unmanic" || "$APP" == "Ollama" || "$APP" == "FileFlows" ]]; then
|
||||||
|
cat <<EOF >>$LXC_CONFIG
|
||||||
# VAAPI hardware transcoding
|
# VAAPI hardware transcoding
|
||||||
lxc.cgroup2.devices.allow: c 226:0 rwm
|
lxc.cgroup2.devices.allow: c 226:0 rwm
|
||||||
lxc.cgroup2.devices.allow: c 226:128 rwm
|
lxc.cgroup2.devices.allow: c 226:128 rwm
|
||||||
@ -1566,34 +1506,32 @@ lxc.mount.entry: /dev/fb0 dev/fb0 none bind,optional,create=file
|
|||||||
lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir
|
lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir
|
||||||
lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file
|
lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file
|
||||||
EOF
|
EOF
|
||||||
}
|
fi
|
||||||
|
else
|
||||||
append_vaapi_unprivileged() {
|
if [[ "$APP" == "Channels" || "$APP" == "Emby" || "$APP" == "ErsatzTV" || "$APP" == "Frigate" || "$APP" == "Jellyfin" || "$APP" == "Plex" || "$APP" == "Scrypted" || "$APP" == "Tdarr" || "$APP" == "Unmanic" || "$APP" == "Ollama" || "$APP" == "FileFlows" ]]; then
|
||||||
if [[ -e "/dev/dri/renderD128" ]]; then
|
if [[ -e "/dev/dri/renderD128" ]]; then
|
||||||
if [[ -e "/dev/dri/card0" ]]; then
|
if [[ -e "/dev/dri/card0" ]]; then
|
||||||
printf "dev0: /dev/dri/card0,gid=44\ndev1: /dev/dri/renderD128,gid=104\n" >>"$config"
|
cat <<EOF >>$LXC_CONFIG
|
||||||
|
# VAAPI hardware transcoding
|
||||||
|
dev0: /dev/dri/card0,gid=44
|
||||||
|
dev1: /dev/dri/renderD128,gid=104
|
||||||
|
EOF
|
||||||
else
|
else
|
||||||
printf "dev0: /dev/dri/card1,gid=44\ndev1: /dev/dri/renderD128,gid=104\n" >>"$config"
|
cat <<EOF >>$LXC_CONFIG
|
||||||
|
# VAAPI hardware transcoding
|
||||||
|
dev0: /dev/dri/card1,gid=44
|
||||||
|
dev1: /dev/dri/renderD128,gid=104
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
is_hw_transcoding_app() {
|
|
||||||
[[ "$APP" =~ ^(Channels|Emby|ErsatzTV|Frigate|Jellyfin|Plex|Scrypted|Tdarr|Unmanic|Ollama|FileFlows)$ ]]
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ "$CT_TYPE" == "0" ]]; then
|
|
||||||
append_usb_passthrough
|
|
||||||
is_hw_transcoding_app && append_vaapi_privileged
|
|
||||||
else
|
|
||||||
is_hw_transcoding_app && append_vaapi_unprivileged
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# This starts the container and executes <app>-install.sh
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start "$CTID"
|
pct start "$CTID"
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
|
if [ "$var_os" == "alpine" ]; then
|
||||||
if [[ "$var_os" == "alpine" ]]; then
|
|
||||||
sleep 3
|
sleep 3
|
||||||
pct exec "$CTID" -- /bin/sh -c 'cat <<EOF >/etc/apk/repositories
|
pct exec "$CTID" -- /bin/sh -c 'cat <<EOF >/etc/apk/repositories
|
||||||
http://dl-cdn.alpinelinux.org/alpine/latest-stable/main
|
http://dl-cdn.alpinelinux.org/alpine/latest-stable/main
|
||||||
@ -1601,8 +1539,8 @@ http://dl-cdn.alpinelinux.org/alpine/latest-stable/community
|
|||||||
EOF'
|
EOF'
|
||||||
pct exec "$CTID" -- ash -c "apk add bash >/dev/null"
|
pct exec "$CTID" -- ash -c "apk add bash >/dev/null"
|
||||||
fi
|
fi
|
||||||
|
lxc-attach -n "$CTID" -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/$var_install.sh)" || exit $?
|
||||||
|
|
||||||
lxc-attach -n "$CTID" -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/$var_install.sh)" || return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function sets the description of the container.
|
# This function sets the description of the container.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user