-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathinstall.sh
executable file
·118 lines (93 loc) · 3.37 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
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
#!/bin/bash
#
# Public domain.
#
#
# install.sh by Rafael Senties Martinelli.
#
# To the extent possible under law, the person who associated CC0 with
# install.sh has waived all copyright and related or neighboring rights
# to install.sh.
#
# You should have received a copy of the CC0 legalcode along with this
# work. If not, see <https://creativecommons.org/publicdomain/zero/1.0/>.
if [ "$EUID" -ne 0 ]
then echo -e "\e[00;31m The script must be run as root.\e[00m"
exit
fi
NUMBER_OF_STEPS=5 # installation steps
#
# Set the scripts permissions
#
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd "$DIR" || exit
chmod a+x ./remove
#
# Remove previous versions
#
echo -e "\e[00;33m[1/$NUMBER_OF_STEPS] Removing previous versions..\e[00m"
./remove
#
# Start the installation
#
echo -e "\e[00;33m\n[2/$NUMBER_OF_STEPS] Installing the software files...\e[00m"
function install_files(){
echo "installing: $1"
if [ -d "$DIR$1/__pycache__" ]; then
rm -rf "$DIR$1/__pycache__"
fi
install -d "$1" |& grep -v "omitting directory"
install -D "$DIR$1/"* "$1" |& grep -v "omitting directory"
}
install_files "/usr/bin"
install_files "/usr/share/applications"
install_files "/usr/share/AKBL"
install_files "/usr/share/AKBL/test"
install_files "/usr/share/AKBL/computers"
install_files "/usr/share/AKBL/GUI"
install_files "/usr/share/AKBL/GUI/ColorChooserToolbar"
install_files "/usr/share/AKBL/GUI/img"
install_files "/usr/share/AKBL/BlockTesting"
install_files "/usr/share/AKBL/Indicator"
install_files "/usr/share/AKBL/Indicator/img"
install_files "/usr/share/AKBL/ModelChooser"
install_files "/usr/share/doc/AKBL"
install_files "/usr/share/doc/AKBL/BusData"
install_files "/usr/share/doc/AKBL/BusData/Data"
install_files "/usr/share/doc/AKBL/ImagesPreview"
install_files "/usr/share/doc/AKBL/Licenses"
install_files "/usr/share/doc/AKBL/Programming"
install_files "/usr/share/doc/AKBL/Programming/class_diagrams"
install_files "/usr/lib/python3/AKBL"
install_files "/usr/lib/python3/AKBL/Engine"
install_files "/usr/lib/python3/AKBL/Computer"
install_files "/usr/lib/python3/AKBL/Theme"
install_files "/usr/lib/systemd/system"
chmod u=rw /usr/lib/systemd/system/akbl.service # The permissions must be forced.
chmod go=r /usr/lib/systemd/system/akbl.service # The permissions must be forced.
##
## Post installation
##
echo -e "\e[00;33m\n[3/$NUMBER_OF_STEPS] Creating the python links...\e[00m"
PYTHON_VERSIONS=($(ls /usr/lib/ | grep python3))
for python_version in "${PYTHON_VERSIONS[@]}"; do
if [[ "$python_version" != "python3" ]]; then
if [ -d "/usr/lib/$python_version" ]; then
ln -s /usr/lib/python3/AKBL "/usr/lib/$python_version/AKBL" && echo -e "linked $python_version"
fi
fi
done
echo -e "\e[00;33m\n[4/$NUMBER_OF_STEPS] Choosing the computer model...\e[00m"
python3 /usr/share/AKBL/ModelChooser/cmd.py
echo -e "\e[00;33m\n[5/$NUMBER_OF_STEPS] Enabling the daemon...\e[00m"
if [ -f /bin/systemctl ]; then
systemctl daemon-reload
systemctl enable akbl
systemctl restart akbl
sleep 2
ping=$(akbl --ping)
echo "AKBL ping... $ping"
else
echo -e "\e[00;31m Warning: systemd seems to be missing. The daemon will have to be manually launched.\e[00m"
fi
echo -e "\nThe installation has finished. If you have any window of the software (GUI, BlockTesting, Bindings script, etc..) or the indicator is running, you must restart them.\n"