公司的电脑平时一直处于开机状态, 压榨电脑的剩余价值, 网速又好, 寻思着弄成下载机, 迅雷给路由器做的版本叫 Xware, 找了下发现有 x86 版本, 顺势装在 Ubuntu 上了.

Xware1.0.31 点击下载

解压后有四个文件
1
2
3
4
-rw-rw-rw- 1 gavin gavin 4.1M  8月 27  2014 EmbedThunderManager
-rw-rw-rw- 1 gavin gavin 24K 8月 27 2014 ETMDaemon
-rw-rw-rw- 1 gavin gavin 111K 8月 27 2014 portal
-rw-rw-rw- 1 gavin gavin 23K 8月 27 2014 vod_httpserver
执行./portal
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
initing...
try stopping xunlei service first...
killall: ETMDaemon: no process killed
killall: EmbedThunderManager: no process killed
killall: vod_httpserver: no process killed
setting xunlei runtime env...
port: 9000 is usable.

YOUR CONTROL PORT IS: 9000

starting xunlei service...
etm path: /home/gavin/Software/Xware1.0.31_x86_32_glibc
execv: /home/gavin/Software/Xware1.0.31_x86_32_glibc/lib/ETMDaemon.

getting xunlei service info...
Connecting to 127.0.0.1:9000 (127.0.0.1:9000)
the active key is not valid.

try again...(has tried 1 time(s)).
getting xunlei service info...
Connecting to 127.0.0.1:9000 (127.0.0.1:9000)

THE ACTIVE CODE IS: ******

go to http://yuancheng.xunlei.com, bind your device with the active code.
finished.

把 ACTIVE CODE 填入 http://yuancheng.xunlei.com/ 中, 就算完成了.

完成上一步, 还有个问题, xware 是针对嵌入式设备的, xware 只会检测挂载到/media 目录下可写的设备, 所以我们需要把本地的某个文件夹, 挂载到/media, 同时我们又不希望一插入 U 盘就被识别为 xware 可用目录, 于是我们还需要换一个用户专门用来启动 xware.

  • 创建 thunder 用户
1
sudo useradd --no-create-home --user-group thunder
  • 把 xware 目录设置为 thunder 所有
1
su chown thunder:thunder -R Xware1.0.31
  • 创建下载目录和挂载目录, 并设置为 thunder 用户所有
1
2
3
4
sudo mkdir ~/TDDownload -p
sudo mkdir /media/thunder/TDDownload -p
sudo chown thunder:thunder ~/TDDownload
sudo chown thunder:thunder /media/thunder/TDDownload
  • 把下载目录挂载到挂载目录
1
sudo mount --bind ~/TDDownload /media/thunder/TDDownload/
  • 配置启动脚本, 放在 Xware 文件夹外
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
#!/bin/sh

XWARE_DIR=./Xware1.0.31_x86_32_glibc

USERNAME="thunder"

# 下载绝对路径
DOWN_DIR={你的下载绝对路径}
# 挂载路径
MOUNT_DIR=/media/thunder/TDDownload

if [ $# -gt 0 ];
then
# 加参数 -s是关闭
su $USERNAME -c "$XWARE_DIR/portal -s"
code=$?

if [ $code -eq 0 ];
then
umount $MOUNT_DIR
echo "xware stop sucess..."
else
echo "xware stop fail,code $code"
fi

else
# 不加参数默认是启动
su $USERNAME -c $XWARE_DIR/portal
code=$?

if [ $code -eq 0 ];
then
mount --bind $DOWN_DIR $MOUNT_DIR
echo "xware start sucess..."
else
echo "xware start fail,code $code"
fi

fi
  • 启动与关闭
启动
1
sudo ./xware.sh
关闭
1
sudo ./xware.sh -s