Files
oscarpilot/launch_openpilot.sh
Your Name af0fc9daec wip
2024-02-13 00:22:00 -06:00

72 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/bash
cd /data/openpilot
# Initialize a counter for the timeout
timeout=5
# Loop until we have a network connection or the timeout expires
while ! ping -c 1 google.com &> /dev/null; do
echo "Waiting for internet connection..."
sleep 1
timeout=$((timeout - 1))
if [ "$timeout" -le 0 ]; then
echo "Timeout reached. Proceeding without network operations."
break
fi
done
if [ "$timeout" -gt 0 ]; then
echo "Internet connection established, proceeding with update."
# Set branch to your target branch
branch="oscrpilot"
# Fetch the latest changes from the remote repository for the target branch
git fetch origin "$branch"
# Checkout the target branch forcefully, ignoring submodules as in the Python example
git checkout --force --no-recurse-submodules -B "$branch" FETCH_HEAD
# Reset the local changes hard, clean the directory including untracked files and directories,
# and ensure submodules are in sync, updated, and also reset hard
git reset --hard
git clean -xdff
git submodule sync
git submodule update --init --recursive
git submodule foreach --recursive git reset --hard
echo "Repository and submodules have been updated and cleaned."
# Assuming AGNOS and finalize_update steps are specific and detailed,
# the shell equivalent might require custom scripts or commands.
# For AGNOS update, you'd handle it based on your specific needs.
# Finalizing update - replicating the Python finalize_update function
FINALIZED="/path/to/finalized" # Define your finalized update path
OVERLAY_MERGED="/path/to/overlay_merged" # Define your overlay merged view path
# Clean up any previous finalized update and copy the new one
[ -d "$FINALIZED" ] && rm -rf "$FINALIZED"
cp -rT "$OVERLAY_MERGED" "$FINALIZED" --preserve=links
# Reset and clean the finalized update directory
git -C "$FINALIZED" reset --hard
git -C "$FINALIZED" submodule foreach --recursive git reset --hard
# Run git cleanup in the finalized update directory
git -C "$FINALIZED" gc
git -C "$FINALIZED" lfs prune
echo "Finalized update directory has been prepared."
fi
# Blank the UI (assuming framebuffer device is /dev/fb0)
# This command clears the framebuffer, effectively blanking the screen
dd if=/dev/zero of=/dev/fb0 &> /dev/null
export PASSIVE="0"
exec ./launch_chffrplus.sh