-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·132 lines (116 loc) · 5.11 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
USERNAME=$SUDO_USER
GREEN='\033[0;32m'
NC='\033[0m'
DIR=`pwd`
set -e
help() {
echo "UBUVoiceAssistant installer"
echo "Available options:"
echo "\"install.sh install\" to install the program"
echo "\"install.sh install --manual\" to install without autocompleting Mycroft prompts"
echo "\"install.sh uninstall\" to remove the program"
echo "\"install.sh update-skills\" to update all the ubu-skills"
echo "\"install.sh update\" to update UBUVoiceAssistant and ubu-skills"
}
install() {
# Refresh system packages
printf "${GREEN}Updating system packages...${NC}\n"
apt-get update
printf "${GREEN}Finished updating system packages${NC}\n"
# Get python packages
printf "${GREEN}Installing system dependencies...${NC}\n"
apt-get install python3-pip python3-pyqt5 python3-pyqt5.qtwebengine git -y
pip3 install mycroft-messagebus-client babel bs4 fuzzywuzzy
sudo apt install libjack-dev libjack0 -y
printf "${GREEN}Finished installing system dependencies${NC}\n"
# Prepare user folder
sudo -u $USERNAME mkdir -p /home/${USERNAME}/.config/UBUVoiceAssistant
sudo -u $USERNAME mkdir -p /home/${USERNAME}/.mycroft
printf "${GREEN}Downloading Mycroft...${NC}\n"
mkdir -p /usr/lib/mycroft-core
chown $USERNAME /usr/lib/mycroft-core
cd /usr/lib/mycroft-core
sudo -u $USERNAME git clone https://github.com/MycroftAI/mycroft-core.git .
printf "${GREEN}Finished downloading Mycroft${NC}\n"
printf "${GREEN}Configuring Mycroft...${NC}\n"
if [[ -n $1 && $1 == "--manual" ]]; then
printf "${GREEN}A list of questions will be asked now to configure Mycroft. Answer by pressing Y in all of them.\n"
printf "Se van a hacer una serie de preguntas para configurar Mycroft. Responde a todas pulsando Y${NC}\n"
read -s -p "Press Enter to continue."
sudo -u $USERNAME bash dev_setup.sh -sm
else
echo -e YYYYYYYYYYY | sudo -u $USERNAME bash dev_setup.sh -sm
fi
printf "${GREEN}Finished configuring Mycroft${NC}\n"
# Copy UBU skills inside
printf "${GREEN}Installing UBU skills...${NC}\n"
cd $DIR
sudo -u $USERNAME /usr/lib/mycroft-core/bin/mycroft-msm install https://github.com/ubu-skills/ubu-messages
sudo -u $USERNAME /usr/lib/mycroft-core/bin/mycroft-msm install https://github.com/ubu-skills/ubu-grades
sudo -u $USERNAME /usr/lib/mycroft-core/bin/mycroft-msm install https://github.com/ubu-skills/ubu-course
sudo -u $USERNAME /usr/lib/mycroft-core/bin/mycroft-msm install https://github.com/ubu-skills/ubu-help
sudo -u $USERNAME /usr/lib/mycroft-core/bin/mycroft-msm install https://github.com/ubu-skills/ubu-calendar
printf "${GREEN}Installed UBU skills${NC}\n"
# Installing to a permanent location
printf "${GREEN}Installing to a permanent location...${NC}\n"
mkdir -p /usr/lib/UBUVoiceAssistant
echo "#!/bin/bash" > /usr/bin/UBUVoiceAssistant
echo "cd /usr/lib/UBUVoiceAssistant" >> /usr/bin/UBUVoiceAssistant
echo "QT_QUICK_BACKEND=\"software\" python3 -m UBUVoiceAssistant.GUI.main" >> /usr/bin/UBUVoiceAssistant
chmod a+x /usr/bin/UBUVoiceAssistant
chown $USERNAME /usr/lib/UBUVoiceAssistant
sudo -u $USERNAME cp -r ./src/UBUVoiceAssistant/ /usr/lib/UBUVoiceAssistant
printf "${GREEN}Installed to a permanent location${NC}\n"
# Create app launcher icon
printf "${GREEN}Creating app launcher icon...${NC}\n"
echo "[Desktop Entry]" > /usr/share/applications/UBUVoiceAssistant.desktop
echo "Type=Application" >> /usr/share/applications/UBUVoiceAssistant.desktop
echo "Name=UBUVoiceAssistant" >> /usr/share/applications/UBUVoiceAssistant.desktop
echo "Comment=UBUVoiceAssistant" >> /usr/share/applications/UBUVoiceAssistant.desktop
echo "Terminal=false" >> /usr/share/applications/UBUVoiceAssistant.desktop
echo "Exec=UBUVoiceAssistant" >> /usr/share/applications/UBUVoiceAssistant.desktop
echo "Icon=/usr/lib/UBUVoiceAssistant/UBUVoiceAssistant/imgs/appicon.png" >> /usr/share/applications/UBUVoiceAssistant.desktop
echo "Categories=Utility;Education;Accessibility;Qt;" >> /usr/share/applications/UBUVoiceAssistant.desktop
if [ -f /usr/bin/xdg-desktop-menu ]; then
xdg-desktop-menu forceupdate
fi
printf "${GREEN}Created app launcher icon${NC}\n"
printf "${GREEN}Install completed :)${NC}\n"
}
uninstall() {
rm -rf /usr/lib/UBUVoiceAssistant
rm -rf /usr/lib/mycroft-core
rm -f /usr/bin/UBUVoiceAssistant
rm -f /usr/share/applications/UBUVoiceAssistant.desktop
rm -rf /home/${USERNAME}/.mycroft
rm -rf /opt/mycroft
printf "${GREEN}UBUVoiceAssistant was uninstalled.${NC}\n"
}
updateskills() {
sudo -u $USERNAME /usr/lib/mycroft-core/bin/mycroft-msm update
}
updateall() {
rm -rf /usr/lib/UBUVoiceAssistant
mkdir -p /usr/lib/UBUVoiceAssistant
cp -r ./src/UBUVoiceAssistant/ /usr/lib/UBUVoiceAssistant
updateskills
}
if [[ -n $1 && $1 == "install" || $1 == "uninstall" || $1 == "update-skills" || $1 == "update" ]]; then
# Checking if the script was launched as root
if [ "$EUID" -ne 0 ]
then echo "Please, run again the script as sudo."
exit
fi
if [ $1 == "install" ]; then
install $2
elif [ $1 == "update-skills" ]; then
updateskills
elif [ $1 == "update" ]; then
updateall
else
uninstall
fi
else
help
fi