SHA256
1
0

Add scripts to role

This commit is contained in:
2026-01-29 01:06:09 -05:00
parent 62c413d42d
commit b5e082e400
23 changed files with 8 additions and 23 deletions

29
roles/scripts/common/extract Executable file
View File

@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Automatically decompresses most filetypes
extract() {
local a
[[ $# -eq 0 ]] && { echo "usage: extract <archive...>" >&2; return 1; }
for a in "$@"; do
[[ ! -f $a ]] && { echo "$a: not a file" >&2; continue; }
case $a in
*.tar.*|*.tgz|*.tbz2) tar xvf "$a" --auto-compress ;;
*.tar) tar xvf "$a" ;;
*.gz) gunzip "$a" ;;
*.bz2) bunzip2 "$a" ;;
*.xz) unxz "$a" ;;
*.zst) unzstd "$a" ;;
*.zip) unzip "$a" ;;
*.rar) unrar x "$a" ;;
*.7z) 7z x "$a" ;;
*.Z) uncompress "$a" ;;
*) echo "$a: cannot extract" ;;
esac
done
}
# Allow script to be safely sourced
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
extract "$@"
exit
fi