-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·35 lines (28 loc) · 1.09 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
TARGET=$HOME/.local/bin/gigachat
mkdir -p $HOME/.local/bin
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
if [ "$1" == "-b" ]; then
git pull
echo "Building..."
./gradlew nativeBuild --info
cp ./build/native/nativeCompile/gigachat $TARGET
else
VERSION=$( curl -I https://github.com/owpk/gigachat-grpc-client/releases/latest | awk -F '/' '/^location/ {print substr($NF, 1, length($NF)-1)}' )
LAST_VER=$( gigachat -v )
echo "Latest version: $VERSION"
echo "Current version: $LAST_VER"
if [[ -z "$LAST_VER" || $(version $VERSION) -gt $(version $LAST_VER) ]]; then
rm $TARGET 2> /dev/null
echo "------"
echo "Found newest version!: $VERSION"
echo "------"
echo "Downloading..."
PLATFORM=$(uname -m)
REDIRECT=$( curl -I "https://github.com/owpk/gigachat-grpc-client/releases/download/$VERSION/gigachat-$PLATFORM" \
| awk '/^location/ {print $2}' | sed -e 's/\n//g' | sed -e 's/\r//g')
curl $REDIRECT --output $TARGET
chmod +x $TARGET
exit 0
fi
fi