-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.sh
30 lines (27 loc) · 1.25 KB
/
main.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
PACKAGE_VERSION=$(node -p -e "try { require('./nitro-sniper/package.json').version } catch { '0.0.0' }")
LATEST_VERSION=$(curl --silent "https://raw.githubusercontent.com/slow-fork/nitro-sniper/main/package.json" | grep '"version":' | sed -E 's/.*"([^"]+)".*/\1/')
function compareVersions {
echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }';
}
function installAll() {
echo "$(tput setaf 6)Installing packages, please wait..."
install-pkg "http://archive.ubuntu.com/ubuntu/pool/main/g/glib2.0/libglib2.0-0_2.56.4-0ubuntu0.18.04.8_amd64.deb" &> /dev/null
echo "$(tput setaf 2)Installed dependencies."
echo "$(tput setaf 6)Cloning the latest sniper code..."
cd ..
rm -rf nitro-sniper &> /dev/null
git clone https://github.com/slow-fork/nitro-sniper nitro-sniper &> /dev/null
cd nitro-sniper
echo "$(tput setaf 2)Cloned latest version of the sniper."
echo "$(tput setaf 6)Installing sniper dependencies..."
npm install &> /dev/null
echo "$(tput setaf 2)Installed sniper dependencies."
echo "$(tput setaf 2)Running sniper..."
npx node ./src/index.js
}
cd nitro-sniper
if [ $(compareVersions $PACKAGE_VERSION) -lt $(compareVersions $LATEST_VERSION) ] || [ ! -d "node_modules" ]; then
installAll
else
npx node ./src/index.js
fi