Shadowsocks-Qt5 AppImage

Applications on Linux tend to be distributed by distributions, managed/packaged by distribution’s package managers. For upstream application developers, one way to ship the software to users is to create binary packages for mainstream Linux distributions. Don’t get me wrong, it is not too difficult, given we’ve now had Launchpad for Ubuntu, Copr for Fedora, OBS for OpenSUSE. Arch Linux has AUR, although that is just recipe collection.

By chance, I’ve seen Krita is shipping their software using AppImage. My attention was drawn over immediately. It looks very promising, given how many upstream apps are packaged in AppImage and how easy-to-use it is. The best part is that AppImage doesn’t require any tools (unlike flatpak which needs OS support). It basically acts similarly to the way how people ship applications on macOS, in bundles! Hence, there you go, my journey to pack Shadowsocks-Qt5 in AppImage.

Since you can easily find well documented procedures in their Wiki pages, I won’t bother logging it step by step but only a few hiccups I got. The tool I’m using is linuxdeployqt along with the vanilla AppImageKit. Both tools are distributed in AppImage format, how convenient! 🙂

As recommended, you should use a relatively old Linux distribution to make your AppImage file as compatible as possible (apps linked against newer GLIBC won’t be able to run with older GLIBC). I’ve chosen Debian Jessie as the host OS which has very similar software suite as Ubuntu Trusty does (so I can use Travis CI in the future to automate AppImage build).

One hiccup I got was a symbol error from libharfbuzz.so, see this issue. After a few days Googling, I found a similar issue which points to freetype and harfbuzz themselves. So I just tried to remove libfreetype.so and libharfbuzz.so from appdir directory, and packed with appimagetool, voila it works! I have to point out that linuxdeployqt will always try to put those necessary libraries into appdir when you use it to pack AppImage. In the end, I had to replace the last step with vanilla appimagetool. In another words, what I did was

linuxdeployqt ./appdir/usr/share/applications/shadowsocks-qt5.desktop -bundle-non-qt-libs
rm -f ./appdir/usr/lib/libharfbuzz.so.0
rm -f ./appdir/usr/lib/libfreetype.so.6
appimagetool ./appdir

An experimental AppImage file has been uploaded to the releases page, please give it try, especially if your Linux distribution doesn’t have Shadowsocks-Qt5 in the repository.

Advertisements

Shadowsocks on RHEL 101

This post is written as a basic guide to install and setup shadowsocks server on Red Hat Enterprise Linux (or its clones such as CentOS). shadowsocks-libev is chosen as the shadowsocks port (implementation) for this guide.

Introduction

Shadowsocks is a beloved lightweight secure proxy procotol that can help you bypass firewalls. It’s incredibly flexible and easy to deploy, setup, or even implement it from scratch. Shadowsocks runs on Windows, Mac, Linux, FreeBSD, Android, iOS and more! It runs on x86, ARM, MIPS and more, from PCs to routers!

The project is open-sourced and hosted on GitHub. Different implementations (shadowsocks port) have different licenses though, their features may vary, especially for non-essential features.

Installation

You don’t need to compile source code yourself. Instead, the recommended way is to install from Copr repository.

  1. Download repo from Shadowsocks Copr.
  2. Put repo file into /etc/yum.repos.d/.
  3. Execute sudo yum update and sudo yum install shadowsocks-libev in terminal.

Server Configuration

Open the configuration file /etc/shadowsocks-libev/config.json (You’ll need root priviledge for this). An example configuration is pasted below:

{
    "server":"0.0.0.0",
    "server_port":8388,
    "local_port":1080,
    "password":"barfoo!",
    "timeout":600,
    "method":"chacha20"
}
  • server: Server listening address
  • server_port: Server listening port
  • local_port: Local listening port (ignored by server)
  • password: Password used for encryption
  • timeout: Maximum idle time for a TCP connection
  • method: Encryption method

Start Service

  • For RHEL 6, execute sudo service shadowsocks-libev start to start.
  • For RHEL 7 or Fedora, execute sudo systemctl start shadowsocks-libev to start.

Client Configuration

There are a lot of shadowsocks clients available on all major platforms. The client’s configuration should be the same as server’s. Well, the server IP is the server’s public IP instead of 0.0.0.0.

You must understand the client is effectively a local SOCKS5 proxy server that forwards data to remote shadowsocks server. In order to complete the proxy channel, you need to set applications’ SOCKS5 proxy server to the client‘s address and port.

A good news is on Android platform, shadowsocks client is more or less like a VPN (easier to setup for tech noobs). You can set it proxy the whole handset, or just proxy certain apps.

Don’t want to type that loooong and full-of-symbols password? Check the Quick Guide to use QR Code to share your configuration (Note: One-time authentication option is not included in QR Code).

Install Terminus Font as A Normal User

For old Linux distributions, TrueType Fonts (TTF) are installed into $HOME/.fonts if not installed globally. As an even older practice, bitmap fonts (usually used in xterm or urxvt) installation is slightly different.

Here is my situation:
– Red Hat Enterprise Linux 5
– No root priviledge
– System reboots every week

As you may know, those now deprecated configuration methods are the only ways on this old system. To be honest, I never installed a bitmap font before because TTF is simply much better and eye-friendlier. But if we consider the rendering speed, of course bitmap is faster in most cases.

Anyway, take Terminus as an example since it’s very popular (not my type of font). Download the latest source code from its project website and extract it. Then,

./configure --prefix=$HOME/.local
make
make install fontdir

Now these fonts should be installed into your home directory. Before they can be used, you need to type some commands:

xset +fp $HOME/.local/share/fonts/terminus
xset fp rehash

To preview the font, simply run xfontsel and change font family to terminus. You can also list all terminus fonts using xlsfonts | grep terminus.

You should be able to download the TTF type font of terminus, if that’s the case, you need to copy them into $HOME/.fonts directory and run fc-cache -rv to refresh the cache.

Change your terminal font to a nice one before you get your eyes blind. 🙂

Build GCC 5.2 on RHEL 6

To build GCC, we need other three components, GMP, MPC, and MPFR. And I found a lazy way to compile all of them together here. But because GMP, MPC, MPFR are compiled together with GCC, they’re certainly not installed before the new GCC is installed. So we can’t do make -k check to make a test after the compilation in this way. If you’d like to do a test, please go the traditional way, build and install them one by one seperately.

wget http://ftpmirror.gnu.org/gcc/gcc-5.2.0/gcc-5.2.0.tar.bz2
tar xf gcc-5.2.0.tar.bz2

wget https://gmplib.org/download/gmp/gmp-6.0.0a.tar.xz
tar xf gmp-6.0.0a.tar.xz
mv gmp-6.0.0 gcc-5.2.0/gmp

wget ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz
tar xf mpc-1.0.3.tar.gz
mv mpc-1.0.3 gcc-5.2.0/mpc

wget http://www.mpfr.org/mpfr-current/mpfr-3.1.3.tar.xz
tar xf mpfr-3.1.3.tar.xz
mv mpfr-3.1.3 gcc-5.2.0/mpfr

mkdir gcc-5.2.0/gcc-build && cd gcc-5.2.0/gcc-build

# I don't have root privilege, so install to a subdir in my home directory
../configure --prefix=$HOME/gcc5 \
             --disable-multilib \
             --enable-languages=c,c++ \
             --enable-libstdcxx-threads \
             --enable-libstdcxx-time \
             --enable-shared \
             --enable-__cxa_atexit \
             --disable-libunwind-exceptions \
             --disable-libada \
             --host x86_64-redhat-linux-gnu \
             --build x86_64-redhat-linux-gnu \
             --with-default-libstdcxx-abi=gcc4-compatible

# For clusters, you should request a compute node in slurm to do the compilation. Don't do these in head node
make -j4

make install

With --with-default-libstdcxx-abi=gcc4-compatible, we avoid recompiling all C++ libraries built using older GCC (prior to GCC 5.1). This ensures the default ABI is the old, GCC4-compatble one instead of the newly introduced CXX11 ABI. Check Configure – The GNU C++ Library for details.

Continue reading “Build GCC 5.2 on RHEL 6”

Use avconv to Convert Video Format

avconv is a utility that belongs to Libav project. Similar to its precedent ffmpeg, it supports lots of mainstream encoders and decoders. Here I just put some simple commands as a personal memo and a brief guide.

Install libav-tools via apt-get on your Debian/Ubuntu machines. Note on my Fedora laptop, there is no libav but only the original ffmpeg packages. The command-line options are fairly similar (sometimes even identical). In that case, you only need to substitute ffmpeg for avconv.

Continue reading “Use avconv to Convert Video Format”

Force-Enable Hardware Acceleration in Firefox on Linux

Before any steps, let’s check if GPU acceleration is already on.

  1. Open about:support in Firefox.
  2. Navigate to Graphics section.
  3. Check the GPU Accelerated Windows field.

If it’s 1/1 or 1/2 or 2/2 or whatever, anyway, the first number must be greater than 0, then Firefox is already hardware accelerated. And you don’t need to take following procedures to force-enable it. Otherwise, let’s do a few modifications to force-enable the GPU acceleration in Firefox!

Continue reading “Force-Enable Hardware Acceleration in Firefox on Linux”