add rust function & linkwarden 24.04

This commit is contained in:
CanbiZ
2025-05-27 10:33:04 +02:00
parent 1216d2f27c
commit 42402c54dc
3 changed files with 257 additions and 0 deletions

View File

@@ -1191,3 +1191,47 @@ setup_rbenv_stack() {
rm -rf "$TMP_DIR"
msg_ok "rbenv stack ready (Ruby $RUBY_VERSION)"
}
install_rust_and_crates() {
local RUST_TOOLCHAIN="${RUST_TOOLCHAIN:-stable}"
local RUST_CRATES="${RUST_CRATES:-}"
# Install rustup if not available
if ! command -v rustup &>/dev/null; then
msg_info "Installing rustup"
curl -fsSL https://sh.rustup.rs | sh -s -- -y --default-toolchain "$RUST_TOOLCHAIN"
export PATH="$HOME/.cargo/bin:$PATH"
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >>"$HOME/.profile"
msg_ok "Installed rustup with $RUST_TOOLCHAIN"
else
msg_ok "rustup already installed"
rustup install "$RUST_TOOLCHAIN"
fi
rustup default "$RUST_TOOLCHAIN"
rustup update
# install crates
if [[ -n "$RUST_CRATES" ]]; then
IFS=',' read -ra CRATES <<<"$RUST_CRATES"
for crate in "${CRATES[@]}"; do
local NAME VER
if [[ "$crate" == *"@"* ]]; then
NAME="${crate%@*}"
VER="${crate##*@}"
else
NAME="$crate"
VER=""
fi
if cargo install --list | grep -q "^$NAME "; then
msg_info "Crate $NAME already installed, updating"
cargo install "$NAME" ${VER:+--version "$VER"} --force
else
msg_info "Installing crate $NAME ${VER:+($VER)}"
cargo install "$NAME" ${VER:+--version "$VER"}
fi
done
msg_ok "All requested Rust crates processed"
fi
}