autostart-manage/autoinstall/before.sh

31 lines
558 B
Bash
Raw Normal View History

2024-01-09 15:48:11 +00:00
#!/usr/bin/env bash
action=${action:?}
# if action is run or completions, do nothing
if [ "$action" = "run" ] || [ "$action" = "completions" ]
2024-01-09 15:48:11 +00:00
then
return
2024-01-09 15:48:11 +00:00
fi
clean=${args[--clean]:-}
target=${args[target]:?}
if [ "$action" = "exe" ]
2024-01-09 15:48:11 +00:00
then
target="$HOME/.local/bin/$target"
fi
if [ -n "$clean" ] || [ -n "${AUTOINSTALL_CLEAN:-}" ]
then
echo "Cleaning $target"
2024-03-22 21:14:13 +00:00
# sanity checks
if [ -z "$target" ] || [ "$target" = "/" ] || [ "$target" = "$HOME" ] || [ "$target" = "$HOME/" ]
then
echo "Invalid target: '$target'"
exit 1
fi
2024-01-09 15:48:11 +00:00
rm -rf "$target"
fi