-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·48 lines (37 loc) · 1.18 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
set -e
set -u
VERSION="v0.2.1"
REPOSITORY="https://github.com/mateussouzaweb/compactor"
BINARY="$REPOSITORY/releases/download/$VERSION/compactor"
BINARIES="/usr/local/bin"
# Switch to user local binaries if available
if [ -d "$HOME/.local/bin" ]; then
BINARIES="$HOME/.local/bin"
fi
# Make sure binaries path works
export PATH="$PATH:$BINARIES"
# Start install
echo "[INFO] Installing compactor and dependencies..."
# Install dependencies
if [[ $(node -v) == "" ]]; then
echo "[INFO] Installing NodeJS and NPM..."
apt install -y nodejs npm
fi
if [[ $(/sbin/ldconfig -p | grep libjpeg) == "" ]]; then
echo "[INFO] Installing libjpeg..."
apt install -y libjpeg-progs
fi
# Install NPM packages
PKGS=( gifsicle jpegoptim-bin cwebp-bin optipng-bin sass terser typescript svgo html-minifier rollup )
INSTALLED=$(npm list -g)
echo "[INFO] Checking NPM packages..."
for PKG in "${PKGS[@]}"; do
echo $INSTALLED | grep "$PKG" || npm install -s -g "$PKG"
echo "[INFO] $PKG - OK"
done
# Install compactor
echo "[INFO] Downloading compactor..."
wget -q $BINARY -O $BINARIES/compactor
chmod +x $BINARIES/compactor
echo "[INFO] Compactor ${VERSION} installed at $BINARIES/compactor"