tori/tori

74 lines
1.5 KiB
Bash
Executable file

#! /usr/bin/env sh
main() {
# paths
VERSION="0.5.0 2024-07-18"
TORI_ROOT="$HOME/.local/share/tori"
CONFIG_ROOT="$HOME/.config/tori"
TMP_DIR="/tmp/tori"
CACHE_DIR="$HOME/.cache/tori"
# os-independent state
DEBUG=$DEBUG
DEBUG_DISABLED_WARNING=
## user input
argument="$1"
parameter="$2"
# import source
check_core_paths
. "$TORI_ROOT/src/index.sh"
set_opts on
## os-dependent state
OS="$(get_operating_system)"
PACKAGE_CACHE="$CACHE_DIR/${OS}_packages.cache"
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
}
main "$1" "$2"