forked from NauelG/supremo-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsupremo-setup
executable file
·200 lines (182 loc) · 5.14 KB
/
supremo-setup
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
195
196
197
198
199
200
#! /bin/bash
# Supremo Installer
# What this script does:
# 1. Downloading wine, wget and unzip, if not installed on the system
# 2. Downloading supremo from official download page
# 3. Copying supremo to /usr/local/bin/ directory
# 4. Copying icons to /usr/share/icons/hicolor/*/apps
# 5. Creating launcher for Supremo
# 6. Creating service to auto-start Supremo
#
# Written by Mohammad Riza Nurtam <muhammadriza@gmail.com>
# Adapted by Nauel Gomez <g.nauel@gmail.com> for Supremo remote control software
#
# Supremo version: 4.0.5.2299
#
# Print error messages and defining error status with non-zero value
errMsg() {
echo "USAGE:
To install
sudo bash supremo-setup install
To remove
sudo bash supremo-setup remove"
exit 1
}
# Installing dependencies
depInst() {
DISTRIBUTION=`sed "/^ID/s/ID=//gp" -n /etc/os-release`
echo -n "Wine is not installed. Installing wine and dependencies..."
case $DISTRIBUTION in
'fedora' | '"rhel"' | '"centos"' | '"IGN"' )
dnf -q -y install wine wget curl > /dev/null 2>&1 || yum -q -y install wine wget curl > /dev/null 2>&1
echo "DONE"
;;
'ubuntu' | 'debian' | '"elementary"' | 'zorin' | 'linuxmint' | 'kali' | 'neon' )
if [ -f /etc/os-release ]
then
source /etc/os-release
fi
if [ $(echo $VERSION_ID | awk '{printf "%1.0f",$1}') -ge 18 ]
then
WINEPKG="wine-stable"
else
WINEPKG="wine"
fi
apt-get -q -y install $WINEPKG wget curl > /dev/null 2>&1
echo "DONE"
;;
'arch' )
sed -i "/\[multilib\]/,/Include/"'s/^#//' /etc/pacman.conf
pacman -Sy
pacman -Sq --noconfirm wine wget curl > /dev/null 2>&1
echo "DONE"
;;
*)
echo "FAILED"
exit 1
;;
esac
}
# Downloading latest version of Winbox from Mikrotik's website.
# The URL of the file is parsed from https://mikrotik.com/download
wbDl() {
if [[ -f supremo.exe ]]
then
echo "Using previously downloaded supremo.exe"
echo "Delete file supremo.exe to force download the latest version"
else
echo -n "Downloading Supremo... "
URL="https://www.supremocontrol.com/download.aspx?file=Supremo.exe&id_sw=7&ws=supremocontrol.com"
wget -q -c -O supremo.exe $URL
echo "DONE"
fi
}
filesCp() {
echo -n "Copying files... "
if [[ !$(mkdir -p /usr/local/bin) ]]
then
if [[ !$(cp -f supremo.exe /usr/local/bin/supremo.exe) ]]
then
cp -f Supremo.sh /usr/local/bin/supremo.sh
chmod a+x /usr/local/bin/supremo.sh
chmod a+x /usr/local/bin/supremo.exe
for size in $( ls -1 icons/supremo-*.png | cut -d\- -f2 | cut -d\. -f1 | paste -sd ' ') ; do
mkdir -p /usr/share/icons/hicolor/${size}/apps/
cp -f icons/supremo-${size}.png /usr/share/icons/hicolor/${size}/apps/supremo.png
done
echo "DONE"
else
echo "FAILED"
exit 1
fi
else
echo "FAILED"
exit 1
fi
}
lncCrt() {
echo -n "Creating application launcher... "
if touch /usr/share/applications/supremo.desktop
then
echo "[Desktop Entry]" > /usr/share/applications/supremo.desktop
echo "Name=Supremo" >> /usr/share/applications/supremo.desktop
echo "GenericName=Remote Control Software" >> /usr/share/applications/supremo.desktop
echo "Comment=Remote Control Software" >> /usr/share/applications/supremo.desktop
echo "Exec=/usr/local/bin/supremo.sh" >> /usr/share/applications/supremo.desktop
echo "Icon=supremo" >> /usr/share/applications/supremo.desktop
echo "Terminal=false" >> /usr/share/applications/supremo.desktop
echo "Type=Application" >> /usr/share/applications/supremo.desktop
echo "StartupNotify=true" >> /usr/share/applications/supremo.desktop
echo "StartupWMClass=Supremo.exe" >> /usr/share/applications/supremo.desktop
echo "Categories=Network;RemoteAccess;" >> /usr/share/applications/supremo.desktop
echo "Keywords=supremo;" >> /usr/share/applications/supremo.desktop
xdg-desktop-menu forceupdate --mode system
echo "DONE"
else
echo "FAILED"
exit 1
fi
}
srvAnsw() {
echo "Do you want to autostart Supremo on user login?"
select yn in "Yes" "No"; do
case $yn in
Yes ) srvCrt; exit;;
No ) exit;;
esac
done
}
srvCrt() {
echo -n "Creating application autostart... "
if cp /usr/share/applications/supremo.desktop /home/$SUDO_USER/.config/autostart/supremo.desktop
then
echo "DONE"
else
echo "FAILED"
exit 1
fi
}
filesRm() {
echo -n "Removing launcher... "
find /usr/share/applications/ -name "supremo.desktop" -delete
echo "DONE"
echo -n "Removing icons... "
find /usr/share/icons -name "supremo.png" -delete
echo "DONE"
echo -n "Removing files... "
rm -rf /usr/local/bin/supremo.exe
rm -rf /usr/local/bin/supremo.sh
rm -rf /home/$SUDO_USER/.config/autostart/supremo.desktop
echo "DONE"
}
if [ -z "$1" ]; then
errMsg;
fi
case $1 in
'install' )
if [[ ! $(wine --version) ]]
then
depInst
fi
if wbDl
then
if filesCp
then
lncCrt
srvAnsw
else
echo "FAILED"
exit 1
fi
else
echo "FAILED"
exit 1
fi
;;
'remove' )
filesRm
;;
* )
errMsg
;;
esac