...
This commit is contained in:
parent
d6362a5152
commit
13839041ff
@ -40,7 +40,8 @@ fi
|
|||||||
|
|
||||||
# Check if Rust is already installed
|
# Check if Rust is already installed
|
||||||
if command -v rustc &> /dev/null; then
|
if command -v rustc &> /dev/null; then
|
||||||
RUST_VERSION=$(rustc --version)
|
RUST_VERSION=$(rustc --version 2>/dev/null || echo "")
|
||||||
|
if [ -n "$RUST_VERSION" ]; then
|
||||||
warn "Rust is already installed: $RUST_VERSION"
|
warn "Rust is already installed: $RUST_VERSION"
|
||||||
read -p "Do you want to update/reinstall? (y/N): " -n 1 -r
|
read -p "Do you want to update/reinstall? (y/N): " -n 1 -r
|
||||||
echo
|
echo
|
||||||
@ -48,6 +49,11 @@ if command -v rustc &> /dev/null; then
|
|||||||
log "Installation cancelled"
|
log "Installation cancelled"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
warn "Rust tools found but no default toolchain set. Will configure default toolchain."
|
||||||
|
fi
|
||||||
|
elif command -v rustup &> /dev/null; then
|
||||||
|
warn "Rustup found but no default toolchain set. Will configure default toolchain."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for required dependencies
|
# Check for required dependencies
|
||||||
@ -85,6 +91,15 @@ log "Starting Rust installation..."
|
|||||||
log "CARGO_HOME: $CARGO_HOME"
|
log "CARGO_HOME: $CARGO_HOME"
|
||||||
log "RUSTUP_HOME: $RUSTUP_HOME"
|
log "RUSTUP_HOME: $RUSTUP_HOME"
|
||||||
|
|
||||||
|
# Check if rustup is already installed but needs default toolchain
|
||||||
|
if command -v rustup &> /dev/null; then
|
||||||
|
log "Rustup already installed. Setting up default toolchain..."
|
||||||
|
if [ "$EUID" -eq 0 ]; then
|
||||||
|
/usr/local/bin/rustup default stable || rustup default stable
|
||||||
|
else
|
||||||
|
"$CARGO_HOME/bin/rustup" default stable || rustup default stable
|
||||||
|
fi
|
||||||
|
else
|
||||||
# Download and run rustup installer
|
# Download and run rustup installer
|
||||||
log "Downloading rustup installer..."
|
log "Downloading rustup installer..."
|
||||||
if [ "$EUID" -eq 0 ]; then
|
if [ "$EUID" -eq 0 ]; then
|
||||||
@ -119,27 +134,43 @@ else
|
|||||||
log "To use Rust in new shells, run: source ~/.cargo/env"
|
log "To use Rust in new shells, run: source ~/.cargo/env"
|
||||||
log "Or add ~/.cargo/bin to your PATH in your shell profile"
|
log "Or add ~/.cargo/bin to your PATH in your shell profile"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Verify installation
|
# Verify installation
|
||||||
log "Verifying Rust installation..."
|
log "Verifying Rust installation..."
|
||||||
if [ "$EUID" -eq 0 ]; then
|
if [ "$EUID" -eq 0 ]; then
|
||||||
|
# Source the environment first
|
||||||
|
export PATH="/usr/local/cargo/bin:$PATH"
|
||||||
RUST_VERSION=$(/usr/local/bin/rustc --version 2>/dev/null || echo "")
|
RUST_VERSION=$(/usr/local/bin/rustc --version 2>/dev/null || echo "")
|
||||||
CARGO_VERSION=$(/usr/local/bin/cargo --version 2>/dev/null || echo "")
|
CARGO_VERSION=$(/usr/local/bin/cargo --version 2>/dev/null || echo "")
|
||||||
|
RUSTUP_VERSION=$(/usr/local/bin/rustup --version 2>/dev/null || echo "")
|
||||||
else
|
else
|
||||||
RUST_VERSION=$("$CARGO_HOME/bin/rustc" --version 2>/dev/null || echo "")
|
# Source the cargo environment
|
||||||
CARGO_VERSION=$("$CARGO_HOME/bin/cargo" --version 2>/dev/null || echo "")
|
if [ -f "$CARGO_HOME/env" ]; then
|
||||||
|
source "$CARGO_HOME/env"
|
||||||
|
fi
|
||||||
|
RUST_VERSION=$("$CARGO_HOME/bin/rustc" --version 2>/dev/null || rustc --version 2>/dev/null || echo "")
|
||||||
|
CARGO_VERSION=$("$CARGO_HOME/bin/cargo" --version 2>/dev/null || cargo --version 2>/dev/null || echo "")
|
||||||
|
RUSTUP_VERSION=$("$CARGO_HOME/bin/rustup" --version 2>/dev/null || rustup --version 2>/dev/null || echo "")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$RUST_VERSION" ] && [ -n "$CARGO_VERSION" ]; then
|
if [ -n "$RUST_VERSION" ] && [ -n "$CARGO_VERSION" ]; then
|
||||||
log "✅ Rust installation successful!"
|
log "✅ Rust installation successful!"
|
||||||
log "Rust compiler: $RUST_VERSION"
|
log "Rust compiler: $RUST_VERSION"
|
||||||
log "Cargo package manager: $CARGO_VERSION"
|
log "Cargo package manager: $CARGO_VERSION"
|
||||||
|
if [ -n "$RUSTUP_VERSION" ]; then
|
||||||
|
log "Rustup toolchain manager: $RUSTUP_VERSION"
|
||||||
|
fi
|
||||||
|
|
||||||
# Install common components
|
# Set default toolchain and install common components
|
||||||
log "Installing common Rust components..."
|
log "Setting default Rust toolchain..."
|
||||||
if [ "$EUID" -eq 0 ]; then
|
if [ "$EUID" -eq 0 ]; then
|
||||||
|
/usr/local/bin/rustup default stable
|
||||||
|
log "Installing common Rust components..."
|
||||||
/usr/local/bin/rustup component add clippy rustfmt
|
/usr/local/bin/rustup component add clippy rustfmt
|
||||||
else
|
else
|
||||||
|
"$CARGO_HOME/bin/rustup" default stable
|
||||||
|
log "Installing common Rust components..."
|
||||||
"$CARGO_HOME/bin/rustup" component add clippy rustfmt
|
"$CARGO_HOME/bin/rustup" component add clippy rustfmt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -158,3 +189,5 @@ if [ -n "$RUST_VERSION" ] && [ -n "$CARGO_VERSION" ]; then
|
|||||||
else
|
else
|
||||||
error "Rust installation failed. Please check the output above for errors."
|
error "Rust installation failed. Please check the output above for errors."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
rustup default stable
|
@ -36,7 +36,7 @@ log "Script directory: $SCRIPT_DIR"
|
|||||||
|
|
||||||
# Define target directory for SAL repository
|
# Define target directory for SAL repository
|
||||||
SAL_TARGET_DIR="/root/code/git.threefold.info/herocode/sal"
|
SAL_TARGET_DIR="/root/code/git.threefold.info/herocode/sal"
|
||||||
SAL_REPO_URL="git@git.ourworld.tf:herocode/sal.git"
|
SAL_REPO_URL="git@git.threefold.info:herocode/sal.git"
|
||||||
|
|
||||||
# Function to check if ssh-agent is loaded and has keys
|
# Function to check if ssh-agent is loaded and has keys
|
||||||
check_ssh_agent() {
|
check_ssh_agent() {
|
||||||
@ -59,10 +59,10 @@ check_ssh_agent() {
|
|||||||
|
|
||||||
# Function to test SSH connection to git server
|
# Function to test SSH connection to git server
|
||||||
test_ssh_connection() {
|
test_ssh_connection() {
|
||||||
log "Testing SSH connection to git.ourworld.tf..."
|
log "Testing SSH connection to git.threefold.info..."
|
||||||
|
|
||||||
if ssh -T -o ConnectTimeout=10 -o StrictHostKeyChecking=no git@git.ourworld.tf 2>&1 | grep -q "successfully authenticated"; then
|
if ssh -T -o ConnectTimeout=10 -o StrictHostKeyChecking=no git@git.threefold.info 2>&1 | grep -q "successfully authenticated"; then
|
||||||
log "✅ SSH connection to git.ourworld.tf successful"
|
log "✅ SSH connection to git.threefold.info successful"
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
warn "SSH connection test failed. Continuing anyway..."
|
warn "SSH connection test failed. Continuing anyway..."
|
||||||
|
Loading…
Reference in New Issue
Block a user