Last active
April 11, 2021 14:45
-
-
Save ajmasia/371ef33b575ccb1a5cb85197682d0bf9 to your computer and use it in GitHub Desktop.
Install cc-tool script
This file contains 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
#!/usr/bin/env bash | |
CC_TOOL_DIR="$HOME/cc-tool" | |
packages=("autoconf" "automake" "libusb" "boost" "pkgconfig" "libtool") | |
function innstall_packages() { | |
echo "π adding homebrew packages" | |
brew services stop --all | |
installed_packages=() | |
for i in "$@"; do | |
if brew ls --versions "$i" >/dev/null; then | |
continue | |
else | |
tput setaf 6 | |
echo "π installing $i package" | |
tput sgr0 | |
brew install "$i" | |
installed_packages+=("$i") | |
fi | |
done | |
if [ ${#installed_packages[@]} -eq 0 ]; then | |
tput setaf 6 | |
echo "π no packages needed to be installed" | |
fi | |
} | |
function install_cc_tool { | |
tput setaf 2 | |
echo "π building cc-tool" | |
tput sgr0 | |
cd "$CC_TOOL_DIR" && ./bootstrap && ./configure && make | |
} | |
function show_help { | |
tput setaf 2 | |
echo "π some help from https://www.zigbee2mqtt.io/information/flashing_the_cc2531.html" | |
tput setaf 6 | |
echo "Connect devices: CC debugger --> Downloader cable CC2531 --> CC2531 USB sniffer" | |
echo "Connect BOTH the CC2531 USB sniffer and the CC debugger to your PC using USB" | |
echo "If the light on the CC debugger is RED, press the Reset button on the CC debugger. The light on the CC debugger should now turn GREEN" | |
echo "Download the firmware: https://github.com/Koenkk/Z-Stack-firmware/tree/master/coordinator/Z-Stack_Home_1.2/bin" | |
echo "Flash your firmware runing: sudo cc-tool -e -w <firmware-file.hex>" | |
echo "πββοΈ Enjoy!!!" | |
tput sgr0 | |
} | |
function ctrl_c() { | |
exit 1 | |
} | |
trap ctrl_c INT | |
if [[ -d "$CC_TOOL_DIR" ]]; then | |
tput setaf 1 | |
echo "β οΈ it seems cc-tool is installed in your user root directory" | |
exit 1 | |
else | |
clear | |
tput setaf 2 | |
echo "π installing cc-tool app" | |
innstall_packages "${packages[@]}" | |
tput setaf 2 | |
echo "π cloning into: '$CC_TOOL_DIR'" | |
tput sgr0 | |
git clone https://github.com/dashesy/cc-tool.git "$CC_TOOL_DIR" | |
if install_cc_tool; then | |
tput setaf 2 | |
echo "π cc-tool installation has been completed successfully" | |
echo "β οΈ add 'export PATH=$PATH:$HOME/cc-tool' to your .zshrc PATH" | |
tput sgr0 | |
show_help | |
else | |
tput setaf 1 | |
echo "π₯ an error occurred installing the app" | |
exit 1 | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment