tori/tori

75 lines
1.5 KiB
Bash
Executable file

#! /usr/bin/env sh
main() {
# paths
VERSION="0.4.1 2024-07-14"
TORI_ROOT="$HOME/.local/share/tori"
CONFIG_ROOT="$HOME/.config/tori"
TMP_DIR="/tmp/tori"
CACHE_DIR="$HOME/.cache/tori"
check_core_paths
. "$TORI_ROOT/src/index.sh"
# state
DEBUG=$DEBUG
## user input
argument="$1"
parameter="$2"
set_opts -
## global constants
OS="$(get_operating_system)"
PACKAGE_CACHE="$CACHE_DIR/${OS}_packages.cache"
## global state
base_files=
bkp_files=
user_packages=
system_packages=
# startup checks
prepare_directories
# entry point
if [ "$argument" = check ]; then
check
elif [ "$argument" = cache ]; then
update_package_cache --force
elif [ "$argument" = version ] || [ "$argument" = -v ] || [ "$argument" = --version ]; then
echo "$VERSION"
elif [ "$argument" = help ] || [ "$argument" = -h ] || [ "$argument" = --help ]; then
print_help
else
echo "Use 'tori help' for usage instructions"
fi
}
check_core_paths() {
local tori_conf="$CONFIG_ROOT/tori.conf"
if [ -f "$tori_conf" ]; then
local tori_root_value
tori_root_value="$(grep -i '^tori_root' "$CONFIG_ROOT/tori.conf" \
| cut -d '=' -f 2 | xargs \
| sed "s*~*$HOME*" | sed "s*\$HOME*$HOME*g" \
)"
if [ -n "$tori_root_value" ]; then
TORI_ROOT="$tori_root_value"
fi
fi
if ! [ -f "$TORI_ROOT/src/index.sh" ]; then
echo "No valid tori installation found at $TORI_ROOT"
exit 1
fi
[ -n "$DEBUG" ] && echo "TORI_ROOT: $TORI_ROOT"
}
main "$1" "$2"