dotfiles.2022/_home/dot_sz.shrc.d/42_truecharts

41 lines
1.4 KiB
Plaintext

[[ -r /etc/apt/sources.list ]] \
&& ixsystems_system=$(cat /etc/apt/sources.list | grep '^deb https\?://apt\.tn\.ixsystems\.com' | wc -l) \
&& [[ $ixsystems_system -lt 11 ]] \
&& unset ixsystems_system
if [[ -n "$ixsystems_system" ]]; then
if ! [[ -r /tmp/truenas_scriptpath ]]; then
/sbin/zpool list -Ho name | \
grep -v 'boot-pool' | \
while read pool; do
/sbin/zfs list -rHo name $pool | \
grep "^$pool/[a-z\._]*data/_\?scripts"
done | \
while read dataset; do
/sbin/zfs list -Ho mountpoint $dataset
done > /tmp/truenas_scriptpath
fi
truenas_scriptspath=$(cat /tmp/truenas_scriptpath)
fi
if [[ -n "$truenas_scriptspath" && -x "${truenas_scriptspath}/truetool/truetool.sh" ]]; then
function truetool() {
pushd ${truenas_scriptspath}/truetool > /dev/null
sudo ./truetool.sh "${@}"
popd > /dev/null
}
function truedcx() {
docker exec -it $(docker ps --filter "name=$1" -q) $2
}
function true-docker-id() {
docker ps --filter "name=$1" -q
}
function true-hostname() {
local ID=$(true-docker-id $1)
local autoHostname=$(docker inspect --format="{{ .Config.Hostname }}" $ID)
local contIP=$(docker exec $ID cat /etc/hosts | grep $autoHostname | awk '{print $1}')
docker exec $ID nslookup $contIP | tail +4 | sed 's/^[0-9]\+.*name = [-0-9]\+\.//'
}
fi