truecharts generalization
This commit is contained in:
parent
07a1eff21d
commit
71e8da7289
|
@ -1,6 +1,26 @@
|
|||
if [[ -x "/mnt/szmedia/_apps.data/_scripts/truetool/truetool.sh" ]]; then
|
||||
[[ -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 /mnt/szmedia/_apps.data/_scripts/truetool > /dev/null
|
||||
pushd ${truenas_scriptspath}/truetool > /dev/null
|
||||
sudo ./truetool.sh "${@}"
|
||||
popd > /dev/null
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
SOURCE=${BASH_SOURCE[0]}
|
||||
while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
|
||||
SOURCE=$(readlink "$SOURCE")
|
||||
[[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
|
||||
|
||||
[[ -r "$DIR/01_util.functions" ]] && . "$DIR/01_util.functions" || {
|
||||
[[ -r ~/.sz.shrc.d/01_util.functions ]] && . ~/.sz.shrc.d/01_util.functions
|
||||
}
|
||||
[[ -z "$(type -t require_root)" ]] && (>&2 printf '\E[31mERROR:\E[0m %s\n' "Failed to load 01_util.functions" ) && exit 1
|
||||
|
||||
require_root
|
||||
|
||||
error "This is an error"
|
Loading…
Reference in New Issue