Ubuntu 18.04 LTS 盒子环境的部署

本文测试环境为 Hetzner E3-1245V2 独服,系统为官方的 Ubuntu 18.04 Minimal 模板。本文需要综合上一篇盒子配置文章阅读。

写在前面

经过长期的测试,考虑到双栈 IP 的需求,Deluge / qBittorrent 需要 libtorrent 1.0.11 版本才能正常汇报双栈 IP,所以本文很多操作都为了这个目标而设。

Deluge 1.3.15 官方 PPA 仍然没有更新 18.04 对应的二进制包,所幸 Ubuntu 官方源里面就是 1.3.15,理论上可以使用。但是考虑到使用 apt 安装会导致安装官方源中自带的 libtorrent 1.1.5 的依赖,因此选择完全编译安装 libtorrent 与 Deluge。

Wine 官方源也没有增加 Ubuntu 18.04 的支持,Ubuntu 官方源中有对应的 wine64 软件包,因此选择安装该包而非 Wine 官方的版本。

E3-1245V2 有自带 Intel 集显,考虑到 X11VNC 配合 Xorg 使用可以支持完整的键盘操作(VNCserver 存在无法输入 tab、WinKey 的问题,还有 24bit 显示导致 VMware 颜色错乱的问题),本文中选择安装 X11VNC。考虑到通用性,仍应参考上一篇文章使用 VNCserver。

环境的部署

本文所有编译环境采用最新的 gcc-8.1 完成,注意 Boost 需要最高 1.65.1 版本,这个和目前 Ubuntu 源中的版本一致。

# gcc-8 Prerequisites
add-apt-repository ppa:ubuntu-toolchain-r/test
# Compiler
apt install gcc-8 g++-8 build-essential checkinstall pkg-config automake libtool git
# Libtorrent Dependency
apt install libboost-dev libboost-system-dev libboost-python-dev libboost-chrono-dev libboost-random-dev libssl-dev libgeoip-dev
# Deluge Dependency
apt install python-pip python-attr python-automat python-chardet python-click python-colorama python-constantly python-hyperlink python-incremental python-openssl python-pam python-pyasn1 python-pyasn1-modules python-serial python-service-identity python-twisted-bin python-twisted-core python-zope.interface python-twisted python-openssl python-setuptools intltool geoip-database python-notify python-pygame python-glade2 librsvg2-common xdg-utils python-mako
# qBittorrent Dependency
apt-get install qtbase5-dev qttools5-dev-tools libqt5svg5-dev

libtorrent 1.0.11 的编译

综合参考 Deluge 的文档与 qBittorrent 的文档。

git clone https://github.com/arvidn/libtorrent.git libtorrent-1.0.11
git checkout $(git tag | grep libtorrent-1_0_ | sort -t _ -n -k 3 | tail -n 1)
./autotool.sh
./configure --enable-python-binding --with-libiconv --disable-debug --enable-encryption --with-libgeoip=system CXXFLAGS=-std=c++11
make -j$(nproc)
checkinstall
ldconfig

注意 libtorrent 1_0_x 的代码需要修改才能正常地引用 Boost,毛球说 RC_1_0 分支不存在本问题,未作测试。

//修改include/libtorrent/export.hpp
//那两个hpp文件在boost/config/detail/下,而不是boost/config/下

#if !defined(BOOST_COMPILER_CONFIG) && !defined(BOOST_NO_COMPILER_CONFIG)
#  include <boost/config/detail/select_compiler_config.hpp>
#endif
#ifdef BOOST_COMPILER_CONFIG
#  include BOOST_COMPILER_CONFIG
#endif

#if !defined(BOOST_PLATFORM_CONFIG) && !defined(BOOST_NO_PLATFORM_CONFIG)
#  include <boost/config/detail/select_platform_config.hpp>
#endif
#ifdef BOOST_PLATFORM_CONFIG
#  include BOOST_PLATFORM_CONFIG
#endif

Deluge 安装

wget http://download.deluge-torrent.org/source/deluge-1.3.15.tar.gz
tar xzvf deluge*.tar.gz
python setup.py build
python setup.py install

注意这种方式安装的 Deluge 默认在 /usr/local/bin 下,而不是像 deb 安装一样在 /usr/bin。如果需要安装在 /usr/bin 下,安装时添加参数 –install-layout=deb。

其他软件的部署

add-apt-repository ppa:transmissionbt/ppa
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
dpkg --add-architecture i386 
apt install --install-recommends xorg x11vnc transmission-daemon sshfs nodejs firefox fonts-noto xfce4 wine-stable
apt install gtk3-engines-xfce xfce4-goodies xfce4-power-manager

Xorg 配置文件

位置在 /usr/share/X11/xorg.conf.d/20-intel.conf

Section "Device"
   Identifier  "Intel Graphics"
   Driver      "intel"
   Option      "AccelMethod"  "sna"
   Option      "TearFree"     "true"
EndSection

Section "Monitor"
    Identifier      "External VGA"
    Modeline        "1600x900_60.00"  118.25  1600 1696 1856 2112  900 903 908 934 -Hsync +Vsync
    Option          "PreferredMode" "1600x900_60.00"
EndSection

Section "Screen"
    Identifier    "Screen0"
    Device        "Device0"
    Monitor       "Monitor0"
    DefaultDepth  24
    SubSection "Display"
        Depth 24
        Modes "1600x900"
        Virtual 1600 900
    EndSubSection
EndSection

X11VNC 与 Xorg 的 systemd 启动脚本

# xserver.service
[Unit]
Description=Xserver
After=network-online.target

[Service]
ExecStart=/usr/bin/sudo /usr/bin/startx -- :0
Restart=always
Type=simple
RestartSec=3

[Install]
WantedBy=multi-user.target
# x11vnc.service
[Unit]
Description=X11vnc
After=network-online.target xserver.service
Wants=xserver.service

[Service]
ExecStart=/usr/bin/sudo /usr/bin/x11vnc -rfbport 25901 -rfbauth /root/.vnc/passwd  -display :0 -forever -nevershared -bg -repeat -nowf -o /root/.vnc/x11vnc.log
Restart=always
Type=forking
RestartSec=3

[Install]
WantedBy=multi-user.target

x11vnc 需要首先创建 ~/.vnc/passwd 文件,这个 VNCserver 运行的时候也会自动创建,我懒得重新建立就没研究这个,改日有空再写吧。

Xorg 默认启动的文件为 ~/.xinitrc

#!/bin/sh

# /etc/X11/xinit/xinitrc
#
# global xinitrc file, used by all X sessions started by xinit (startx)

# invoke global X session script
. /etc/X11/Xsession
exec startxfce4

参考资料

https://wiki.archlinux.org/index.php/Xinit_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)

https://wiki.archlinux.org/index.php/X11vnc_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)

https://blog.csdn.net/songbaiyao/article/details/72858087

https://wiki.archlinux.org/index.php/Xorg_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)

https://wiki.archlinux.org/index.php/Intel_graphics_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)

https://serverfault.com/questions/174003/how-can-opengl-graphics-be-displayed-remotely-using-vnc

https://askubuntu.com/questions/537787/enable-3d-hw-acceleration-on-vmware-workstation-10-on-ubuntu-14-04

https://github.com/qbittorrent/qBittorrent/wiki/Compiling-qBittorrent-on-Debian-and-Ubuntu

https://dev.deluge-torrent.org/wiki/Installing/Source

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注