Posts in category “Linux”

gnome3 how to alt tab windows on current workspace only?

gsettings set org.gnome.shell.app-switcher current-workspace-only true

Virtualbox MacOS VM setup / setup Rime/Squirrel input method (鼠须管) on macOS

  1. I successfully ran macOS High Sierra on my Ubuntu 18.04 laptop through VirtualBox. VirtualBox is great ! This article helps!
  2. Install Rime on macOS in five minutes
  3. download the zip file from latest release from the Tags page on GitHUB
  4. unzip the file and install the pkg file
  5. go to https://github.com/rime/plum to get the wubi package.
git clone https://github.com/rime/plum.git
cd plum
bash rime-install wubi pinyin-simp

The last step, is creating a default.custom.yaml file and putting it in ~/Library/Rime directory.

the content in my default.custom.yaml is

patch:
  schema_list:
    - schema: wubi_pinyin
    - schema: pinyin_simp

How make openvpn work with docker & avoid entering the password every time

I met this issue today morning and find the solution from the link I just refered.

I have made a few change to the solution to meet my case, this is why I wrote this article.

My version of fix-routes.sh

#!/bin/sh
echo "Adding custom route to $route_vpn_gateway with /24 mask..."
# ip route add 10.8.0.0/24 via $route_vpn_gateway
ip route add 192.168.178.0/24 via $route_vpn_gateway

echo "Removing /1 routes..."
ip route del 0.0.0.0/1 via $route_vpn_gateway
ip route del 128.0.0.0/1 via $route_vpn_gateway

I didn't use ip route add default via $route_vpn_gateway line because I didn't want to route everything through my VPN.

Changes to my openvpn profile

You can see I added an extra askpass line besides what the author has done. That line was added to help me get ride of the annoyance of entering the password for my private key every time I run the openvpn client program.

auth SHA256
auth-nocache
verb 3
askpass /home/davidwei/ovpn/pass.txt
script-security 2
route-up /etc/openvpn/fix-routes.sh

My ovpn start one-line script

davidwei@xps:~$ cat ~/bin/ovpn 
sudo openvpn ~/shukebeta.ovpn > /dev/null 2>&1 &

My pass.txt

davidwei@xps:~$ cat ~/ovpn/pass.txt 
my-very-secret-password

Notes for upgrading Debian 7 to Debian 10 on an old cheap VPS

前言

好几年前 123systems.net 打折的时候买了这个vps,年付只要 $3.8。不过配置还说得过去,256M 内存,10G ssd硬盘,每个月有512G流量,而且是 KVM的。那时候我还不知道啥是docker,买这台vps的目标很单纯,就是翻墙。然而当时 123systems.net 的服务非常烂,网络差,北京连过去经常丢包不说,而且还常down机,你提个ticket也要过上好几天才有人搭理。便宜没好货....看在乞丐价的份上,所以大爷我也忍了。不就3块8么,全当喂狗了。(所以后面不久我又从另一家买了一台配置高点的)。后来听说 123systems 被另一家 vps 提供商(对,就是chicago vps)收购了,我想那服务是不是会好点,就又连上去试了下。别说,网络真的稳定多了!也几乎不down机了,于是它就作为我的一个备用翻墙节点用起来了。这也才有了后面的年年续费。

在这台机器上我用了好几年 Ubuntu 14.04,但这台 vps 能够安装的操作系统模板,这么多年就一直没更新过。Ubuntu 最高是14.04, Centos是 6.5, Debian是7.3,Fedora 是 20。后来我玩 Docker 的时候想到这台机器是 kvm 啊,可以装docker的。于是就在上面装了Docker。后来随着 Docker 的一直升级,渐渐地新版 Docker 就不再支持 Ubuntu 14.04了。虽然用旧版也不是不行,但是我动了升级操作系统的念头。虽然模板中只有 14.04, 我总可以自己升级装好的系统嘛。然而升级并不顺利,我曾经磕磕绊绊升到 16.04 用了几天,发现不稳定(经常无故自动关机)就又回到了 14.04。后来经过一个不眠之夜,我装上了 Debian 7 又费了好大劲升级到 Debian 8 jessie。这个还比较稳定,就一直用着,直到昨天晚上。

昨天晚上闲逛的时候,我发现有一个人写了个一键自动重灌vps操作系统的脚本,支持 Debian 和 Centos, 支持指定版本号。 我的心又活络起来了。虽然那篇文间是2018年的,已经挺老了,但我还是打定主意打算试试,万一支持 Debian 10 呢。于是该备份的备份,然后开始尝试。不过作者说了不保证谁都能用,也不保证不丢数据。悲伤的是 他说对了

Debian装上启动不了,Centos 看文章下面的评论最高只能升级到 6.10 而我的目标是 7.7。罢了罢了!此路不通!看看天色已晚,已过夜里12点。我打算再最后试一次, 装个 Fedora 20 看看能不能一路升到最新。然而也不顺利。都1点了,去他的,睡觉了。

心里有事,睡得也不踏实,于是今天早上早早就起来了。不想再用Ubuntu了,于是重新装上 Deiban 7, 我想这次,就升级到 Deiban 8 和过去一样算了,回到原点凑付用吧。一台年付才3.8的破机器,不值当我花这么多时间折腾。然而 Debian 7 的源已经都死掉了,所以 Deiban 7 的系统也没法更新了,直接升 8 就好了。然而升 8 也不顺利,上次升级的时候并没有记笔记,所以好多问题东西要重新搜索,重新找(所以我今天在写笔记!)。就在到处找的过程中,我看到一个人在某个问题下评论说,他从 Debian 7 一直升级到了 Debian10,虽然花了很多时间,但感觉 amazing! 那我也试试唄。

现在是中午12点,开心的是我也搞定了那个升级,并且正在趁热乎把中间找资料的坎坷记录下来。那么口水到此结束,下面干货开始:

正文

  1. Debian 7 更新 /etc/apt/sources.list 为
deb http://deb.debian.org/debian/ jessie main contrib non-free
deb-src http://deb.debian.org/debian/ jessie main contrib non-free

deb http://security.debian.org/ jessie/updates main contrib non-free
deb-src http://security.debian.org/ jessie/updates main contrib non-free

deb http://deb.debian.org/debian/ jessie-updates main contrib non-free
deb-src http://deb.debian.org/debian/ jessie-updates main contrib non-free
  1. 用 root
apt-get -y update
apt-get -y install apt -t jessie
apt -y upgrade
apt-get -y dist-upgrade 
reboot

当然升级之路不会这么顺利,你肯定会遇到 no public key available for the following key IDs: xxxxx 和什么源已过期无法验证之类的报错。对于前者, 使用 apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1397BC53640DB551(请一定记着把key换成你那里看到的key);至于后者,可以用加参数大法apt-get -y -o Acquire::Check-Valid-Until=false update 解决。总起来说这一步还是蛮顺利的,升级完重新启动能直接进系统,网络什么都是好的。

  1. Jessie to Stretch,继续用root身份哦
sed -i 's/jessie/stretch/g' /etc/apt/sources.list
apt-get update
apt-get upgrade
apt-get dist-upgrade

应该说这个升级也蛮顺利的,除了升级完重启后....我就再也连接不上vps之外。还好有 Vnc 可以用,虽然网页上提供的 html5 vnc cient不能使,但我用本机的 vncviewer 能够连接上。 连上之后,发现除了网卡参数全丢了,其他都是正常的。那...网卡参数怎么设置?原来的参数都是啥?我不知道哇。于是又一通搜索,各种尝试,还是不行。最后想起 vps 控制台有 Reconfigure Networking 的功能,那就死马当活马医,试试吧。一试,好了!那么.....从7升到9已经是挺了不起的成就了,还升10么?升!

  1. Stretch to Buster,继续用 root 身份
sed -i 's/stretch/buster/g' /etc/apt/sources.list
apt-get update
apt-get upgrade
apt-get full-upgrade

这个升级也蛮顺利的,然而升级完重启后就连接不上vps的问题再一次发生了。根据刚才的经验用了 vps 控制台的 Reconfigure Networking 的功能,但这次没有那么走运,网还是不通。经过一番排查之后,发现这次系统注入参数时使用的网卡名字是 eth0,而我记得以前网卡的名字是 ens3。于是修改 /etc/network/interfaces 文件,把 eth0 改为 ens3 然后 systemctl start networking.service。成功!

每一次折腾,都能学到点什么,技术就是这么一点点折腾来的。但是如果不记录下来,下次再找又要花很多时间。所以...我又花了40分钟写这篇blog。不过还是很开心啊!把看似不可能事情最终搞成了,就是那样的开心!

参考资料: debian-wheezy-update-repository
参考资料: how-to-upgrade-debian-7-wheezy-to-10-buster-safely
参考资料: how-to-upgrade-debian-8-jessie-to-debian-9-stretch

How to get coloured terminal over ssh?

I haven't used my old MBP 13 for nearly a month. This evening I picked it up and opened the iTerm2 then connected to my home server through ssh. I noticed I get a white-black colored terminal. What's wrong? I remembered it was colorful when I logged into this machine last time using iTerm2 on my MBP 15.

Firstly, I checked the version of iTerm2, it was a bit old, so I updated it first. Unfortunately, it doesn't help. I noticed I was using bash instead of zsh on this machine. So I ran chsh and changed the shell from bash to ssh. It also doesn't help. Then I find this answer from stackoverflow.com. A comment in this answer reminded me: I should check and compare the terminal configuration in iTerm2. So I found the secret!

Command + , open the preference, then click the profiles tab, then change the Report terminal type from xterm to xterm-256 color, that's it!