mirror of
https://github.com/kuhyx/scripts.git
synced 2026-07-04 15:03:09 +02:00
fix: resolve all shellcheck errors
- Replace 'A && B || C' patterns with proper if-then-else statements (SC2015) - Add check_for_virtualbox function to invoke prompt_for_virtualbox_challenge (SC2317) - Fix install_launcher function to escape variable in heredoc (SC2119/SC2120) - Apply shfmt formatting to ensure consistent style Fixes 7 SC2015 violations, 1 SC2317 violation, and 1 SC2119/SC2120 pair. All 79 shell files now pass shellcheck without errors.
This commit is contained in:
parent
8e0a720499
commit
03bd36e41d
@ -26,7 +26,7 @@ AMD_ENABLE_SI_CIK=${AMD_ENABLE_SI_CIK:-auto}
|
|||||||
AMD_SKIP_INITRAMFS=${AMD_SKIP_INITRAMFS:-0}
|
AMD_SKIP_INITRAMFS=${AMD_SKIP_INITRAMFS:-0}
|
||||||
AMD_VERBOSE=${AMD_VERBOSE:-0}
|
AMD_VERBOSE=${AMD_VERBOSE:-0}
|
||||||
|
|
||||||
vlog() { [ "$AMD_VERBOSE" = 1 ] && echo "[amd] $*" || true; }
|
vlog() { if [ "$AMD_VERBOSE" = 1 ]; then echo "[amd] $*"; fi; }
|
||||||
info() { echo "[amd] $*"; }
|
info() { echo "[amd] $*"; }
|
||||||
warn() { echo "[amd][warn] $*" >&2; }
|
warn() { echo "[amd][warn] $*" >&2; }
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ INTEL_ENABLE_GUC=${INTEL_ENABLE_GUC:-}
|
|||||||
INTEL_SKIP_INITRAMFS=${INTEL_SKIP_INITRAMFS:-0}
|
INTEL_SKIP_INITRAMFS=${INTEL_SKIP_INITRAMFS:-0}
|
||||||
INTEL_VERBOSE=${INTEL_VERBOSE:-1}
|
INTEL_VERBOSE=${INTEL_VERBOSE:-1}
|
||||||
|
|
||||||
vlog() { [ "$INTEL_VERBOSE" = 1 ] && echo "[intel] $*" || true; }
|
vlog() { if [ "$INTEL_VERBOSE" = 1 ]; then echo "[intel] $*"; fi; }
|
||||||
info() { echo "[intel] $*"; }
|
info() { echo "[intel] $*"; }
|
||||||
warn() { echo "[intel][warn] $*" >&2; }
|
warn() { echo "[intel][warn] $*" >&2; }
|
||||||
|
|
||||||
|
|||||||
@ -45,8 +45,12 @@ cleanup_mount_stacks() {
|
|||||||
# Drop protective attributes if present
|
# Drop protective attributes if present
|
||||||
if command -v lsattr >/dev/null 2>&1; then
|
if command -v lsattr >/dev/null 2>&1; then
|
||||||
attrs=$(lsattr -d "$TARGET" 2>/dev/null || true)
|
attrs=$(lsattr -d "$TARGET" 2>/dev/null || true)
|
||||||
echo "$attrs" | grep -q " i " && chattr -i "$TARGET" > /dev/null 2>&1 || true
|
if echo "$attrs" | grep -q " i "; then
|
||||||
echo "$attrs" | grep -q " a " && chattr -a "$TARGET" > /dev/null 2>&1 || true
|
chattr -i "$TARGET" >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
if echo "$attrs" | grep -q " a "; then
|
||||||
|
chattr -a "$TARGET" >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
stop_units_if_present
|
stop_units_if_present
|
||||||
|
|||||||
@ -536,8 +536,30 @@ function prompt_for_steam_challenge() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function check_for_virtualbox() {
|
||||||
|
# List of VirtualBox-related packages
|
||||||
|
local vbox_packages=("virtualbox" "virtualbox-host-modules-arch" "virtualbox-guest-iso" "virtualbox-ext-oracle")
|
||||||
|
|
||||||
|
# Check if the command is an installation command
|
||||||
|
if [[ $1 == "-S" || $1 == "-Sy" || $1 == "-Syu" || $1 == "-Syyu" || $1 == "-U" ]]; then
|
||||||
|
# Check all arguments
|
||||||
|
for arg in "$@"; do
|
||||||
|
# Strip repository prefix if present
|
||||||
|
local package_name="${arg##*/}"
|
||||||
|
|
||||||
|
# Check if argument matches any VirtualBox package
|
||||||
|
for package in "${vbox_packages[@]}"; do
|
||||||
|
if [[ $arg == "$package" || $arg == *"/$package-"* || $arg == *"/$package/"* ||
|
||||||
|
$arg == *"/$package" || $package_name == "$package" ]]; then
|
||||||
|
return 0 # VirtualBox package found
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
return 1 # No VirtualBox package found
|
||||||
|
}
|
||||||
|
|
||||||
# Function to prompt for solving a word unscrambling challenge (for virtualbox - always active)
|
# Function to prompt for solving a word unscrambling challenge (for virtualbox - always active)
|
||||||
# shellcheck disable=SC2329 # Invoked dynamically when matching VirtualBox packages
|
|
||||||
function prompt_for_virtualbox_challenge() {
|
function prompt_for_virtualbox_challenge() {
|
||||||
echo -e "${YELLOW}WARNING: You are trying to install VirtualBox.${NC}"
|
echo -e "${YELLOW}WARNING: You are trying to install VirtualBox.${NC}"
|
||||||
echo -e "${YELLOW}VirtualBox challenge will begin shortly...${NC}"
|
echo -e "${YELLOW}VirtualBox challenge will begin shortly...${NC}"
|
||||||
@ -681,6 +703,13 @@ if check_for_steam "$@"; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check for VirtualBox (challenge-eligible package)
|
||||||
|
if check_for_virtualbox "$@"; then
|
||||||
|
if ! prompt_for_virtualbox_challenge; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Display operation
|
# Display operation
|
||||||
display_operation "$1"
|
display_operation "$1"
|
||||||
|
|
||||||
|
|||||||
@ -176,7 +176,7 @@ install_launcher() {
|
|||||||
cat >"$launcher" <<EOF
|
cat >"$launcher" <<EOF
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
exec uv --directory "$python_dir" run unreal_mcp_server.py "${1:-}" < /dev/null
|
exec uv --directory "$python_dir" run unreal_mcp_server.py "\${1:-}" < /dev/null
|
||||||
EOF
|
EOF
|
||||||
chmod +x "$launcher"
|
chmod +x "$launcher"
|
||||||
if [[ $EUID -eq 0 ]]; then chown "$ACTUAL_USER:$ACTUAL_USER" "$launcher"; fi
|
if [[ $EUID -eq 0 ]]; then chown "$ACTUAL_USER:$ACTUAL_USER" "$launcher"; fi
|
||||||
|
|||||||
@ -476,7 +476,9 @@ main() {
|
|||||||
else
|
else
|
||||||
echo "API key authentication DISABLED (public instance)."
|
echo "API key authentication DISABLED (public instance)."
|
||||||
fi
|
fi
|
||||||
[[ -n ${PRELOAD_LANGS} ]] && echo "Preloaded languages requested: ${PRELOAD_LANGS}" || true
|
if [[ -n ${PRELOAD_LANGS} ]]; then
|
||||||
|
echo "Preloaded languages requested: ${PRELOAD_LANGS}"
|
||||||
|
fi
|
||||||
echo "Environment file: ${ENV_FILE}"
|
echo "Environment file: ${ENV_FILE}"
|
||||||
echo "Manage: docker logs -f ${SERVICE_NAME} | docker stop ${SERVICE_NAME}"
|
echo "Manage: docker logs -f ${SERVICE_NAME} | docker stop ${SERVICE_NAME}"
|
||||||
echo "Uninstall: sudo ${SCRIPT_NAME} --uninstall"
|
echo "Uninstall: sudo ${SCRIPT_NAME} --uninstall"
|
||||||
|
|||||||
@ -66,7 +66,9 @@ has_libcublas12() {
|
|||||||
/usr/local/cuda-12*/lib64 \
|
/usr/local/cuda-12*/lib64 \
|
||||||
/opt/cuda/lib64 \
|
/opt/cuda/lib64 \
|
||||||
/opt/cuda/targets/x86_64-linux/lib; do
|
/opt/cuda/targets/x86_64-linux/lib; do
|
||||||
[[ -e "$d/libcublas.so.12" ]] && return 0 || true
|
if [[ -e "$d/libcublas.so.12" ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
# venv-provided NVIDIA CUDA libs
|
# venv-provided NVIDIA CUDA libs
|
||||||
if [[ -x "$VENV_DIR/bin/python" ]]; then
|
if [[ -x "$VENV_DIR/bin/python" ]]; then
|
||||||
@ -76,7 +78,9 @@ has_libcublas12() {
|
|||||||
for d in "$VENV_DIR/lib/python$pyver/site-packages/nvidia/cublas/lib" \
|
for d in "$VENV_DIR/lib/python$pyver/site-packages/nvidia/cublas/lib" \
|
||||||
"$VENV_DIR/lib/python$pyver/site-packages/nvidia/cudnn/lib" \
|
"$VENV_DIR/lib/python$pyver/site-packages/nvidia/cudnn/lib" \
|
||||||
"$VENV_DIR/lib/python$pyver/site-packages/nvidia/cuda_runtime/lib"; do
|
"$VENV_DIR/lib/python$pyver/site-packages/nvidia/cuda_runtime/lib"; do
|
||||||
[[ -e "$d/libcublas.so.12" ]] && return 0 || true
|
if [[ -e "$d/libcublas.so.12" ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user