instalar Winbox bajo Linux (Ubuntu, Fedora o Mint, entro otros)

He aquí un script de instalación de Winbox para Linux.

El script soporta  Debian, Ubuntu,  Linux Mint, Kali Linux, Fedora, RHEL, CentOS, IGOS Nusantara y Elemantary OS.

El mismo instala Wine y/o actualiza (del depósito de distribución) a una versión más nueva (solo para Fedora, RHEL, CentOS, IGN). Además crea una entrada de menú en el iniciador de aplicaciones.

La versión que toma de Winbox es la última que se baja de de https://mikrotik.com/download.

Para ejecturar la instalación de Winbox bajo el Linux

Solo debe ejecutar el siguiente script de la siguiente forma:

 

sudo bash ./winbox-setup install

El script es el siguiente copielo  y péguelo en un archivo en su Linux

#! /bin/sh
# Winbox Installer
# Wrritten by Mohammad Riza Nurtam <muhammadriza@gmail.com>
# version=0.3
# winbox_version=3.11

# Print error messages and defining error status with non-zero value
errMsg() {
  echo "USAGE:
To install
sudo bash winbox-setup install

To remove
sudo bash winbox-setup remove"
  exit 1
}

# Installing dependencies
depInst() {
  DISTRIBUTION=`sed "/^ID/s/ID=//gp" -n /etc/os-release`
  echo -n "Installing dependencies..."
  case $DISTRIBUTION in
    'fedora' | '"rhel"' | '"centos"' | '"IGN"' )
      dnf -q -y install wine wget > /dev/null 2>&1
      echo "DONE"
    ;;
    'ubuntu' | 'debian' | '"elementary"' | 'linuxmint' | 'kali' )
      apt-get -q -y install wine wget > /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 [[ $(ls -al | grep winbox.exe) ]]
  then
    echo "Using previously downloaded winbox.exe"
  else
    echo -n "Downloading Winbox..."
    URL="http:"$(curl -s https://mikrotik.com/download | grep -o //.*winbox.exe)
    URLlenght=${#URL}
    if [[ $URLlenght<60 ]]; then
      echo "FAILED"
      exit 1
    else
      wget -q -c -O winbox.exe $URL
      echo "DONE"
    fi
  fi
}

filesCp() {
  echo -n "Copying files..."
  if [[ !$(mkdir -p /opt/winbox) ]]
  then
    if [[ !$(cp -f winbox.exe /opt/winbox/winbox.exe) ]]
    then
      cp -f icons/winbox-128x128.png /usr/share/icons/hicolor/128x128/apps/winbox.png
      cp -f icons/winbox-16x16.png /usr/share/icons/hicolor/16x16/apps/winbox.png
      cp -f icons/winbox-192x192.png /usr/share/icons/hicolor/192x192/apps/winbox.png
      cp -f icons/winbox-20x20.png /usr/share/icons/hicolor/20x20/apps/winbox.png
      cp -f icons/winbox-22x22.png /usr/share/icons/hicolor/22x22/apps/winbox.png
      cp -f icons/winbox-24x24.png /usr/share/icons/hicolor/24x24/apps/winbox.png
      cp -f icons/winbox-256x256.png /usr/share/icons/hicolor/256x256/apps/winbox.png
      cp -f icons/winbox-32x32.png /usr/share/icons/hicolor/32x32/apps/winbox.png
      cp -f icons/winbox-36x36.png /usr/share/icons/hicolor/36x36/apps/winbox.png
      cp -f icons/winbox-40x40.png /usr/share/icons/hicolor/40x40/apps/winbox.png
      cp -f icons/winbox-48x48.png /usr/share/icons/hicolor/48x48/apps/winbox.png
      cp -f icons/winbox-64x64.png /usr/share/icons/hicolor/64x64/apps/winbox.png
      cp -f icons/winbox-72x72.png /usr/share/icons/hicolor/72x72/apps/winbox.png
      cp -f icons/winbox-8x8.png /usr/share/icons/hicolor/8x8/apps/winbox.png
      cp -f icons/winbox-96x96.png /usr/share/icons/hicolor/96x96/apps/winbox.png
      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/winbox.desktop
  then
    echo "[Desktop Entry]" > /usr/share/applications/winbox.desktop
    echo "Name=Winbox" >> /usr/share/applications/winbox.desktop
    echo "GenericName=Configuration tool for RouterOS" >> /usr/share/applications/winbox.desktop
    echo "Comment=Configuration tool for RouterOS" >> /usr/share/applications/winbox.desktop
    echo "Exec=wine /opt/winbox/winbox.exe" >> /usr/share/applications/winbox.desktop
    echo "Icon=winbox" >> /usr/share/applications/winbox.desktop
    echo "Terminal=false" >> /usr/share/applications/winbox.desktop
    echo "Type=Application" >> /usr/share/applications/winbox.desktop
    echo "StartupNotify=true" >> /usr/share/applications/winbox.desktop
    echo "Categories=Network;RemoteAccess;" >> /usr/share/applications/winbox.desktop
    echo "Keywords=winbox;mikrotik;" >> /usr/share/applications/winbox.desktop
    echo "DONE"
  else
    echo "FAILED"
    exit 1
  fi
}

filesRm() {
  echo -n "Removing launcher..."
  find /usr/share/applications/ -name "winbox.desktop" -delete
  echo "DONE"

  echo -n "Removing icons..."
  find /usr/share/icons -name "winbox.png" -delete
  echo "DONE"

  echo -n "Removing files..."
  rm -rf /opt/winbox/
  echo "DONE"
}

if [ -z "$1" ]; then
  errMsg;
fi
case $1 in
  'install' )
    depInst
    if wbDl
    then
      if filesCp
      then
        lncCrt
      else
        echo "FAILED"
        exit 1
      fi
    else
      echo "FAILED"
      exit 1
    fi
  ;;

  'remove' )
    filesRm
  ;;

  * )
    errMsg
  ;;
esac

Para que se incorpore los iconos al menu debe bajar y extraer en el mismo directorio el siguiente conjunto de imagenes. icons.tar

Opcional

Un paso opcional para escritorios basado en GTK, si el icono no está cargado o cargado con un tamaño incorrecto, podría actualizar el caché de iconos con este comando: gtk-update-icon-cache -f -t /usr/share/icons/hicolor

Para Removerlo

Si quieres eliminar Winbox, simplemente ejecuta este comando:

sudo bash ./winbox-setup remove

O

sudo bash ./winbox-setup remove

 

Avatar
Carlos Dagorret
CTO Facultad de Ciencias Económicas

My research interests include distributed robotics, mobile computing and programmable matter.

comments powered by Disqus