Compare commits

..

7 Commits

Author SHA1 Message Date
CanbiZ
bccfc2eb33 Refine comment on setting default Rust toolchain
Removed redundant comment about fixing old installations.
2025-11-13 09:57:07 +01:00
CanbiZ
88e189b5e2 Update tools.func 2025-11-13 09:55:58 +01:00
CanbiZ
8b0ef892e6 tools.func: improve Rust setup and crate installation logic
Enhances the setup_rust function to better handle Rust toolchain installation, updates, and verification. Improves global crate installation by handling upgrades, version checks, and error reporting, and adds more informative messaging throughout the process.
2025-11-13 09:54:30 +01:00
community-scripts-pr-app[bot]
4c717c3330 Update CHANGELOG.md (#9119)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-11-13 08:44:23 +00:00
Maximilian Bosche
9eb6a844c0 possible fix for #9109 (#9110) 2025-11-13 09:43:55 +01:00
community-scripts-pr-app[bot]
bec36e8247 Update CHANGELOG.md (#9118)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-11-13 08:35:51 +00:00
CanbiZ
c5a40499c9 Downgrade Swizzin to Debian 12 Bookworm (#9116) 2025-11-13 09:35:20 +01:00
5 changed files with 91 additions and 22 deletions

View File

@@ -12,6 +12,16 @@ Exercise vigilance regarding copycat or coat-tailing sites that seek to exploit
## 2025-11-13
### 🚀 Updated Scripts
- #### 🐞 Bug Fixes
- tools.func: fix wrong output for setup_java (error token is "0") [@snow2k9](https://github.com/snow2k9) ([#9110](https://github.com/community-scripts/ProxmoxVE/pull/9110))
- #### 💥 Breaking Changes
- Downgrade Swizzin to Debian 12 Bookworm [@MickLesk](https://github.com/MickLesk) ([#9116](https://github.com/community-scripts/ProxmoxVE/pull/9116))
## 2025-11-12
### 🆕 New Scripts

View File

@@ -11,7 +11,7 @@ var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-4096}"
var_disk="${var_disk:-20}"
var_os="${var_os:-debian}"
var_version="${var_version:-13}"
var_version="${var_version:-12}"
var_unprivileged="${var_unprivileged:-1}"
header_info "$APP"

View File

@@ -23,7 +23,7 @@
"ram": 4096,
"hdd": 20,
"os": "Debian",
"version": "13"
"version": "12"
}
}
],

View File

@@ -27,9 +27,4 @@ bash <(curl -sL s5n.sh)
motd_ssh
customize
msg_info "Cleaning up"
$STD apt -y autoremove
$STD apt -y autoclean
$STD apt -y clean
msg_ok "Cleaned"
cleanup_lxc

View File

@@ -2788,7 +2788,7 @@ function setup_java() {
# Validate INSTALLED_VERSION is not empty if matched
local JDK_COUNT=0
JDK_COUNT=$(dpkg -l 2>/dev/null | grep -c "temurin-.*-jdk" || echo "0")
JDK_COUNT=$(dpkg -l 2>/dev/null | grep -c "temurin-.*-jdk")
if [[ -z "$INSTALLED_VERSION" && "${JDK_COUNT:-0}" -gt 0 ]]; then
msg_warn "Found Temurin JDK but cannot determine version"
INSTALLED_VERSION="0"
@@ -4341,31 +4341,63 @@ function setup_rust() {
}
export PATH="$CARGO_BIN:$PATH"
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >>"$HOME/.profile"
# Verify installation
if ! command -v rustc >/dev/null 2>&1; then
msg_error "Rust binary not found after installation"
return 1
fi
local RUST_VERSION=$(rustc --version 2>/dev/null | awk '{print $2}')
if [[ -z "$RUST_VERSION" ]]; then
msg_error "Failed to determine Rust version"
return 1
fi
cache_installed_version "rust" "$RUST_VERSION"
msg_ok "Setup Rust $RUST_VERSION"
else
# Scenario 2: Rustup already installed - update/maintain
msg_info "Update Rust ($RUST_TOOLCHAIN)"
$STD rustup install "$RUST_TOOLCHAIN" || {
msg_error "Failed to install Rust toolchain $RUST_TOOLCHAIN"
return 1
}
$STD rustup default "$RUST_TOOLCHAIN" || {
msg_error "Failed to set default Rust toolchain"
return 1
# Ensure default toolchain is set
$STD rustup default "$RUST_TOOLCHAIN" 2>/dev/null || {
# If default fails, install the toolchain first
$STD rustup install "$RUST_TOOLCHAIN" || {
msg_error "Failed to install Rust toolchain $RUST_TOOLCHAIN"
return 1
}
$STD rustup default "$RUST_TOOLCHAIN" || {
msg_error "Failed to set default Rust toolchain"
return 1
}
}
# Update to latest patch version
$STD rustup update "$RUST_TOOLCHAIN" || true
# Ensure PATH is updated for current shell session
export PATH="$CARGO_BIN:$PATH"
local RUST_VERSION=$(rustc --version 2>/dev/null | awk '{print $2}')
if [[ -z "$RUST_VERSION" ]]; then
msg_error "Failed to determine Rust version after update"
return 1
fi
cache_installed_version "rust" "$RUST_VERSION"
msg_ok "Update Rust $RUST_VERSION"
fi
# Install global crates
if [[ -n "$RUST_CRATES" ]]; then
msg_info "Processing Rust crates: $RUST_CRATES"
IFS=',' read -ra CRATES <<<"$RUST_CRATES"
for crate in "${CRATES[@]}"; do
local NAME VER INSTALLED_VER
crate=$(echo "$crate" | xargs) # trim whitespace
[[ -z "$crate" ]] && continue # skip empty entries
local NAME VER INSTALLED_VER CRATE_LIST
if [[ "$crate" == *"@"* ]]; then
NAME="${crate%@*}"
VER="${crate##*@}"
@@ -4374,18 +4406,50 @@ function setup_rust() {
VER=""
fi
INSTALLED_VER=$(cargo install --list 2>/dev/null | awk "/^$NAME v[0-9]/ {print \$2}" | tr -d 'v')
# Get list of installed crates once
CRATE_LIST=$(cargo install --list 2>/dev/null || echo "")
# Check if already installed
if echo "$CRATE_LIST" | grep -q "^${NAME} "; then
INSTALLED_VER=$(echo "$CRATE_LIST" | grep "^${NAME} " | head -1 | awk '{print $2}' | tr -d 'v:')
if [[ -n "$INSTALLED_VER" ]]; then
if [[ -n "$VER" && "$VER" != "$INSTALLED_VER" ]]; then
$STD cargo install "$NAME" --version "$VER" --force
msg_info "Upgrading $NAME from v$INSTALLED_VER to v$VER"
$STD cargo install "$NAME" --version "$VER" --force || {
msg_error "Failed to install $NAME@$VER"
return 1
}
msg_ok "Upgraded $NAME to v$VER"
elif [[ -z "$VER" ]]; then
$STD cargo install "$NAME" --force
msg_info "Upgrading $NAME to latest"
$STD cargo install "$NAME" --force || {
msg_error "Failed to upgrade $NAME"
return 1
}
local NEW_VER=$(cargo install --list 2>/dev/null | grep "^${NAME} " | head -1 | awk '{print $2}' | tr -d 'v:')
msg_ok "Upgraded $NAME to v$NEW_VER"
else
msg_ok "$NAME v$INSTALLED_VER already installed"
fi
else
$STD cargo install "$NAME" ${VER:+--version "$VER"}
msg_info "Installing $NAME${VER:+@$VER}"
if [[ -n "$VER" ]]; then
$STD cargo install "$NAME" --version "$VER" || {
msg_error "Failed to install $NAME@$VER"
return 1
}
msg_ok "Installed $NAME v$VER"
else
$STD cargo install "$NAME" || {
msg_error "Failed to install $NAME"
return 1
}
local NEW_VER=$(cargo install --list 2>/dev/null | grep "^${NAME} " | head -1 | awk '{print $2}' | tr -d 'v:')
msg_ok "Installed $NAME v$NEW_VER"
fi
fi
done
msg_ok "Processed Rust crates"
fi
}