Compare commits
2 commits
67de45f5ba
...
019acbcb45
Author | SHA1 | Date | |
---|---|---|---|
019acbcb45 | |||
5f650f7d17 |
5 changed files with 55 additions and 9 deletions
|
@ -1,3 +1,4 @@
|
|||
0.7.0 2024-09-13: Imperative commands install, uninstall, track and forget
|
||||
0.6.0 2024-09-03: File management with the tree strategy
|
||||
File backups
|
||||
Extract authorization command to top level
|
||||
|
|
|
@ -14,6 +14,7 @@ package_manager() {
|
|||
if [ "$OS" = "FreeBSD" ]; then
|
||||
manager="pkg"
|
||||
args__get_manually_installed='query -e "%a = 0" "%n"'
|
||||
args__get_status='' # TODO
|
||||
args__install='install'
|
||||
args__uninstall='delete'
|
||||
args__update='update'
|
||||
|
@ -23,6 +24,8 @@ package_manager() {
|
|||
# shellcheck disable=SC2086
|
||||
if [ "$command" = 'get_manually_installed' ]; then
|
||||
eval $manager "$args__get_manually_installed"
|
||||
elif [ "$command" = 'get_status' ]; then
|
||||
echo unimplemented: eval $manager "$args__get_status" # TODO
|
||||
elif [ "$command" = 'install' ]; then
|
||||
$AUTHORIZE_COMMAND $manager $args__install $args__user_args
|
||||
elif [ "$command" = 'uninstall' ]; then
|
||||
|
|
|
@ -1,8 +1,26 @@
|
|||
# functions to track, untrack and query tracked state of packages
|
||||
|
||||
# returns 0 if all packages are tracked, 1 if any is untracked
|
||||
query_packages() {
|
||||
local packages="$1"
|
||||
|
||||
echo "$packages" | xargs | sed 's/ /\n/g' | while read -r package; do
|
||||
if ! cat "$CONFIG_ROOT/packages" | grep -q "^$package$"; then
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
done
|
||||
}
|
||||
|
||||
track_packages() {
|
||||
local packages="$1"
|
||||
|
||||
echo "$packages" | xargs | sed 's/ /\n/g' | while read -r package; do
|
||||
echo "$package" >> "$CONFIG_ROOT/packages"
|
||||
if query_packages "$package"; then
|
||||
log info "Package $package was not tracked because it is already tracked"
|
||||
else
|
||||
echo "$package" >> "$CONFIG_ROOT/packages"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
|
|
@ -149,9 +149,13 @@ prepare_directories() {
|
|||
}
|
||||
|
||||
print_help() {
|
||||
printf "\n tori: configuration managent and system replication tool\n"
|
||||
printf "\n tori: configuration management and system replication tool\n"
|
||||
printf "\n Options:\n\n"
|
||||
printf "\tcheck\t\tcompare configuration to system state\n"
|
||||
printf "\tinstall\t\tinstall packages\n"
|
||||
printf "\tuninstall\tuninstall packages\n"
|
||||
printf "\ttrack\t\tadd a file to your configuration\n"
|
||||
printf "\tforget\t\tremove a file from your configuration\n"
|
||||
printf "\tcache\t\trefresh the local package cache\n"
|
||||
printf "\n"
|
||||
printf "\tversion\t\tprint current version with release date\n"
|
||||
|
|
34
tori
34
tori
|
@ -2,7 +2,7 @@
|
|||
|
||||
main() {
|
||||
# paths
|
||||
VERSION="0.6.0 2024-09-03"
|
||||
VERSION="0.7.0 2024-09-13"
|
||||
TORI_ROOT="$HOME/.local/share/tori"
|
||||
CONFIG_ROOT="$HOME/.config/tori"
|
||||
BACKUP_ROOT="$HOME/.local/state/tori/backup"
|
||||
|
@ -15,8 +15,8 @@ main() {
|
|||
DEBUG_DISABLED_WARNING=
|
||||
|
||||
## user input
|
||||
argument="$1"
|
||||
parameter="$2"
|
||||
command="$1"
|
||||
argument="$2"
|
||||
|
||||
# import source
|
||||
check_core_paths
|
||||
|
@ -38,13 +38,33 @@ main() {
|
|||
|
||||
# entry point
|
||||
|
||||
if [ "$argument" = check ]; then
|
||||
if [ "$command" = check ] || [ "$command" = c ]; then
|
||||
check
|
||||
elif [ "$argument" = cache ]; then
|
||||
elif [ "$command" = install ] || [ "$command" = i ]; then
|
||||
if package_manager install "$argument"; then
|
||||
track_packages "$argument"
|
||||
else
|
||||
log warn "Package installation failed for $argument, no action taken"
|
||||
fi
|
||||
elif [ "$command" = uninstall ] || [ "$command" = u ]; then
|
||||
if package_manager uninstall "$argument"; then
|
||||
if package_manager; then
|
||||
log warn "Package uninstallation failed for $argument, no action taken"
|
||||
else
|
||||
untrack_packages "$argument"
|
||||
fi
|
||||
else
|
||||
log warn "Package uninstallation failed for $argument, no action taken"
|
||||
fi
|
||||
elif [ "$command" = track ] || [ "$command" = t ]; then
|
||||
echo unimplemented: track "$argument" # TODO
|
||||
elif [ "$command" = forget ] || [ "$command" = f ]; then
|
||||
echo unimplemented: untrack "$argument" # TODO
|
||||
elif [ "$command" = cache ]; then
|
||||
update_package_cache --force
|
||||
elif [ "$argument" = version ] || [ "$argument" = -v ] || [ "$argument" = --version ]; then
|
||||
elif [ "$command" = version ] || [ "$command" = -v ] || [ "$command" = --version ]; then
|
||||
echo "$VERSION"
|
||||
elif [ "$argument" = help ] || [ "$argument" = -h ] || [ "$argument" = --help ]; then
|
||||
elif [ "$command" = help ] || [ "$command" = -h ] || [ "$command" = --help ]; then
|
||||
print_help
|
||||
else
|
||||
echo "Use 'tori help' for usage instructions"
|
||||
|
|
Loading…
Reference in a new issue