In this section I describe how to install Entware on a router (Asus RT-AC56U).
Firstly almost all Asus routers come with a built-in Optware package manager. This package manager is outdated, all packages are not updated anymore. For this reason, a new package manager (Entware) has been created in order to replace Optware. Unfortunately Entware and Optware share some libraries, so we cannot install them at the same time. Some features of Asus routers are not compatible with Entware packages, for example "Media Server", "Asus AiCloud" and "Download Master". Until these packages are built-in in the router, they are still available, while if they are installed into an external drive, they must work only with Optware as they are not compatible with Entware (we cannot mix the libraries of Entware with the libraries of Optware). While "Media Server" and "Download Master" may be replaced with some Entware's packages (for example respectively with "Minidlna" and "Transmission"), "Asus AiCloud" cannot be directly replaced, so we have to consider this matter before upgrading to Entware.
The first step of upgrading to Entware is to install a router's built-in package, for example "Download Master". We use an external drive (for example USB Pendrive), we format it using ext2/ext3 file system, we insert it into router's USB socket, and we install "Download Master". After doing this, we uninstall "Download Master" (we don't need it anymore). In this way the router has created a folder into the external drive, this folder name depends on the router we are using (for example for RT-AC56U this folder is named "asusware.arm"). After doing this, we open Telnet, we go to "/opt" folder and we delete all files included in that folder, except the file ".asusrouter" as this file is used by the router to mount the "/opt" folder. Now the "/opt" folder is empty (again, except the file ".asusrouter"), so we can install Entware. To do this, we have to download this script. This is a sample content of the above-mentioned script:
#!/bin/sh echo "Info: Checking for prerequisites and creating folders..." if [ -d /opt ] then echo "Warning: Folder /opt exists!" else mkdir /opt fi for folder in bin etc/init.d lib/opkg sbin share tmp usr var/log var/lock var/run do if [ -d "/opt/$folder" ] then echo "Warning: Folder /opt/$folder exists!" echo "Warning: If something goes wrong please clean /opt folder and try again." else mkdir -p /opt/$folder fi done echo "Info: Opkg package manager deployment..." CURARCH="armv7" DLOADER="ld-linux.so.3" URL=http://pkg.entware.net/binaries/$CURARCH/installer wget $URL/opkg -O /opt/bin/opkg chmod +x /opt/bin/opkg wget $URL/opkg.conf -O /opt/etc/opkg.conf wget $URL/ld-2.23.so -O /opt/lib/ld-2.23.so wget $URL/libc-2.23.so -O/opt/lib/libc-2.23.so wget $URL/libgcc_s.so.1.2.23 -O /opt/lib/libgcc_s.so.1 cd /opt/lib chmod +x ld-2.23.so ln -s ld-2.23.so $DLOADER ln -s libc-2.23.so libc.so.6 echo "Info: Basic packages installation..." /opt/bin/opkg update /opt/bin/opkg install entware-opt if [ ! -f /opt/usr/lib/locale/locale-archive ] then wget http://pkg.entware.net/binaries/other/locale-archive.2.23 -O /opt/usr/lib/locale/locale-archive fi echo "Info: Congratulations!" echo "Info: If there are no errors above then Entware-ng was successfully initialized." echo "Info: Add /opt/bin & /opt/sbin to your PATH variable" echo "Info: Add '/opt/etc/init.d/rc.unslung start' to startup script for Entware-ng services to start" echo "Info: Found a Bug? Please report at https://github.com/Entware-ng/Entware-ng/issues"
After download the above-mentioned script, we have to execute it. This is a sample output of above-mentioned script:
root@RT-AC56U:/tmp# ./entware-install.sh Info: Checking for prerequisites and creating folders... Warning: Folder /opt exists! Warning: If something goes wrong please clean /opt folder and try again. Info: Opkg package manager deployment... Connecting to pkg.entware.net (18.104.22.168:80) opkg 100% |**************************| 124k 0:00:00 ETA Connecting to pkg.entware.net (22.214.171.124:80) opkg.conf 100% |**************************| 142 0:00:00 ETA Connecting to pkg.entware.net (126.96.36.199:80) ld-2.23.so 100% |**************************| 139k 0:00:00 ETA Connecting to pkg.entware.net (188.8.131.52:80) libc-2.23.so 100% |**************************| 1198k 0:00:00 ETA Connecting to pkg.entware.net (184.108.40.206:80) libgcc_s.so.1 100% |**************************| 39632 0:00:00 ETA Info: Basic packages installation... Downloading http://pkg.entware.net/binaries/armv7/Packages.gz. Updated list of available packages in /opt/var/opkg-lists/packages. Installing entware-opt (222108-5) to root... Downloading http://pkg.entware.net/binaries/armv7/entware-opt_222108-5_armv7soft.ipk. Installing libc (2.23-6) to root... Downloading http://pkg.entware.net/binaries/armv7/libc_2.23-6_armv7soft.ipk. Installing libgcc (6.3.0-6) to root... Downloading http://pkg.entware.net/binaries/armv7/libgcc_6.3.0-6_armv7soft.ipk. Installing libssp (6.3.0-6) to root... Downloading http://pkg.entware.net/binaries/armv7/libssp_6.3.0-6_armv7soft.ipk. Installing librt (2.23-6) to root... Downloading http://pkg.entware.net/binaries/armv7/librt_2.23-6_armv7soft.ipk. Installing libpthread (2.23-6) to root... Downloading http://pkg.entware.net/binaries/armv7/libpthread_2.23-6_armv7soft.ipk. Installing libstdcpp (6.3.0-6) to root... Downloading http://pkg.entware.net/binaries/armv7/libstdcpp_6.3.0-6_armv7soft.ipk. Installing ldconfig (2.23-6) to root... Downloading http://pkg.entware.net/binaries/armv7/ldconfig_2.23-6_armv7soft.ipk. Installing findutils (4.6.0-1) to root... Downloading http://pkg.entware.net/binaries/armv7/findutils_4.6.0-1_armv7soft.ipk. Installing terminfo (6.0-1c) to root... Downloading http://pkg.entware.net/binaries/armv7/terminfo_6.0-1c_armv7soft.ipk. Installing locales (2.23-6) to root... Downloading http://pkg.entware.net/binaries/armv7/locales_2.23-6_armv7soft.ipk. Installing opkg (2011-04-08-9c97d5ec-17) to root... Downloading http://pkg.entware.net/binaries/armv7/opkg_2011-04-08-9c97d5ec-17_armv7soft.ipk. Configuring libgcc. Configuring libc. Configuring libssp. Configuring libpthread. Configuring librt. Configuring terminfo. Configuring ldconfig. Configuring locales. Entware uses separate locale-archive file independent from main system Creating locale archive - /opt/usr/lib/locale/locale-archive Adding en_EN.UTF-8 Adding ru_RU.UTF-8 You can download locale sources from http://pkg.entware.net/sources/i18n_glib223.tar.gz You can add new locales to Entware using /opt/bin/localedef.new Configuring opkg. Configuring libstdcpp. Configuring findutils. Configuring entware-opt. Updating /opt/etc/ld.so.cache... done. Info: Congratulations! Info: If there are no errors above then Entware-ng was successfully initialized. Info: Add /opt/bin & /opt/sbin to your PATH variable Info: Add '/opt/etc/init.d/rc.unslung start' to startup script for Entware-ng services to start Info: Found a Bug? Please report at https://github.com/Entware-ng/Entware-ng/issues
We can use the command "opkg --help" to see if we have
properly installed Entware on the router.
If we give a look to above-mentioned output, we note the line "Info: Add /opt/bin & /opt/sbin to your PATH variable". We do not need to add these folders to the PATH variable as these folders are automatically added into PATH variable by the router whenever "/opt" folder is mounted. We also note the line "Info: Add '/opt/etc/init.d/rc.unslung start' to startup script for Entware-ng services to start". We consider this line if we want to execute a script whenever we insert the USB external drive. Normally on Asus router the services are automatically enabled due to some features of Optware, these features allow to execute services included in folder "/opt/etc/init.d". Unfortunately with Entware we have to use another way to automatically execute a script after mounting the "/opt" folder. We are lucky to see that router included a "nvram" key in order to automatically execute a script. This key is named "script_usbmount", normally this key is empty. For example if we want to use the script "/opt/etc/autorun.sh", we have to write the following commands:
nvram set script_usbmount=/opt/etc/autorun.sh
To check the above-command, we have to write:
nvram show | grep -i autorun.sh
Inside the above-mentioned script file "autorun.sh" we can enable services (remember that services' scripts are in folder "/opt/etc/init.d") or execute other scripts or commands.
There is another "nvram" key called "script_usbumount", this key is similar to the above-mentioned key "script_usbmount" but its value is used before the USB external drive is to be unmounted, in this way we can stop services or execute other scripts or commands before removing the USB external drive.
After installing Entware, we can install all the packages we need, for example if we want to install "Nano" editor, we can use the command "opkg install nano". Note that the command for Entware is "opkg", while we used "ipkg" command for Optware. The syntax of "opkg" command is similar to the syntax of "ipkg" command, so we do not need to start over.
To update all packages we will use the two commands "opkg update" and "opkg upgrade" (the first command updates the Internet source of packages, the second one upgrades only the updated packages). We need to take care about the upgrade of packages, because it is happened to me in the past that some configurations files (changed by me) were overwritten by the default configuration files. My suggestion is to make a backup of all "/opt" folder before upgrading the packages (but also periodically in order to have a backup copy of Entware installation whenever we need to restore some files).
Another my suggestion is to use the parameter "--noaction" with the command "opkg upgrade", in this way we may see a simulation (testing) of the upgrading procedure, just to know in advance which packages will be upgraded, which files will be overwritten and if there is something we have to do in advance in order to have a full-functional Entware environment after upgrading the packages.
This is a sample output of command "opkg update":
root@RT-AC56U:/tmp# opkg update Downloading http://pkg.entware.net/binaries/armv7/Packages.gz Updated list of available packages in /opt/var/opkg-lists/packages
This is a sample output of command "opkg --help":
root@RT-AC56U:/tmp# opkg --help usage: opkg [options...] sub-command [arguments...] where sub-command is one of: Package Manipulation: update Update list of available packages upgrade Upgrade installed packages install <pkgs> Install package(s) configure <pkgs> Configure unpacked package(s) remove <pkgs|regexp> Remove package(s) flag <flag> <pkgs> Flag package(s) <flag>=hold|noprune|user|ok|installed|unpacked (one per invocation) Informational Commands: list List available packages list-installed List installed packages list-upgradable List installed and upgradable packages list-changed-conffiles List user modified configuration files files <pkg> List files belonging to <pkg> search <file|regexp> List package providing <file> find <regexp> List packages whose name or description matches <regexp> info [pkg|regexp] Display all info for <pkg> status [pkg|regexp] Display all status for <pkg> download <pkg> Download <pkg> to current directory compare-versions <v1> <op> <v2> compare versions using <= < > >= = << >> print-architecture List installable package architectures depends [-A] [pkgname|pat]+ whatdepends [-A] [pkgname|pat]+ whatdependsrec [-A] [pkgname|pat]+ whatrecommends[-A] [pkgname|pat]+ whatsuggests[-A] [pkgname|pat]+ whatprovides [-A] [pkgname|pat]+ whatconflicts [-A] [pkgname|pat]+ whatreplaces [-A] [pkgname|pat]+ Options: -A Query all packages not just those installed -V[<level>] Set verbosity level to <level>. --verbosity[=<level>] Verbosity levels: 0 errors only 1 normal messages (default) 2 informative messages 3 debug 4 debug level 2 -f <conf_file> Use <conf_file> as the opkg configuration file --conf <conf_file> --cache <directory> Use a package cache -d <dest_name> Use <dest_name> as the the root directory for --dest <dest_name> package installation, removal, upgrading. <dest_name> should be a defined dest name from the configuration file, (but can also be a directory name in a pinch). -o <dir> Use <dir> as the root directory for --offline-root <dir> offline installation of packages. --add-arch <arch>:<prio> Register architecture with given priority --add-dest <name>:<path> Register destination with given path Force Options: --force-depends Install/remove despite failed dependencies --force-maintainer Overwrite preexisting config files --force-reinstall Reinstall package(s) --force-overwrite Overwrite files from other package(s) --force-downgrade Allow opkg to downgrade packages --force-space Disable free space checks --force-postinstall Run postinstall scripts even in offline mode --force-remove Remove package even if prerm script fails --force-checksum Don't fail on checksum mismatches --noaction No action -- test only --download-only No action -- download only --nodeps Do not follow dependencies --nocase Perform case insensitive pattern matching --size Print package size when listing available packages --force-removal-of-dependent-packages Remove package and all dependencies --autoremove Remove packages that were installed automatically to satisfy dependencies -t Specify tmp-dir. --tmp-dir Specify tmp-dir. -l Specify lists-dir. --lists-dir Specify lists-dir. regexp could be something like 'pkgname*' '*file*' or similar e.g. opkg info 'libstd*' or opkg search '*libop*' or opkg remove 'libncur*'