-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.sh
28 lines (25 loc) · 1.17 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
PACKAGE_VERSION=$(node -p -e "try { require('./package.json').version } catch { '0.0.0' }")
LATEST_VERSION=$(curl --silent "https://raw.githubusercontent.com/marioparaschiv/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..."
git reset --hard HEAD
git pull
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
}
rm -rf settings.env
if [ $(compareVersions $PACKAGE_VERSION) -eq $(compareVersions $LATEST_VERSION) ] && [ -d "node_modules" ] && [ -d "node_modules/discord.js" ]; then
npx node ./src/index.js
else
installAll
fi