-
Notifications
You must be signed in to change notification settings - Fork 0
F_adding_install_script #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Athen-Player1
wants to merge
9
commits into
noetic-devel
Choose a base branch
from
F_install_script
base: noetic-devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ac446f7
adding install.sh
Athen-Player1 325c614
adding license & adding grub editing to install_kernel()
Athen-Player1 5f66af2
removing whitespace
Athen-Player1 474113b
removing correct whitespace
Athen-Player1 dccc093
addressing Pr comments
Athen-Player1 6c76ef0
fixing typo(s)
Athen-Player1 929343b
removing typo
Athen-Player1 10bd1e8
Merge branch 'noetic-devel' into F_install_script
Athen-Player1 ff98371
Merge branch 'noetic-devel' into F_install_script
niko-holmes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,229 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Software License Agreement (BSD License) | ||
| # Copyright © 2025 belongs to Shadow Robot Company Ltd. | ||
| # All rights reserved. | ||
| # Redistribution and use in source and binary forms, with or without modification, | ||
| # are permitted provided that the following conditions are met: | ||
| # 1. Redistributions of source code must retain the above copyright notice, | ||
| # this list of conditions and the following disclaimer. | ||
| # 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| # this list of conditions and the following disclaimer in the documentation | ||
| # and/or other materials provided with the distribution. | ||
| # 3. Neither the name of Shadow Robot Company Ltd nor the names of its contributors | ||
| # may be used to endorse or promote products derived from this software without | ||
| # specific prior written permission. | ||
| # This software is provided by Shadow Robot Company Ltd "as is" and any express | ||
| # or implied warranties, including, but not limited to, the implied warranties of | ||
| # merchantability and fitness for a particular purpose are disclaimed. In no event | ||
| # shall the copyright holder be liable for any direct, indirect, incidental, special, | ||
| # exemplary, or consequential damages (including, but not limited to, procurement of | ||
| # substitute goods or services; loss of use, data, or profits; or business interruption) | ||
| # however caused and on any theory of liability, whether in contract, strict liability, | ||
| # or tort (including negligence or otherwise) arising in any way out of the use of this | ||
| # software, even if advised of the possibility of such damage. | ||
|
|
||
| set -e | ||
|
|
||
| # Colors for terminal output | ||
| RED='\033[0;31m' | ||
| GREEN='\033[0;32m' | ||
| BLUE='\033[0;34m' | ||
| YELLOW='\033[1;33m' | ||
| NC='\033[0m' | ||
|
|
||
| DEVELOPMENT=false | ||
| KERNEL_URL="https://s3.eu-west-2.amazonaws.com/com.shadowrobot.eu-west-2.public/linux-image-6.5.2-rt8_6.5.2-3_amd64.deb" | ||
| KERNEL_LOCATION="/tmp/rtkernel.deb" | ||
|
|
||
|
|
||
| # Print colour functions | ||
| print_red() { | ||
| echo -e "${RED}$1${NC}" | ||
| } | ||
|
|
||
| print_green() { | ||
| echo -e "${GREEN}$1${NC}" | ||
| } | ||
|
|
||
| print_yellow() { | ||
| echo -e "${YELLOW}$1${NC}" | ||
| } | ||
|
|
||
| print_blue() { | ||
| echo -e "${BLUE}$1${NC}" | ||
| } | ||
|
|
||
| print_startup_message() { | ||
| print_yellow "=================================================================" | ||
| print_yellow "| |" | ||
| print_yellow "| Shadow Dexee Deployment Tool |" | ||
| print_yellow "| |" | ||
| print_yellow "=================================================================" | ||
| print_yellow "" | ||
| print_yellow "Possible options:" | ||
| print_yellow " * --dev Install the development container" | ||
| print_yellow " * --help Print this help" | ||
| } | ||
|
|
||
| install_apps() { | ||
| print_yellow "Updating package repositories..." | ||
| sudo apt update >/dev/null || { print_red "Failed to update repositories"; exit 1; } | ||
|
|
||
| print_yellow "Upgrading system packages..." | ||
| sudo apt upgrade -y >/dev/null || { print_red "Failed to upgrade packages"; exit 1; } | ||
|
|
||
| print_yellow "Installing required packages (Terminator, Docker, OpenSSH, Curl)..." | ||
| sudo apt install -y terminator docker.io openssh-server curl || { print_red "Failed to install packages"; exit 1; } | ||
|
|
||
| print_green "Package installation complete" | ||
| } | ||
|
|
||
| install_kernel() { | ||
| print_yellow "Installing RT kernel..." | ||
| # Check if kernel is already installed | ||
| if dpkg -l | grep -q "linux-image-6.5.2-rt8"; then | ||
Athen-Player1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| print_yellow "RT kernel is already installed" | ||
| return 0 | ||
| fi | ||
|
|
||
| # Install the kernel and set it as the default grub option | ||
| wget -O "$KERNEL_LOCATION" "$KERNEL_URL" >/dev/null || { print_red "Failed to download kernel"; exit 1; } | ||
| sudo dpkg -i "$KERNEL_LOCATION" >/dev/null || { print_red "Failed to install kernel"; exit 1; } | ||
| rm -f "$KERNEL_LOCATION" || { print_yellow "Warning: Failed to remove kernel package"; } | ||
| print_yellow "Updating GRUB configuration..." | ||
| sudo cp /etc/default/grub /etc/default/grub.bak || { print_red "Failed to backup GRUB configuration"; exit 1; } | ||
| sudo sed -i 's/^GRUB_TIMEOUT=.*/GRUB_TIMEOUT=10/' /etc/default/grub || { print_red "Failed to update GRUB timeout"; exit 1; } | ||
| sudo sed -i 's/^GRUB_DEFAULT=.*/GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 6.5.2-rt8"/' /etc/default/grub || { print_red "Failed to update GRUB default kernel"; exit 1; } | ||
| sudo update-grub || { print_red "Failed to update GRUB"; exit 1; } | ||
|
|
||
| print_green "RT kernel installation complete" | ||
|
|
||
| } | ||
|
|
||
| # Set up docker groups and add the user to it | ||
| configure_docker() { | ||
| print_yellow "Setting up Docker..." | ||
| if ! getent group docker >/dev/null; then | ||
| sudo groupadd docker || { print_red "Failed to create docker group"; exit 1; } | ||
| fi | ||
|
|
||
| if ! groups "$USER" | grep -q docker; then | ||
| sudo usermod -aG docker "$USER" || { print_red "Failed to add user to docker group"; exit 1; } | ||
| fi | ||
| print_green "Docker setup complete" | ||
| print_yellow "Please log out and log back in for Docker group changes to take effect" | ||
| } | ||
|
|
||
| # Download and install the awscli | ||
| install_awscli() { | ||
| print_yellow "Installing AWS CLI..." | ||
| if ! command -v aws &> /dev/null; then | ||
| curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" || { print_red "Failed to download AWS CLI"; exit 1; } | ||
| unzip -q awscliv2.zip || { print_red "Failed to extract AWS CLI"; exit 1; } | ||
| sudo ./aws/install || { print_red "Failed to install AWS CLI"; exit 1; } | ||
| rm -rf awscliv2.zip aws || { print_red "Failed to clean up AWS CLI installation files"; exit 1; } | ||
| else | ||
| print_yellow "AWS CLI is already installed" | ||
| fi | ||
| mkdir -p ~/.ros || { print_red "Failed to create .ros directory"; exit 1; } | ||
| print_green "AWS CLI installation complete" | ||
| } | ||
|
|
||
| # Prompt for AWS login | ||
| authenticate_aws() { | ||
| print_yellow "Please sign into AWS..." | ||
| aws configure || { print_red "AWS configuration failed"; exit 1; } | ||
| if [ "$DEVELOPMENT" = true ]; then | ||
| print_yellow "Authenticating with development ECR..." | ||
| aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin 080653068785.dkr.ecr.eu-west-2.amazonaws.com || { print_red "Failed to authenticate with development ECR"; exit 1; } | ||
| else | ||
| print_yellow "Authenticating with public ECR..." | ||
| aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/shadowrobot || { print_red "Failed to authenticate with public ECR"; exit 1; } | ||
| fi | ||
| } | ||
|
|
||
| # Clone Host Scripts and move to home | ||
| clone_host_scripts() { | ||
| print_yellow "Cloning host scripts..." | ||
| # Create temporary directory | ||
| local temp_dir="/tmp/host_scripts/" | ||
| mkdir -p "$temp_dir" || { print_red "Failed to create temporary directory"; exit 1; } | ||
|
|
||
| # Clone repository | ||
| cd "$temp_dir" || { print_red "Failed to change to temporary directory"; exit 1; } | ||
| git clone -n --depth=1 --filter=tree:0 https://github.com/shadow-robot/dx_system.git . || { print_red "Failed to clone repository"; exit 1; } | ||
Athen-Player1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Configure sparse checkout | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have to cd into the dir you just cloned for the next git commands to work |
||
| git sparse-checkout --no-cone /host_scripts || { print_red "Failed to configure sparse checkout"; exit 1; } | ||
Athen-Player1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| git checkout || { print_red "Failed to checkout host_scripts"; exit 1; } | ||
|
|
||
| mv host_scripts "/home/$USER/" || { print_red "Failed to move host_scripts"; exit 1; } | ||
Athen-Player1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Cleanup | ||
| cd "/home/$USER" || { print_yellow "Warning: Failed to change back to home directory"; } | ||
| rm -rfd "$temp_dir" || { print_yellow "Warning: Failed to remove temporary directory"; } | ||
Athen-Player1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| print_green "Host scripts cloned successfully" | ||
| } | ||
|
|
||
| append_bashrc(){ | ||
| # Append the setup.bash into the bashrc | ||
| print_yellow "Setting up bashrc" | ||
| grep -qxF 'source /home/$USER/host_scripts/setup.bash' ~/.bashrc || echo 'source /home/$USER/host_scripts/setup.bash' >> ~/.bashrc | ||
| source ~/.bashrc | ||
| print_green "bashrc setup complete" | ||
| } | ||
|
|
||
| pull_dx_image() { | ||
| source /home/$USER/host_scripts/envoirment.sh | ||
Athen-Player1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| IMAGE="${IMAGE_REPOSITORY}:${IMAGE_TAG_FLAVOUR}-${IMAGE_TAG_VERSION}" | ||
Athen-Player1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| print_yellow "Pulling image: $IMAGE" | ||
| docker pull "$IMAGE" || { print_red "Failed to pull image"; exit 1; } | ||
| } | ||
|
|
||
| clear_credentials(){ | ||
| print_yellow "Removing AWS creds and signing out of docker" | ||
| unset AWS_ACCESS_KEY_ID | ||
| unset AWS_SECRET_ACCESS_KEY | ||
| unset AWS_SESSION_TOKEN | ||
| unset AWS_PROFILE | ||
| rm -f ~/.aws/credentials | ||
| rm -f ~/.aws/config | ||
| aws ecr get-login-password | docker logout 080653068785.dkr.ecr.eu-west-2.amazonaws.com ||{ print_red "Failed to logout of ECR"; exit 1; } | ||
| docker logout $(docker info | grep 'Username' | awk '{print $2}') | ||
| print_green "Credentials cleared" | ||
| } | ||
| # Main script execution | ||
| print_startup_message | ||
|
|
||
| # Parse command line arguments | ||
| for arg in "$@"; do | ||
| case "$arg" in | ||
| --dev) | ||
| DEVELOPMENT=true | ||
| print_red "Development environment will be installed" | ||
| ;; | ||
| --help) | ||
| print_startup_message | ||
| exit 0 | ||
| ;; | ||
| *) | ||
| print_red "Unknown option: $arg" | ||
| print_startup_message | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| install_apps | ||
| install_kernel | ||
| configure_docker | ||
| install_awscli | ||
| authenticate_aws | ||
| clone_host_scripts | ||
| append_bashrc | ||
| pull_dx_image | ||
| clear_credentials | ||
Athen-Player1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
Athen-Player1 marked this conversation as resolved.
Show resolved
Hide resolved
Athen-Player1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| print_green "Installation completed successfully! Please reboot your system to use the new RT kernel." | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.