Revision 57cbd1cd periphery-lld/peripherylldsetup.sh
periphery-lld/peripherylldsetup.sh | ||
---|---|---|
263 | 263 |
return 0 |
264 | 264 |
} |
265 | 265 |
|
266 |
### check whether commands are available ####################################### |
|
267 |
# Checks whether the specified commands are available and can be executed. |
|
268 |
# |
|
269 |
# usage: checkCommand [<command> <command> ...] |
|
270 |
# arguments: <command> |
|
271 |
# Name of the command to check. |
|
272 |
# return: 0 |
|
273 |
# All requested commands are available. |
|
274 |
# >0 |
|
275 |
# Number of requested commands that were not found. |
|
276 |
# -1 |
|
277 |
# No argument given. |
|
278 |
# |
|
279 |
function checkCommands { |
|
280 |
local status=0 |
|
281 |
|
|
282 |
# return if no argument was specified |
|
283 |
if [ $# -eq 0 ]; then |
|
284 |
return -1 |
|
285 |
fi |
|
286 |
|
|
287 |
# check all specified commands |
|
288 |
while [ $# -gt 0 ]; do |
|
289 |
command -v $1 &>/dev/null |
|
290 |
if [ $? -ne 0 ]; then |
|
291 |
printWarning "Command '$1' not available.\n" |
|
292 |
status=$((status + 1)) |
|
293 |
fi |
|
294 |
shift 1 |
|
295 |
done |
|
296 |
|
|
297 |
return $status |
|
298 |
} |
|
299 |
|
|
266 | 300 |
################################################################################ |
267 | 301 |
# SPECIFIC FUNCTIONS # |
268 | 302 |
################################################################################ |
... | ... | |
327 | 361 |
# Warning: Arborted by user. |
328 | 362 |
# -1 |
329 | 363 |
# Error: Unexpected user input. |
364 |
# -2 |
|
365 |
# Error: Missing dependencies. |
|
330 | 366 |
# |
331 | 367 |
function initAmiroLld { |
332 | 368 |
printInfo "initializing AMiRo-LLD submodule...\n" |
... | ... | |
352 | 388 |
esac |
353 | 389 |
fi |
354 | 390 |
|
391 |
# check dependencies |
|
392 |
checkCommands git |
|
393 |
if [ $? -ne 0 ]; then |
|
394 |
printError "Missing dependencies detected.\n" |
|
395 |
return -2 |
|
396 |
fi |
|
397 |
|
|
355 | 398 |
# initialize submodule to default branch |
356 | 399 |
cd $peripheryllddir |
357 | 400 |
git submodule update --init $amirollddir 2>&1 | tee -a $LOG_FILE |
... | ... | |
381 | 424 |
# |
382 | 425 |
# usage: wipeAmiroLld |
383 | 426 |
# arguments: n/a |
384 |
# return: n/a |
|
427 |
# return: 0 |
|
428 |
# No error or warning occurred. |
|
429 |
# 1 |
|
430 |
# Warning: AMiRo-LLD Git submodule already empty |
|
431 |
# 2 |
|
432 |
# Warning: Aborted by user. |
|
433 |
# -1 |
|
434 |
# Error: Unexpected input occurred. |
|
435 |
# -2 |
|
436 |
# Error: Missing dependencies. |
|
437 |
# |
|
385 | 438 |
function wipeAmiroLld { |
386 | 439 |
printInfo "reset and wipe Git submodule $amirollddir\n" |
387 | 440 |
local userdir=$(pwd) |
388 | 441 |
local peripheryllddir=$(dirname $(realpath ${BASH_SOURCE[0]})) |
389 | 442 |
local amirollddir=${peripheryllddir}/AMiRo-LLD |
390 | 443 |
|
444 |
# check dependencies |
|
445 |
checkCommands git |
|
446 |
if [ $? -ne 0 ]; then |
|
447 |
printError "Missing dependencies detected.\n" |
|
448 |
return -2 |
|
449 |
fi |
|
450 |
|
|
391 | 451 |
# if the AMiRo-LLD folder is empty |
392 | 452 |
if [ -z "$(ls -A $amirollddir)" ]; then |
393 | 453 |
printWarning "$amirollddir is already empty\n" |
Also available in: Unified diff