56 lines
1.3 KiB
Bash
Executable file
56 lines
1.3 KiB
Bash
Executable file
#!/bin/bash -e
|
|
|
|
export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
|
|
|
|
export BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
export IMG_NAME='BarnacleOS'
|
|
export USERNAME='user'
|
|
export PASSWORD='password'
|
|
|
|
export DEPLOY_DIR="$BASE_DIR/deploy"
|
|
export ROOTFS_DIR="$BASE_DIR/rootfs"
|
|
export KEYS_DIR="$BASE_DIR/keys"
|
|
export FILES_DIR="$BASE_DIR/files"
|
|
|
|
export IMG_DATE="$(date +%Y-%m-%d)"
|
|
|
|
export IMG_FILE="$DEPLOY_DIR/$IMG_NAME-${IMG_DATE}.img"
|
|
|
|
# dependencies_check
|
|
# $@ Dependnecy files to check
|
|
#
|
|
# Each dependency is in the form of a tool to test for, optionally followed by
|
|
# a : and the name of a package if the package on a Debian-ish system is not
|
|
# named for the tool (i.e., qemu-user-static).
|
|
dependencies_check() {
|
|
local missing
|
|
|
|
if [[ -f "$1" ]]; then
|
|
for dep in $(cat "$1"); do
|
|
if ! hash ${dep%:*} 2>/dev/null; then
|
|
missing="${missing:+$missing }${dep#*:}"
|
|
fi
|
|
done
|
|
fi
|
|
|
|
if [[ "$missing" ]]; then
|
|
tput setaf 1 # Red color
|
|
echo 'Reqired dependencies not installed.'
|
|
echo 'This can be resolved on Debian/Raspbian systems by installing the following packages:'
|
|
for package_name in $missing; do
|
|
echo " * $package_name"
|
|
done
|
|
tput sgr0 # No color
|
|
|
|
false
|
|
fi
|
|
}
|
|
|
|
dependencies_check "$BASE_DIR/depends"
|
|
|
|
cd "$BASE_DIR"
|
|
|
|
mkdir -p "$DEPLOY_DIR"
|
|
|
|
exec bash -e $@
|