storj/scripts/utils.sh
Bryan White 7257079c67
Waitlist script (#573)
* bash refactoring

* add storj.sh and user.sh

* reformat/refactor

* formatting

* fix typo
2018-11-06 18:43:20 +01:00

65 lines
816 B
Bash

#!/usr/bin/env bash
dots() {
echo -n "."
sleep 1
dots
}
dots_on() {
dots &
dots_pid=$!
}
dots_off() {
disown $dots_pid
kill "$dots_pid"
}
build() {
local tmp_dir=$1
shift
echo "building temp binaries:"
for cmd in $@; do
echo -n " building $cmd..."
dots_on
local path=${tmp_dir}/${cmd}
declare -g ${cmd}=${path}
go build -o ${path} storj.io/storj/cmd/${cmd}
dots_off
echo "done"
done
echo " binaries built in $tmp_dir"
}
temp_build() {
tmp_dir=$(mktemp -d)
build ${tmp_dir} $@
}
check_help() {
if [ $1 == "--help" ] || [ $1 == "-h" ]; then
echo $2
exit 0
fi
}
ensure_dir() {
if [ ! -d $1 ]; then
mkdir $1
fi
}
no_overwrite() {
if [ -e $1 ]; then
echo "Error: $1 already exists; refusing to overwrite"
exit 10
fi
}
log_list() {
for f in $@; do
echo ${f}
done
}