wip: further cleanup

This commit is contained in:
Andrejus
2021-04-16 00:26:07 +01:00
parent 18689abd73
commit e5223a45db
48 changed files with 405 additions and 361 deletions

View File

@@ -1,18 +1,26 @@
#!/usr/bin/env bash
set -eo pipefail
TIME=${TIME:-`date`}
UUID=${UUID:-`uuidgen`}
HOST=${HOST:-`hostname`}
#
# Script that installs system dependencies specified in a config,
# and runs all post-install scripts contained in a subdirectory.
#
NAME=`basename "$0"`
REL_DIR=`dirname "$0"`
ABS_DIR=`readlink -f $REL_DIR/../` # Scripts are nested inside of /scripts
TIME=${TIME:-$(date)}
UUID=${UUID:-$(uuidgen)}
HOST=${HOST:-$(hostname)}
LOG_DIR="$ABS_DIR/logs"
mkdir -p $LOG_DIR
LOG_TARGET=${LOG_TARGET:-$LOG_DIR/$UUID.log}
NAME=$(basename "$0")
REL_DIR=$(dirname "$0")
ABS_DIR=$(readlink -f $REL_DIR/../) # Scripts are nested inside of /scripts
UTILS="${REL_DIR}/_utils.sh"
CONFIG="${REL_DIR}/install_config.json"
INSTALL_DIR="${REL_DIR}/install.d"
LOG_DIR="${ABS_DIR}/logs"
mkdir -p "$LOG_DIR"
LOG_TARGET=${LOG_TARGET:-"${LOG_DIR}/${UUID}.log"}
main() {
echo "Running $NAME at $TIME"
@@ -24,31 +32,38 @@ main() {
exit 1
fi
echo "Loading utils"
source $REL_DIR/_utils.sh
apt_update
echo "Installing jq..."
apt_install jq
echo "Installing apt dependencies..."
for dep in `jq -r ".apt_dependencies[]" $ABS_DIR/config.json`; do
apt_install $dep
# Load installer dependencies
source "$UTILS"
update
install jq
for dep in $(jq -r ".apt_core_dependencies[]" "$CONFIG"); do
install "$dep"
done
figlet -c "bootstrapping..."
$ABS_DIR/scripts/bootstrap.sh
source $HOME/.profile
# Add apt repositories
for i in $(jq ".apt_repositories | keys | .[]" "$CONFIG"); do
value=$(jq -r ".apt_repositories[$i]" "$CONFIG")
add_repository "$value"
done
update
figlet -c "installing..."
export INSTALL_DIR="$REL_DIR/install"
# Install apt dependencies
for dep in $(jq -r ".apt_dependencies[]" "$CONFIG"); do
install "$dep"
done
# Install dotfiles on system and load them
figlet -c "Bootstrapping..."
$ABS_DIR/scripts/bootstrap.sh
source "$HOME/.profile"
# Run custom installer scripts
figlet -c "Installing..."
for script in $INSTALL_DIR/*.sh; do
figlet -c `basename $script`
figlet -c "$(basename $script)"
source $script
done
}
echo "main: Logging to $LOG_TARGET"
main 2>&1 |tee $LOG_TARGET
main 2>&1 | tee "$LOG_TARGET"