-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
51 lines (41 loc) · 1.01 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
49
50
51
#!/bin/bash
# Setup paths
SHELLPER="shellper.sh"
# First argument can be branch name, default is "master"
BRANCH=${1:-master}
# Setup URL
URL="https://raw.githubusercontent.com/carmelosantana/shellper/$BRANCH/$SHELLPER"
# If curl is installed check if branch is valid
if command -v curl >/dev/null 2>&1; then
# Check if branch is valid
if ! curl -s -o /dev/null -I -w "%{http_code}" $URL | grep -q "200"; then
echo "Branch $BRANCH does not exist."
exit 1
else
curl -s -o "$SHELLPER" "$URL"
fi
else
# Download shellper
wget -q $URL
fi
# Check if file was downloaded
if [ ! -f "$SHELLPER" ]; then
echo "Failed to download shellper."
exit 1
fi
# Check + install dependencies
for install in "rlwrap"; do
if ! command -v "$install" >/dev/null 2>&1; then
apt update
apt install -y "$install"
fi
done
# Set permissions
chmod +x "$SHELLPER"
# Install
mv "$SHELLPER" /usr/local/bin/shellper
# We're done
echo -n "Install complete."
echo
# Clean exit
exit 0