-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall_stable.sh
executable file
·59 lines (48 loc) · 1.3 KB
/
install_stable.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
52
53
54
55
56
57
58
59
#!/bin/bash
set -e
# Set default command to download archive from
DOWNLOAD_CMD="wget -q"
# Set default install prefix to /usr
PREFIX="${PREFIX:-/usr}"
# Check if the user is root
if [ "$(id -u)" -ne 0 ]
then
echo -e "\e[31mPlease run as root!\e[0m" > /dev/stderr
exit
fi
# Check for unzip and wget
echo -e "Testing for unzip..."
if ! command -v unzip &> /dev/null
then
echo -e "\e[31munzip not installed!\e[0m" > /dev/stderr
exit
fi
echo -e "Testing for wget..."
if ! command -v wget &> /dev/null
then
echo -e "\e[31mwget not installed, defaulting to curl!\e[0m" > /dev/stderr
DOWNLOAD_CMD="curl -O -L -J -s"
if ! command -v curl &> /dev/null
then
echo -e "\e[31mcurl not installed!\e[0m" > /dev/stderr
exit
fi
fi
cd /tmp
# If the directory exists, delete it
if [ -d "arithmetica-tui-install" ]; then
rm -rf arithmetica-tui-install
fi
mkdir arithmetica-tui-install
cd arithmetica-tui-install
# Download the latest release
$DOWNLOAD_CMD https://github.com/avighnac/arithmetica-tui/releases/latest/download/arithmetica.out
echo "Sucessfully downloaded the latest release."
# Copy the executable to /usr/bin/arithmetica
chmod +x arithmetica.out
cp arithmetica.out $PREFIX/bin/arithmetica
echo "Copied successfully!"
# Delete the temporary directory
cd ..
rm -rf arithmetica-tui-install
exit 0