Archive : Add support for remote unarchive.
This commit is contained in:
parent
3801872c05
commit
044360be1a
|
@ -1,3 +1,6 @@
|
|||
{ const, ... }: {
|
||||
users.users.root.hashedPassword = const.hashedPassword;
|
||||
# security.sudo.extraConfig = ''
|
||||
# Defaults rootpw
|
||||
# '';
|
||||
}
|
||||
|
|
|
@ -234,13 +234,23 @@ function unarchive() {
|
|||
# Validate.
|
||||
# _archive_check "${target}" || return 1
|
||||
|
||||
# Remote archives.
|
||||
local remote
|
||||
local file="${target}"
|
||||
|
||||
if [[ "${target//\\:/}" == *:* ]]; then
|
||||
local host="${target%%:*}"
|
||||
file="${target#*:}"
|
||||
remote=("sudo" "ssh" "${host}")
|
||||
fi
|
||||
|
||||
# Extract.
|
||||
case "${target##*.}" in
|
||||
case "${file##*.}" in
|
||||
"txz")
|
||||
pv ${target} | xz -d | tar -xf -
|
||||
${remote[@]} pv ${file} | xz -d | tar -xf -
|
||||
;;
|
||||
"tgz")
|
||||
pv ${target} | gzip -d | tar -xf -
|
||||
${remote[@]} pv ${file} | gzip -d | tar -xf -
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
|
|
@ -2,17 +2,18 @@
|
|||
# Root by default.
|
||||
# Usage: s [USER]
|
||||
function s() {
|
||||
su - "${1}"
|
||||
su - ${1}
|
||||
}
|
||||
|
||||
# Run something as root.
|
||||
# Usage: sudo <COMMAND>
|
||||
function sudo() {
|
||||
su -c "${*}"
|
||||
su -c "$(echo ${*} | tr '\n' ' ')"
|
||||
}
|
||||
|
||||
function _complete_s() {
|
||||
_autocomplete "voronind" "dasha"
|
||||
}
|
||||
|
||||
complete -F _complete_s s
|
||||
complete -F _autocomplete_nested sudo
|
||||
|
|
Loading…
Reference in a new issue