zapret/install_bin.sh

53 lines
1.1 KiB
Bash
Raw Normal View History

2019-05-02 09:48:37 +03:00
#!/bin/sh
SCRIPT=$(readlink -f "$0")
EXEDIR=$(dirname "$SCRIPT")
2019-05-02 10:22:47 +03:00
BINS=binaries
BINDIR=$EXEDIR/$BINS
2019-05-02 09:48:37 +03:00
check_dir()
{
2019-05-06 16:02:22 +03:00
echo 0.0.0.0 | "$BINDIR/$1/ip2net" 1>/dev/null 2>/dev/null
2019-05-02 09:48:37 +03:00
}
2019-05-02 10:22:47 +03:00
# link or copy executables. uncomment either ln or cp, comment other
2019-05-02 09:48:37 +03:00
ccp()
{
2019-05-06 16:02:22 +03:00
local F=$(basename $1)
[ -d "$EXEDIR/$2" ] || mkdir "$EXEDIR/$2"
[ -f "$EXEDIR/$2/$F" ] && rm -f "$EXEDIR/$2/$F"
ln -fs "../$BINS/$1" "$EXEDIR/$2" && echo linking : "../$BINS/$1" =\> "$EXEDIR/$2"
#cp -f "$BINDIR/$1" "$EXEDIR/$2" && echo copying : "$BINDIR/$1" =\> "$EXEDIR/$2"
2019-05-02 09:48:37 +03:00
}
ARCHLIST="my x86_64 x86 aarch64 armhf mips64r2-msb mips32r1-lsb mips32r1-msb ppc"
2019-05-02 09:48:37 +03:00
if [ "$1" = "getarch" ]; then
2019-05-06 16:02:22 +03:00
for arch in $ARCHLIST
do
[ -d "$BINDIR/$arch" ] || continue
2019-05-06 16:02:22 +03:00
if check_dir $arch; then
echo $arch
exit 0
2019-05-06 16:02:22 +03:00
fi
done
else
for arch in $ARCHLIST
do
[ -d "$BINDIR/$arch" ] || continue
2019-05-06 16:02:22 +03:00
if check_dir $arch; then
echo $arch is OK
echo installing binaries ...
ccp $arch/ip2net ip2net
ccp $arch/mdig mdig
ccp $arch/nfqws nfq
ccp $arch/tpws tpws
exit 0
2019-05-06 16:02:22 +03:00
else
echo $arch is NOT OK
fi
done
fi
exit 1