1
0
Files
dotfiles/.config/zsh/alias/openwrt.zsh
Konstantin Demin 48e93e48b6
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/manual/woodpecker Pipeline was successful
zsh: openwrt-related goodies
2025-07-13 21:09:51 +03:00

43 lines
1.2 KiB
Bash

#!/bin/zsh
openwrt-ssh() {
ssh -o GlobalKnownHostsFile=/dev/null -o UserKnownHostsFile=/dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no "$@"
}
openwrt-apk-list() {
(( ${+commands[openwrt-apk]} )) || {
echo 'missing "openwrt-apk"' >&2
return 127
}
local i w
w=$(mktemp -d) ; : "${w:?}"
for i ; do
[ -n "$i" ] || continue
find "$w/" -mindepth 1 -maxdepth 1 -exec rm -rf {} +
find "$w/" -mindepth 1 -maxdepth 1 -exec rm -rf {} + || return
openwrt-apk extract --no-cache --no-logfile --no-network --no-check-certificate --allow-untrusted --no-chown --destination "$w" "$i"
env -C "$w" find ./ -mindepth 1 -exec ls -ldgG --color {} +
done
rm -rf "$w"
}
openwrt-ipk-list() {
local i m o
for i ; do
[ -n "$i" ] || continue
o=0
for m ( './data.tar.gz' 'data.tar.gz' ) ; do
tar -tf "$i" "$m" 2>/dev/null || continue
o=1
env printf '%q:\n' "$i"
tar -Oxf "$i" "$m" | tar -ztvf -
break
done
if [ "$o" = '0' ] ; then
env printf '%q: missing data.tar.gz\n' "$i"
continue
fi
done
}