Skip to content

Commit 0bda319

Browse files
committed
First tests and fixes for linux
1 parent 5e08da5 commit 0bda319

File tree

1 file changed

+42
-34
lines changed

1 file changed

+42
-34
lines changed

install.sh

+42-34
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,28 @@
11
#!/bin/bash
22

3-
if [ "$EUID" -ne 0 ]
4-
then echo "[x] Root privileges required!"
5-
exit
6-
fi
7-
8-
PROGRAMNAME=""
9-
DEVELOPERNAME=""
10-
SHORTPROGRAMNAME=""
11-
12-
echo "Welcome to the $PROGRAMNAME installer
13-
14-
By using this software you must agree all below terms:
15-
1) By using this software, it's the end user’s responsibility to obey all applicable local, state and federal laws.
16-
2) The software is provided \"as is\", without warranty of any kind, express or implied.
17-
3) $DEVELOPERNAME isn't responsible for any damage caused by this software.
18-
19-
[?] If you agree, press [Enter] to procede:"
20-
read junk
21-
22-
if [ "$(uname)" == "Darwin" ]; then
23-
install_python_mac()
24-
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
25-
install_python_linux()
26-
else
27-
echo "[x] Only MacOS and Linux operating system are supported."
28-
fi
29-
303
install_python_mac () {
314
if ! command -v brew >/dev/null; then
325
echo "[x] Brew package manager not installed."
6+
exit
337
fi
348

35-
if ! brew list -1 | grep -q "python@3"; then
9+
brew list | grep "python@3.*" > /dev/null 2>&1
10+
if [ $? -ne 0 ]; then
3611
echo "[*] Installing python interpreter on the system..."
3712
if ! brew install -y "python3" > /dev/null 2>&1; then
3813
echo "[x] Cannot install python via brew."
14+
exit
3915
fi
16+
else
17+
echo "[*] The python interpreter is already installed."
4018
fi
4119
}
4220

4321
install_python_linux () {
4422
if command -v apt-get >/dev/null; then
45-
install_python_apt()
23+
install_python_apt
4624
elif command -v yum >/dev/null; then
47-
install_python_yum()
25+
install_python_yum
4826
else
4927
echo "[x] Neither apt not yum found as package manager."
5028
exit
@@ -53,24 +31,54 @@ install_python_linux () {
5331

5432
install_python_apt () {
5533
if [ $(dpkg-query -W -f='${Status}' python3 > /dev/null 2>&1 | grep -c "ok installed") -eq 0 ]; then
56-
# Python3 not installed on the system, just install it!
5734
echo "[*] Installing python interpreter on the system..."
5835
apt update > /dev/null 2>&1;
5936
apt install python3 > /dev/null 2>&1;
6037
fi
6138
}
6239

63-
# Install python requirements
40+
install_python_yum () {
41+
if ! yum list installed python3 &>/dev/null; then
42+
echo "[*] Installing python interpreter on the system..."
43+
yum install -y python3 > /dev/null 2>&1;
44+
fi
45+
}
46+
47+
# if [ "$EUID" -ne 0 ]
48+
# then echo "[x] Root privileges required!"
49+
# exit
50+
# fi
51+
52+
PROGRAMNAME=""
53+
DEVELOPERNAME=""
54+
SHORTPROGRAMNAME=""
55+
56+
echo "Welcome to the $PROGRAMNAME installer
57+
58+
By using this software you must agree all below terms:
59+
1) By using this software, it's the end user’s responsibility to obey all applicable local, state and federal laws.
60+
2) The software is provided \"as is\", without warranty of any kind, express or implied.
61+
3) $DEVELOPERNAME isn't responsible for any damage caused by this software.
62+
63+
[?] If you agree, press [Enter] to procede:"
64+
read junk
65+
66+
if [ "$(uname)" == "Darwin" ]; then
67+
install_python_mac
68+
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
69+
install_python_linux
70+
else
71+
echo "[x] Only MacOS and Linux operating system are supported."
72+
fi
73+
6474
echo "[*] Installing python requirements..."
6575
pip3 install -r requirements.txt > /dev/null 2>&1;
6676

67-
# Install the script in the opt directory
6877
echo "[*] Installing the software..."
6978
mkdir /opt/$SHORTPROGRAMNAME > /dev/null 2>&1;
7079
cp src/$SHORTPROGRAMNAME.py /opt/$SHORTPROGRAMNAME > /dev/null 2>&1;
7180
chmod +x /opt/$SHORTPROGRAMNAME/$SHORTPROGRAMNAME.py > /dev/null 2>&1;
7281

73-
# Create the command for the shell
7482
echo "[*] Setting up the environment..."
7583
ln -s /opt/$SHORTPROGRAMNAME/$SHORTPROGRAMNAME.py /usr/bin/$SHORTPROGRAMNAME > /dev/null 2>&1;
7684

0 commit comments

Comments
 (0)