forked from enesbcs/shellyteacher4domo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreinstall.sh
executable file
·125 lines (125 loc) · 2.63 KB
/
preinstall.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/bash
echo "ShellyTeacher dependency solver"
echo "-------------------------------"
DISPLAY=`printenv DISPLAY`
if [ -z `command -v command` ]
then
echo "Command not found!"
exit
fi
_SUDO=`command -v sudo`
_SYSTEM=""
_ROOT=""
if [ "$(id -u)" -eq 0 ]; then
_ROOT="y"
fi
if [ ! -z `command -v apt-get` ]
then
_SYSTEM="apt-get"
elif [ ! -z `command -v pacman` ]
then
_SYSTEM="pacman"
elif [ ! -z `command -v apk` ]
then
_SYSTEM="apk"
else
echo "Not supported system!"
exit
fi
echo "If you are not root, the system may now ask root password several times. (You may consider to use sudo)"
if [ "$_SYSTEM" = "apt-get" ]
then
if [ ! -z "$_SUDO" ]
then
_SYSTEM="sudo $_SYSTEM"
fi
if [ -z "$_SUDO" ] && [ -z "$_ROOT" ]; then
su - root -c "$_SYSTEM update ; $_SYSTEM install -y python3 python3-pip python3-venv"
if [ ! -z "$DISPLAY" ]
then
su - root -c "$_SYSTEM install -y python3-tk"
fi
else
$_SYSTEM update
$_SYSTEM install -y python3 python3-pip python3-venv
if [ ! -z "$DISPLAY" ]
then
$_SYSTEM install -y python3-tk
fi
fi
fi
if [ "$_SYSTEM" = "pacman" ]
then
if [ ! -z "$_SUDO" ]
then
_SYSTEM="sudo $_SYSTEM"
fi
if [ -z "$_SUDO" ] && [ -z "$_ROOT" ]; then
su - root -c "echo -ne '\n' | $_SYSTEM -S python python-pip"
if [ ! -z "$DISPLAY" ]
then
su - root -c "echo -ne '\n' | $_SYSTEM -S tk"
fi
else
echo -ne '\n' | $_SYSTEM -S python python-pip
if [ ! -z "$DISPLAY" ]
then
echo -ne '\n' | $_SYSTEM -S tk
fi
fi
fi
if [ "$_SYSTEM" = "apk" ]
then
_SED="sed"
if [ ! -z "$_SUDO" ]
then
_SYSTEM="sudo $_SYSTEM"
_SED="sudo sed"
fi
if [ -z "$_SUDO" ] && [ -z "$_ROOT" ]; then
su - root -c "$_SED -i '/community/s/^#//' /etc/apk/repositories"
su - root -c "$_SYSTEM update ; $_SYSTEM add python3 py3-pip"
if [ ! -z "$DISPLAY" ]
then
su - root -c "$_SYSTEM add python3-tkinter"
fi
else
$_SED -i '/community/s/^#//' /etc/apk/repositories
$_SYSTEM update
$_SYSTEM add python3 py3-pip
if [ ! -z "$DISPLAY" ]
then
$_SYSTEM add python3-tkinter
fi
fi
fi
if [ ! -z `command -v python3` ]
then
_PYTHON="python3"
elif [ ! -z `command -v python` ]
then
_PYTHON="python"
else
_PYTHON=""
fi
if [ ! -z `command -v pip3` ]
then
_PIP="pip3"
elif [ ! -z `command -v pip` ]
then
_PIP="pip"
else
_PIP=""
echo "Pip not found, something went really badly!"
exit
fi
if [ ! -z "$_PYTHON" ]
then
$_PYTHON -m venv paho
source paho/bin/activate
$_PIP install paho-mqtt
else
echo "Python3 not found, something went really badly!"
exit
fi
echo "Installation ended for current user, try to run shellyteacher with venv using: ./run.sh"