Mercurial > louis > kiibohd-controller
comparison LoadFile/load.dfu @ 281:71882cd1c362
Check for needed programs
Check for dfu-util and screen before using them. Also aborts if
teensy_loader_cli compilation fails.
Uses the type builtin to determine if a command exists. See here:
https://gist.github.com/sdelmas/7377271
author | Rowan Decker <Smasher816@gmail.com> |
---|---|
date | Thu, 12 Feb 2015 19:42:01 -0800 |
parents | 2a3468f5d8be |
children | c86eb7d0a693 |
comparison
equal
deleted
inserted
replaced
280:18b61e53753c | 281:71882cd1c362 |
---|---|
52 sleep 1 | 52 sleep 1 |
53 fi | 53 fi |
54 | 54 |
55 # Load via dfu-util | 55 # Load via dfu-util |
56 # Used for McHCK based uCs | 56 # Used for McHCK based uCs |
57 dfu-util -D @TARGET_BIN@ | 57 if type dfu-util &>/dev/null; then |
58 EXIT_STATUS=$? | 58 dfu-util -D @TARGET_BIN@ |
59 EXIT_STATUS=$? | |
60 else | |
61 echo "dfu-util is required to reprogram the device" | |
62 exit 3 | |
63 fi | |
59 | 64 |
60 # Load Screen Session if specified | 65 # Load Screen Session if specified |
61 if (( "$EXIT_STATUS" == "0" )) && [[ "$AUTO_SCREEN_SESSION" != "" ]]; then | 66 if (( "$EXIT_STATUS" == "0" )) && [[ "$AUTO_SCREEN_SESSION" != "" ]]; then |
62 sleep 0.1 | 67 if type screen &>/dev/null; then |
63 screen $AUTO_SCREEN_SESSION | 68 sleep 0.1 |
69 screen $AUTO_SCREEN_SESSION | |
70 else | |
71 echo "screen is not installed" | |
72 exit 3 | |
73 fi | |
64 fi | 74 fi |
65 | 75 |
66 exit $EXIT_STATUS | 76 exit $EXIT_STATUS |
67 | 77 |