1
1
#! /bin/bash
2
2
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
-
30
3
install_python_mac () {
31
4
if ! command -v brew > /dev/null; then
32
5
echo " [x] Brew package manager not installed."
6
+ exit
33
7
fi
34
8
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
36
11
echo " [*] Installing python interpreter on the system..."
37
12
if ! brew install -y " python3" > /dev/null 2>&1 ; then
38
13
echo " [x] Cannot install python via brew."
14
+ exit
39
15
fi
16
+ else
17
+ echo " [*] The python interpreter is already installed."
40
18
fi
41
19
}
42
20
43
21
install_python_linux () {
44
22
if command -v apt-get > /dev/null; then
45
- install_python_apt ()
23
+ install_python_apt
46
24
elif command -v yum > /dev/null; then
47
- install_python_yum ()
25
+ install_python_yum
48
26
else
49
27
echo " [x] Neither apt not yum found as package manager."
50
28
exit
@@ -53,24 +31,54 @@ install_python_linux () {
53
31
54
32
install_python_apt () {
55
33
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!
57
34
echo " [*] Installing python interpreter on the system..."
58
35
apt update > /dev/null 2>&1 ;
59
36
apt install python3 > /dev/null 2>&1 ;
60
37
fi
61
38
}
62
39
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
+
64
74
echo " [*] Installing python requirements..."
65
75
pip3 install -r requirements.txt > /dev/null 2>&1 ;
66
76
67
- # Install the script in the opt directory
68
77
echo " [*] Installing the software..."
69
78
mkdir /opt/$SHORTPROGRAMNAME > /dev/null 2>&1 ;
70
79
cp src/$SHORTPROGRAMNAME .py /opt/$SHORTPROGRAMNAME > /dev/null 2>&1 ;
71
80
chmod +x /opt/$SHORTPROGRAMNAME /$SHORTPROGRAMNAME .py > /dev/null 2>&1 ;
72
81
73
- # Create the command for the shell
74
82
echo " [*] Setting up the environment..."
75
83
ln -s /opt/$SHORTPROGRAMNAME /$SHORTPROGRAMNAME .py /usr/bin/$SHORTPROGRAMNAME > /dev/null 2>&1 ;
76
84
0 commit comments