asd
unknown
plain_text
a year ago
1.5 kB
6
Indexable
#!/bin/bash
# Function to display a spinner while waiting
spinner() {
local pid=$1
local delay=0.1
local spinstr='|/-\'
while ps a | awk '{print $1}' | grep -q "$pid"; do
local temp=${spinstr#?}
printf " [%c] " "$spinstr"
spinstr=$temp${spinstr%"$temp"}
sleep $delay
printf "\b\b\b\b\b\b"
done
printf " \b\b\b\b"
}
# Function to handle termination (Ctrl+C)
trap 'echo -e "\nProcess terminated."; exit 1' SIGINT
# Function to list connected devices
list_devices() {
cfgutil list | grep "ECID" | awk '{print $NF}'
}
echo "Waiting for a device to be connected..."
# Wait for a device to be connected
while : ; do
device_info=$(list_devices)
if [ "$device_info" != "" ]; then
break
fi
sleep 1 # Check every 1 second
done &
spinner $!
# Display device information
echo "Device connected:"
cfgutil info
# Prompt to proceed with erasing and preparing the device
read -p "Would you like to proceed with erasing and preparing the device? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Erasing the device..."
cfgutil erase
# Replace <BlueprintName> with the actual name of your blueprint
echo "Applying the blueprint..."
cfgutil blueprint "<BlueprintName>"
echo "Process complete. The device is now ready."
else
echo "Process aborted. You can disconnect the device."
fi
read -p "Press [Enter] to close this window."
Editor is loading...
Leave a Comment