Create a deploypkg.zsh command

For installing a package created through makepkg onto a remote machine

Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
Anna Schumaker 2021-11-29 17:02:55 -05:00
parent f4a1f40eff
commit 8a73ed3a61
3 changed files with 40 additions and 0 deletions

21
colors/pacman.py Normal file
View File

@ -0,0 +1,21 @@
import termcolor
import re
import sys
pacman_colors = dict()
pacman_attrs = dict()
def add_color_attr(field, color, *attrs):
pacman_colors[field] = color
pacman_attrs[field] = attrs
add_color_attr("==>", "green", "bold")
add_color_attr("->", "blue", "bold")
for line in sys.stdin:
if "==>" in line or "->" in line:
for part in re.split(r'(\s+)', line):
color = pacman_colors.get(part, "white")
attrs = pacman_attrs.get(part, ["bold"])
termcolor.cprint(part, color, attrs=attrs, end="")

View File

@ -0,0 +1,9 @@
#compdef deploypkg.zsh
function _deploypkg.zsh() {
_arguments \
'1:package:_files -g "**/*.pkg.tar.*"' \
':destination: _alternative
"hosts:hosts: _ssh_hosts"
"domains:domains:($(virsh list --all --name))"'
}

10
deploypkg.zsh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/zsh
if [ "$#" -ne 2 ]; then
echo "Usage: $0 /path/to/package {libvirt VM}"
exit 1
fi
ssh.zsh $2 "mkdir -p pkg"
scp $1 $2:pkg/
ssh.zsh $2 "sudo pacman --noconfirm -U pkg/$(basename $1)" | python /home/anna/bin/colors/pacman.py