73 lines
1.9 KiB
Bash
Executable File
73 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
#### Variables
|
|
WINBOX_SH="/usr/local/bin/winbox.sh"
|
|
WINBOX_EXE="/usr/local/bin/winbox.exe"
|
|
WINBOX_DESKTOP="/usr/share/applications/winbox.desktop"
|
|
|
|
#### Functions
|
|
check_root() {
|
|
if [ "$EUID" -ne 0 ]; then
|
|
echo "Must be root to run $0"
|
|
exit
|
|
fi
|
|
}
|
|
|
|
check_progs() {
|
|
if [ -z "$(which wget)" ]; then
|
|
echo -n "Installing wget..."
|
|
apt-get -q -y install wget >/dev/null 2>&1
|
|
echo "DONE"
|
|
fi
|
|
|
|
if [ -z "$(which wine)" ]; then
|
|
echo -n "Installing wine..."
|
|
apt-get -q -y install wine >/dev/null 2>&1
|
|
echo "DONE"
|
|
fi
|
|
}
|
|
|
|
prepare_winebox() {
|
|
echo -n "Download winbox..."
|
|
wget -q -O - https://mt.lv/winbox64 >$WINBOX_EXE
|
|
chmod a+x $WINBOX_EXE
|
|
echo "DONE"
|
|
|
|
echo -n "Create winbox.sh..."
|
|
echo "#!/bin/bash" >$WINBOX_SH
|
|
echo "wine "$WINBOX_EXE >>$WINBOX_SH
|
|
chmod a+x $WINBOX_SH
|
|
echo "DONE"
|
|
}
|
|
|
|
addIcons() {
|
|
for size in $(ls -1 icons/winbox-*.png | cut -d\- -f2 | cut -d\. -f1 | paste -sd ' '); do
|
|
mkdir -p /usr/share/icons/hicolor/${size}/apps/
|
|
cp -f icons/winbox-${size}.png /usr/share/icons/hicolor/${size}/apps/winbox.png
|
|
done
|
|
}
|
|
|
|
createMenu() {
|
|
echo -n "Creating application launcher..."
|
|
echo "[Desktop Entry]" >$WINBOX_DESKTOP
|
|
echo "Name=Winbox" >>$WINBOX_DESKTOP
|
|
echo "GenericName=Configuration tool for RouterOS" >>$WINBOX_DESKTOP
|
|
echo "Comment=Configuration tool for RouterOS" >>$WINBOX_DESKTOP
|
|
echo "Exec="$WINBOX_SH >>$WINBOX_DESKTOP
|
|
echo "Icon=winbox" >>$WINBOX_DESKTOP
|
|
echo "Terminal=false" >>$WINBOX_DESKTOP
|
|
echo "Type=Application" >>$WINBOX_DESKTOP
|
|
echo "StartupNotify=true" >>$WINBOX_DESKTOP
|
|
echo "StartupWMClass=winbox.exe" >>$WINBOX_DESKTOP
|
|
echo "Categories=Network;RemoteAccess;" >>$WINBOX_DESKTOP
|
|
echo "Keywords=winbox;mikrotik;" >>$WINBOX_DESKTOP
|
|
xdg-desktop-menu forceupdate --mode system
|
|
echo "DONE"
|
|
}
|
|
|
|
check_root
|
|
check_progs
|
|
prepare_winebox
|
|
addIcons
|
|
createMenu
|