-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·194 lines (164 loc) · 3.98 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/bin/bash
source config/zymp3.conf
source lib/colors.sh
if [[ $EUID -ne 0 ]]; then
echo -e "$0 : ${LRED}This script must be run as root${NC}\n"
exit 1
fi
#List of cuntions to check dependencies (will re-work this later)
checkYoutubedl(){
if [ ! -f /usr/bin/youtube-dl ] && [ ! -f /usr/local/bin/youtube-dl ];then
false
else
true
fi
}
checkFfmpeg(){
if [ ! -f /usr/bin/ffmpeg ] && [ ! -f /usr/bin/avconv ];then
false
else
true
fi
}
checkZenity(){
if [ ! -f /usr/bin/zenity ];then
false
else
true
fi
}
checkYad(){
if [ ! -f /usr/bin/yad ];then
false
else
true
fi
}
checkXdg(){
if [ ! -f /usr/bin/xdg-open ];then
false
else
true
fi
}
checkNotify(){
if [ ! -f /usr/bin/notify-send ];then
false
else
true
fi
}
checkInstall(){
if [ ! -d ${INSTALLPATH} ];then
false
else
true
fi
}
echo "Checking dependencies...";echo
#Check the status of each function
#each variable contains a number based on exit status of each function
checkYoutubedl
if [ $? -eq "1" ];then
YSTATUS=0
echo -e "is youtube-dl installed?: ${LRED}no${NC} (Required)"
else
YSTATUS=1
echo -e "is youtube-dl installed?: ${LGREEN}yes${NC} (Required)"
fi
checkFfmpeg
if [ $? -eq "1" ];then
FSTATUS=0
echo -e "is ffmpeg installed?: ${LRED}no${NC} (Required)"
else
FSTATUS=1
echo -e "is ffmpeg installed?: ${LGREEN}yes${NC} (Required)"
fi
checkZenity
if [ $? -eq "1" ];then
ZSTATUS=0
echo -e "is zenity installed?: ${LRED}no${NC} (Required)"
else
ZSTATUS=1
echo -e "is zenity installed?: ${LGREEN}yes${NC} (Required)"
fi
checkYad
if [ $? -eq "1" ];then
YASTATUS=0
echo -e "is yad installed?: ${LRED}no${NC} (Optional)"
else
YASTATUS=1
echo -e "is yad installed?: ${LGREEN}yes${NC} (Optional)"
fi
checkXdg
if [ $? -eq "1" ];then
XSTATUS=0
echo -e "is xdg-utils installed?: ${LRED}no${NC} (Required)"
else
XSTATUS=1
echo -e "is xdg-utils installed?: ${LGREEN}yes${NC} (Required)"
fi
checkNotify
if [ $? -eq "1" ];then
NSTATUS=0
echo -e "is libnotify installed?: ${LRED}no${NC} (Optional)"
else
NSTATUS=1
echo -e "is libnotify installed?: ${LGREEN}yes${NC} (Optional)"
fi
checkInstall
if [ $? -eq "1" ];then
ISTATUS=0
echo -e "does ${INSTALLPATH} exist?: ${LRED}no${NC}"
else
ISTATUS=1
echo -e "does ${INSTALLPATH} exist?: ${LGREEN}yes${NC}"
fi
if [ ${ISTATUS} = 0 ];then
echo -n "${INSTALLPATH} does not exist, do you want to create it?[y/n]: "
read answer
if [ ${answer} = "y" ];then
mkdir -vp ${INSTALLPATH}
ISTATUS=1
else
echo "$0 : ERROR: could not create ${INSTALLPATH}"
fi
fi
#add all exit status variables and check the sum
#if a certain number is not reached, the check fails
#if the check succeeds, files are installed
ALLSTATUS=$(expr ${YSTATUS} + ${FSTATUS} + ${ZSTATUS} + ${XSTATUS} + ${ISTATUS})
if [ ${ALLSTATUS} != 5 ];then
echo "$0 : ERROR : not all dependencies installed!"
exit 0;
else
echo
echo -e "\e[92mEverything looks good!\033[0m"
echo
echo -n "Continue installation?[y/n]: "
read confirm
if [ "${confirm}" = "y" ];then
cp -v zymp3 ${INSTALLPATH}
cp -v -R lib ${INSTALLPATH}
cp -v -R config ${INSTALLPATH}
cp -v uninstall.sh ${INSTALLPATH}
cp -v assets/zymp3.png ${IMGDIR}
cp -v assets/zymp3.desktop ${DESKTOPFILEDIR}
echo '#!/bin/bash' > ${INSTALLPATH}/zymp3-run.sh
echo "cd ${INSTALLPATH}" >> ${INSTALLPATH}/zymp3-run.sh
echo "./zymp3" >> ${INSTALLPATH}/zymp3-run.sh
chmod -R 777 /opt/zymp3
mv ${INSTALLPATH}/zymp3-run.sh /usr/bin/zymp3
if [ ! -d ${INSTALLPATH} ];then
echo "Zymp3 not installed successfully"
echo "Please file a bug report at: https://github.com/silvernode/zymp3/issues"
else
echo "====================================================="
echo -e "\e[92mZymp3 successfully installed to: ${INSTALLPATH}\033[0m"
echo "An icon has been created in your application menu under the multimedia category."
fi
else
echo "Installation cancelled..."
exit 0;
fi
fi