Install Resilio-Sync into openwrt

Hi. There are some posts, including official one, related to this topic. But so far I searched, none of them are 100% up to date. After tested myself, here is the guide for installing Resilio-Sync into openwrt, today.

Preparation:

  • A router with at least 1GB free memory left after all services you required is on, with ~50MB left on the internal storage.
  • A dedicated USB drive, or an internal storage with enough space left. I use a 500 GB USB drive. When it’s done, more than 30 GB is used. But I guess most of them is for ext4 journal.
  • A tool to transfer file into openwrt like scp or any other with scp support.
  • Upgrade your openwrt to the latest.
  • Know the arch of your router chip, like armhf for the new, armel for those old, and arm64 for 64-bit enabled. Note: arm64 not only means your chip is 64-bit ready, but also working in 64-bit mode with your system supported.

Now let’s start.

Step 1: USB drive preparation

If you need to use internal storage, see Step 1A instead.

  1. Login to terminal. Web based TTYD Terminal or SSH are both fine.
  2. Check current device list by command
ls /dev/sd*

There shouldn’t be anything printed if no disk attached. Remember all reported.

  1. Attach your USB drive. Re-run the command above, you will notice that something more are added. Normally, they should be like /dev/sdX and /dev/sdXY. X is a letter, Y is a number. If this is the 1st drive found, the X should be a, /dev/sda for full. I will take /dev/sda for example in below. Change it into the correct one if it’s not.
  2. Use fdisk to initialize this disk. Command is
fdisk /dev/sda

First, use command p to check the current partitions. Use d to remove them one by one. Then use n to create a primary partition. If any sign is found when creating partition, you can remove it when asked. Finally, use w to save. If anything goes wrong, use q without w will quit fdisk without changes. If everything is right, you will see a /dev/sda1 which is the only numbered return by command ls /dev/sda*.

  1. Make ext4 file system on the /dev/sda1 with command
mkfs.ext4 /dev/sda1
  1. Reboot your router with the USB drive attached. Go back to terminal.
  2. Use command
df -h

to check your device. You should see /dev/sda1 is mounted to somewhere like /mnt/sda1. Note down the location (like /mnt/sda1) for further steps. If the value is not /mnt/sda1, replace it with the right one on your device.

Step 1A: Use internal storage

This step is for whom want to use internal storage instead. No need to follow this when Step 1 is taken.

You need to find a place to store all folders and files created in later steps and note down the path to the place. I will use the path /mnt/sda1 in following steps. You should replace them to your path.

Step 2: Prepare debian system

Openwrt is lightweight linux without many system files shipped. Before installing Resilio-Sync, we need to prepare a full linux system core.

  1. First, install a tool for installing debian. These packages will be placed into internal storage.
opkg install debootstrap binutils
  1. Install debian files. Note: If the chip of your router is not armhf, you need to change the command with the correct arch name. Path /mnt/sda1 is used.
debootstrap --arch=armhf buster /mnt/sda1/debian http://ftp.de.debian.org/debian

This command will download the debian files into a new folder named debian under /mnt/sda1 which should be your USB drive. If something goes wrong, remove the folder /mnt/sda1/debian using command rm -fr /mnt/sda1/debian before re-run this command.

  1. Link system folders from openwrt to the debian system by these commands.
mount --bind /dev /mnt/sda1/debian/dev/
mount --bind /proc /mnt/sda1/debian/proc/
mount --bind /sys /mnt/sda1/debian/sys/
ln -s /bin/bash bin/ash
  1. Then we start the debian bash by this command.
chroot /mnt/sda1/debian/ /bin/bash

Now, the bash is created under debian system. The file system root is changed to the folder debian on your USB drive also.

  1. (Optional) For avoiding scene confusing, a good way is change the shell prompt for chroot. You can run these commands to do that. This is an optional but recommended step.
echo 'PS1="CHROOT:\w# "' >> ~/.bashrc
exit
chroot /mnt/sda1/debian/ /bin/bash

You will notice a CHROOT is shown on the left of the prompt when debian system is using.

  1. Now let’s prepare the debian system by installing locales.
apt-get install locales
dpkg-reconfigure locales

You can select en_US.UTF8 or any others you like.

Step 3: Install Resilio-Sync

  1. Download the right DEB package of Resilio-Sync for your router chip from here.
  2. Transfer the deb file to path /mnt/sda1/debian on your router using scp or any other tool.
  3. Use ls / under chroot terminal to make sure the file is ready.
  4. Install the package using command dpkg -i. If the file name is resilio-sync_2.7.2.1375-1_arm64.deb, the command should be
dpkg -i /resilio-sync_2.7.2.1375-1_arm64.deb
  1. (Optional) Mark the service as auto start by following command. Actually, because the route will not boot debian directly, this command is useless at all. I still place it as an optional step for my obsessive-compulsive disorder 🙂
systemctl enable resilio-sync
  1. (Optional) Edit the config if you need. The config file can be located as /etc/resilio-sync/config.json under chroot terminal.
  2. Exit the chroot by tying exit and press enter.
  3. Create a file for start Resilio-Sync with openwrt. This is actually work, not the step 5. Place a file /etc/init.d/resilio-sync with the content below.
#!/bin/sh /etc/rc.common
#

START=99
STOP=10

. $IPKG_INSTROOT/lib/functions.sh
. $IPKG_INSTROOT/lib/functions/service.sh

start() {
        mount --bind /proc /mnt/sda1/debian/proc
        chroot /mnt/sda1/debian /bin/bash /etc/init.d/resilio-sync start
}

restart() {
        mount --bind /proc /mnt/sda1/debian/proc
        chroot /mnt/sda1/debian /bin/bash /etc/init.d/resilio-sync restart
}

stop() {
        chroot /mnt/sda1/debian /bin/bash /etc/init.d/resilio-sync stop
        umount /mnt/sda1/debian/proc
}
enable() {
        err=1
        name="$(basename "${initscript}")"
        [ "$START" ] && \
                ln -sf "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/S${START}${name}"
                err=0
        [ "$STOP" ] && \
                ln -sf "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/K${STOP}${name}"
                err=0
        return $err
}
disable() {
        name="$(basename "${initscript}")"
        rm -f "$IPKG_INSTROOT"/etc/rc.d/S??$name
        rm -f "$IPKG_INSTROOT"/etc/rc.d/K??$name
}

And mark the file with execution permission and set it auto start by commands

chmod +x /etc/init.d/resilio-sync
/etc/init.d/resilio-sync enable

You can check there should be a service named resilio-sync with number 99 in page System – Startup of the router management portal. It should be marked as enabled as well.

Now everything is done. I left here for you to reboot your router and start to fulfill your Resilio-Sync mission.

Thanks for help from:

User of mysql/mariadb for wordpress

Today, I followed a guild to deploy a database using mysql and mariadb for wordpress instance. It failed in a strange way: I can use the user I created for the database to login from bash using mysql command, but wordpress reports access denied.

After a long time digging, the problem is solved:

Creating an account in database for wordpress, “mysql_native_password” is required to be specified, like CREATE USER [email protected] IDENTIFIED WITH mysql_native_password BY 'password'.

Zevera may NOT be a good choice

For downloading from multiple file hosts, I tried Zevera for a short while.

It’s failed to deal with the URL including encoded characters. For others, it acts quite slow (1~10KB/sec) to my home. I know each software and website has its limitation and I don’t plan to blame Zevera at the beginning.

I googled to try to get a refund after my test. Why I have to google for that? Coz there is no link on their page for refunding and the link provided from the support forum is wrong. Here is the policy I got: http://api.zevera.com/RefundPolicy.aspx.

If you are not satisfied with your premium account you can request a refund in the first 5 days if you haven’t downloaded more than 8 GB or more than 10 different files.

At the moment I emailed them, it’s just 2 hours passed from my payment, and no more than 5 files nor 500MB data is downloaded. Since the day I write this, after 7 days, no response, no refund, nothing.

After 3 days, I mail them to get a support about refund and provide a link that cannot be downloaded. The sad thing is after the mail sent, the host of that link died. One day later, the response of that email is the link is dead and “Your refund request cannot be approved at this time.” Yes, you get it, as they said “if you are not satisfied” is not a reason acceptable at all. I replied the mail with another link with encoded characters in URL, no response again.

If you find there is something wrong and prove to them, they will just ignore you. If you want a refund with your problem, they will not accept that.

How many people in the same boat? I don’t know. Because talking about refund in official forum is not allowed. “REFUND REQUEST – All topics with refund request will be deleted!” as they said.

Increase WSUS downloading speed

The downloading of updates in Windows Server Update Services (WSUS) is based on Background Intelligent Transfer Service (BITS). BITS is designed to download big files using idle bandwidth only. If you need to speed up the downloading process, you may change it to use a foreground mode.

 

To do that, you need a SQL Management Studio to connect the database used by WSUS. The database name is SUSDB. You can run this command in that database specified:

update susdb.dbo.tbConfigurationC set BitsDownloadPriorityForeground=1

For reversion, run it again with replacing the 1 to 0.

 

极路由绑定迅雷远程下载的另类方法

极路由可以通过安装云插件,成为一个迅雷远程下载的客户端。

但在绑定的过程中,由于极路由当前的设计思路,偶尔会出现无法正常绑定的情况。表现为在管理界面中显示出空白页,甚至直接显示出极路由公司首页。这些都导致无法将此路由绑定到迅雷。

如果碰到此类问题,可以通过这种方法绕开系统默认的绑定机制:

  1. 在内网的任何一台电脑上访问http://4006024680.com:9000/getsysinfo。如果你已经知道路由器的IP(默认为192.168.199.1),而且你的DNS未设置为默认,也可以直接使用路由器的IP地址代替4006024680.com的部分。浏览器会返回一行文字,其中一个引号中包括了6位英文和数字的组合。将其复制下,不包括引号。
  2. 访问迅雷远程下载网站http://yuancheng.xunlei.com。左侧上方找到添加按钮,输入复制的文字即可完成绑定。
  3. 之后就可以直接使用迅雷客户端或者迅雷的远程下载网站来分配任务了。并不需要在路由器中再进行绑定的操作。

Testing ZeroShell in enterprise

Hi.

ZeroShell 3 is launched recently, including many new features. I was a fan of this router software for several years and it works like a charm in my Net5501. Now I’m trying to introduce it to the company which I work for.

I deploy this software twice in my company. One is for a virtualization desktops, powered by QoS. This is quite necessary for a network which contains more than 100 clients for internet accessing.

Another one is for all mobiles and pads, powered by Captive Portal. But this function doesn’t work like predicted. Mobiles which joined this network by AP will not pop up a login page automatically. In some restaurants and hotels, after a device joined a network, a web page will be pop up automatically for login, but this function is still missing in this release of ZeroShell.

One more defect is about DHCP server. User defined options are not supported yet.