Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,11 @@ The script will also ask you whether you want to keep the temporary files after
In case you change your mind you can always delete the entire directory (by default `~/jetson_configure_tmp`).
The size of this directory is about 75 GB.

After the script completes, you can continue configuration on the Jetson device by cloning this repository and running one of the `setup_utility.sh` scripts.
After the script completes, you can continue configuration on the Jetson device by cloning this repository and running the `setup_utility.sh` script.

## Configuration utility

- Run the script with "setup_utility.sh" in the root directory of the repository.
- The menu items will be automatically generated from the "subscripts"
folder
- Scripts and folders will appear in the menu as items or
folders.

You can easily add new functionality by putting new scripts into the
subscripts folder. See examples of menus in the "examples_whiptail"
folder.
- Run the script with `setup_utility.sh` in the root directory of the repository.
- The menu items will be automatically generated from the "subscripts" folder
- Scripts and folders will appear in the menu as items or folders.
- You can easily add new functionality by putting new scripts into the subscripts folder. See examples of menus in the `examples_whiptail` folder.
2 changes: 1 addition & 1 deletion jetson_flash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# - prepare the filesystem with a headless user and autologin enabled
# - flash the device with the prepared filesystem and binaries
#
# After this script completes you can continue configuration on the device itself with the setup_utility_F4F.sh or setup_utility_MRS.sh scripts
# After this script completes you can continue configuration on the device itself with the setup_utility.sh script
#

set -euo pipefail
Expand Down
78 changes: 56 additions & 22 deletions setup_utility_MRS.sh → setup_utility.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ blink=$(tput blink)
red='\033[0;31m'
green='\033[0;32m'

light=$(echo $PROFILES | grep COLORSCHEME_LIGHT)
if [ -z "$light" ]
then
light=$(echo "$PROFILES" | grep COLORSCHEME_LIGHT)
if [ -z "$light" ]; then
export NEWT_COLORS='
root=brightgreen,black
border=brightgreen,black
Expand Down Expand Up @@ -44,7 +43,6 @@ else
'
fi


# export NEWT_COLORS='
# root=brightgreen,black
# border=brightgreen,black
Expand Down Expand Up @@ -86,13 +84,10 @@ fi
# roottext=lightgrey,black

# Specify the folder path where your files are located


DIR="$(dirname "$(readlink -f "$0")")"
folder_path=""
first_run=true
if [ -z "$1" ]
then
if [ -z "$1" ]; then
folder_path="$DIR/subscripts"
sudo chmod -R +x "$DIR/subscripts"
sudo chmod -R -x "$DIR/subscripts/5Udev_rules/DISREGARD_udev_rules"
Expand All @@ -106,14 +101,25 @@ fi
OPTIONS=()
FULL_FILEPATHS=()

show_menu() {
show_main_menu() {
whiptail --title "MRS UAV System Install Utility" --menu "Choose an option:" 0 0 0 "${OPTIONS[@]}" 3>&1 1>&2 2>&3
}

show_f4f_mrs_switch_menu() {

F4F_MRS_SWITCH_OPTIONS=(
1 "Use F4F defaults"
2 "Use MRS defaults"
)

whiptail --title "MRS UAV System Install Utility" --menu "Do you want to use F4F or MRS defaults?" 0 0 0 "${F4F_MRS_SWITCH_OPTIONS[@]}" 3>&1 1>&2 2>&3
}

main() {

while true; do
clear
choice=$(show_menu)
choice=$(show_main_menu)

if [ $? -eq 0 ]; then
echo ${FULL_FILEPATHS[$((choice - 1))]}
Expand All @@ -140,8 +146,7 @@ index="1"
for file in "$folder_path"/*; do
# Add each filename to the array
disregard=$(echo $file | grep "DISREGARD")
if [ ! -z "$disregard" ]
then
if [ ! -z "$disregard" ]; then
continue
fi

Expand All @@ -150,7 +155,7 @@ for file in "$folder_path"/*; do
filename="${file##*"/"}"
filename="${filename%.*}"
filename="${filename//_/ }"
filename="${filename#[[:digit:]]}" #removes the first digit from script name
filename="${filename#[[:digit:]]}" # removes the first digit from script name

if [[ -d ${file} ]]; then
OPTIONS+=("$filename ...")
Expand All @@ -161,17 +166,31 @@ for file in "$folder_path"/*; do
FULL_FILEPATHS+=("$file")
done

if [ "$first_run" = true ] ; then
#Check connection to the internet
if [ "$first_run" = true ]; then
# Check connection to the internet
wget -q --spider http://google.com

if [ $? -eq 0 ]; then
echo -e "${green}Online${normal}"
sudo apt install git
sudo apt update

# Check if apt update was already successfully ran in the last 60 minutes and if so, do not run it again
if [ -f /var/lib/apt/periodic/update-success-stamp ]; then
last_update=$(stat -c %Y /var/lib/apt/periodic/update-success-stamp)
now=$(date +%s)
if [ $((now - last_update)) -lt 3600 ]; then
echo "Apt update was already successfully ran in the last 60 minutes, not running it again"
else
sudo apt update
fi
fi
if ! command -v git &>/dev/null; then
echo "Git is not installed. Installing git..."
sudo apt install git
fi

if ! git diff --quiet || ! git diff --cached --quiet; then
echo "Error: Local changes detected. Commit or stash your changes before pulling."
exit 1
echo "Error: Local changes detected. Commit or stash your changes before pulling."
exit 1
fi
git pull
else
Expand All @@ -181,14 +200,29 @@ if [ "$first_run" = true ] ; then
read -p "${blink}${bold}Hit enter to continue ...${normal}"
fi

#Check for whiptail
# Check for whiptail
whiptail_installed=$(apt-cache policy whiptail | grep Installed | grep none)

if [ ! -z "$whiptail_installed" ]
then
if [ ! -z "$whiptail_installed" ]; then
echo "Whiptail NOT installed, will install now:"
sudo apt install whiptail
fi

# Ask whether the user wants to use F4F or MRS defaults
f4f_mrs_choice=$(show_f4f_mrs_switch_menu)
case $f4f_mrs_choice in
1)
echo "Using F4F defaults"
export USE_DEFAULTS_FOR="F4F"
;;
2)
echo "Using MRS defaults"
export USE_DEFAULTS_FOR="MRS"
;;
*) # the default case, also called when cancel is selected
exit 1
;;
esac
fi

main
194 changes: 0 additions & 194 deletions setup_utility_F4F.sh

This file was deleted.

Loading