|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Define success and error color codes |
| 4 | +SUCCESS_COLOR="\e[32m" |
| 5 | +ERROR_COLOR="\e[31m" |
| 6 | +RESET_COLOR="\e[0m" |
| 7 | + |
| 8 | +# Define success tracking variables |
| 9 | +rustupToolchainNightlyInstalled=false |
| 10 | +cmakeInstalled=false |
| 11 | + |
| 12 | + |
| 13 | +# Define installation functions |
| 14 | + |
| 15 | +#Installing manually for now until we figure out why "ghcr.io/devcontainers-community/features/cmake": {} is not working |
| 16 | +install_cmake() { |
| 17 | + echo -e "Installing CMake..." |
| 18 | + sudo apt-get update |
| 19 | + sudo apt-get install -y cmake > /dev/null 2>&1 |
| 20 | + if [[ "$(cmake --version)" =~ "cmake version" ]]; then |
| 21 | + echo -e "${SUCCESS_COLOR}CMake installed successfully.${RESET_COLOR}" |
| 22 | + cmakeInstalled=true |
| 23 | + else |
| 24 | + echo -e "${ERROR_COLOR}CMake installation failed. Please install it manually.${RESET_COLOR}" |
| 25 | + fi |
| 26 | +} |
| 27 | + |
| 28 | +install_rustup_toolchain_nightly() { |
| 29 | + echo -e "Installing Rustup nightly toolchain..." |
| 30 | + rustup toolchain install nightly > /dev/null 2>&1 |
| 31 | + rustup component add rustfmt --toolchain nightly > /dev/null 2>&1 |
| 32 | + if [[ "$(rustup toolchain list)" =~ "nightly" && "$(rustup component list --toolchain nightly | grep rustfmt)" =~ "installed" ]]; then |
| 33 | + echo -e "${SUCCESS_COLOR}Rustup nightly toolchain and rustfmt installed successfully.${RESET_COLOR}" |
| 34 | + rustupToolchainNightlyInstalled=true |
| 35 | + else |
| 36 | + echo -e "${ERROR_COLOR}Rustup nightly toolchain and/or rustfmt installation failed. Please install them manually.${RESET_COLOR}" |
| 37 | + fi |
| 38 | +} |
| 39 | + |
| 40 | +# Install tools |
| 41 | +install_cmake |
| 42 | +install_rustup_toolchain_nightly |
| 43 | + |
| 44 | +# Copy our custom welcome message to replace the default github welcome message |
| 45 | +sudo cp .devcontainer/welcome.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt |
| 46 | + |
| 47 | + |
| 48 | +# Check the success tracking variables |
| 49 | +if $rustupToolchainNightlyInstalled && $cmakeInstalled; then |
| 50 | + echo -e "${SUCCESS_COLOR}All tools installed successfully.${RESET_COLOR}" |
| 51 | +else |
| 52 | + echo -e "${ERROR_COLOR}One or more tools failed to install. Please check the output for errors and install the failed tools manually.${RESET_COLOR}" |
| 53 | +fi |
0 commit comments