Windows使用frp进行远程连接

frp 是一个可用于内网穿透的高性能的反向代理应用,支持 tcp, udp, http, https 协议。

Github介绍: https://github.com/fatedier/frp/blob/master/README_zh.md

安装

从这里https://github.com/fatedier/frp/releases 下载最新的二进制安装包,服务端跟客户端都在一个压缩包里。

服务端

服务端跟客户端都需要一个配置文件,对于服务端配置文件如下

1
2
3
4
5
frps.ini (完整配置文件 https://github.com/fatedier/frp/blob/master/conf/frps_full.ini)
[common]
bind_port = 7000
vhost_http_port = 8888
token = your_token

然后启动只需要一条命令
/usr/bin/frps -c /etc/frps/frps.ini

最好做一下守护,如使用systemd托管

1
2
3
4
5
6
7
8
9
10
11
12
13
$ cat /etc/systemd/system/frps.service
[Unit]
Description=frpc daemon
After=syslog.target network.target
Wants=network.target
[Service]
Type=simple
ExecStart=/usr/bin/frps -c /etc/frps/frps.ini
Restart=always
RestartSec=1min
ExecStop=/usr/bin/killall frps
[Install]
WantedBy=multi-user.target

客户端

客户端同服务端也需要一份配置(frpc.ini),如这里我们做windows的远程桌面映射

1
2
3
4
5
6
7
8
[common]
server_addr = 47.98.28.15
server_port = 7000
token = your_token
[rdp]
type = tcp
local_port = 3389
remote_port = 3389

上面的server_addr填写服务端的ip,token同服务端的token。

同样一条命令启动
./frpc.exe -c frpc.ini

做成自启动服务

下载一个nssm.exe放到frp的目录下,然后执行下面的命令(注意下对32、64版本)
nssm.exe install frpc

接下来会弹出一个框,在path处选择启动frpc的frpc.bat

点击Install service即可

启动 nssm.exe start frpc

测试

首先确保你的windows可以被远程连接。

在外网机器输入 47.98.28.15,然后输入你的用户名密码即可连接。

注意开通服务器跟客户端的3389端口,以及服务端的7000,8888端口。

SailfishOS移植到Redmi-5-Plus的一些记录(2)

接上 https://birdzhang.xyz/2018/03/30/SailfishOS%E7%A7%BB%E6%A4%8D%E5%88%B0Redmi-5-Plus%E7%9A%84%E4%B8%80%E4%BA%9B%E8%AE%B0%E5%BD%95/

本文章主要针对 hybris 15.1的移植

挑选设备源码

mer-hybris的android hybris-15.1是基于lineageos的,所以我们在没有官方/非官方lineageos用的时候,也要找基于lineage的第三方rom,如国内的Mokee,国外的OmniROM等,只需要稍微改一点devicetree就可以用了

适配hybris-15.1的一些更改

一、Failed to initialize property area

目前的解决方法是注释掉这个, 还有可能是没有关闭selinux或者没有初始化sailfish所需要的android init rc文件有关

system/core/init/property_service.cpp, 将72行的exit(1);注释掉

二、kernel,device部分

  1. 内核部分主要需要注意的是你的设备是否是有 /vendor分区的,project treble的都会有一个单独的/vendor分区,这个需要注意。

    可以通过这个里查看 arch/arm/boot/dts/qcom/msm8953.dtsi (根据你自己cpu来区分,找不到的话就用grep找一下)

    如下,可以看到有vendor跟system分区单独挂载,这个地方可以看谷歌对system-as-root的说明便于理解

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    firmware: firmware {
    android {
    compatible = "android,firmware";
    fstab {
    compatible = "android,fstab";
    vendor {
    compatible = "android,vendor";
    dev = "/dev/block/platform/soc/7824900.sdhci/by-name/cust";
    type = "ext4";
    mnt_flags = "ro,barrier=1,discard";
    fsmgr_flags = "wait";
    status = "ok";
    };
    system {
    compatible = "android,system";
    dev = "/dev/block/platform/soc/7824900.sdhci/by-name/system";
    type = "ext4";
    mnt_flags = "ro,barrier=1,discard";
    fsmgr_flags = "wait";
    status = "ok";
    };

    也可以通过device tree的 fstab.qcom 查看,如果没有,需要加上去(至少在vince上面是这样,因为后面的dhd要靠这个来判断),如我的需要加这两行

    1
    2
    /dev/block/bootdevice/by-name/system            /system                 ext4    ro,barrier=1                                                    wait,recoveryonly
    /dev/block/bootdevice/by-name/cust /vendor ext4 ro,barrier=1 wait,recoveryonly

    有的设备/dev/block/bootdevice/by-name/system挂载到/下面(对应下面的dhd部分的makefstab_skip_entries),而我的设备/vendor是来自/cust(也是迷 @_@

  1. device tree部分注释掉启用full treble的部分

    如我的设备需要把下面这些注释掉,否则selinux的政策文件会安装到/vendor下面,不会在根目录下产生,sfos需要在根下面有。

    扩展阅读: https://source.android.com/security/selinux?hl=zh_cn

    1
    2
    3
    4
    5
    6
    # Treble
    #BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED := true
    #PRODUCT_FULL_TREBLE_OVERRIDE := true
    #PRODUCT_COMPATIBILITY_MATRIX_LEVEL_OVERRIDE := 27
    #BOARD_VNDK_VERSION := current
    #BOARD_VNDK_RUNTIME_DISABLE := true

三、dhd,dhc部分

https://wiki.merproject.org/wiki/Adaptations/faq-hadk 搜索 15.1也会找到一些需要注意的地方

修改dhd的spec文件,添加

1
2
# On Android 8 the system partition is (intended to be) mounted on /.
%define makefstab_skip_entries / /vendor /dev/stune /dev/cpuset /sys/fs/pstore /dev/cpuctl

也不一定全部要加上,我的设备/system,/vendor就不自动挂载,需要改成这样, 可以先不加然后telnet上去看看这里目录下有没有文件吧

1
%define makefstab_skip_entries /dev/stune /dev/cpuset /sys/fs/pstore /dev/cpuctl

这样会生成system.mountvendor.mount,启动systemd的时候会挂载上

对于有些设备可能提示kgsl kgsl-3d0: |_load_firmware| request_firmware(a530_pm4.fw) failed: -2,需要做一个软链到 /lib/firmware

https://github.com/mer-hybris/droid-config-sony-nile/blob/91c15efb576c29a9d41cc4cd1d40c62ddcce9824/sparse/lib/firmware

调试

暂无很详细的,主要是看dmesg,journalctl等看看把出错的都修了。

通话声音

如果可以打通电话但是没有声音,则需要 pulseaudio-modules-droid-hidl 1.0版本(截止2019-09-24),然后配合新的ril配置文件 https://github.com/mer-hybris/droid-config-sony-nile/tree/master/sparse/etc/ofono

界面crash

看dmesg/logcat/journactl里面是不是有binder的信息,打补丁吧,至于打哪些只能靠猜(大雾

使用docker编译打包sailfishos

开坑

  1. ubuntu HA_BUILD

用官方的ubuntu镜像即可,16.04或18.04都可以,不要用最新的20.04。一般来说启动之后的镜像除了手动指定的目录是持久化的,其他的会重启后失效,所以最好自己做一个镜像,把安卓编译环境安装上。

启动时映射本地目录,当作ANDROID_ROOT目录。

  1. mer MER_BUILD

  2. OBS

  3. gitlab ci

harbor跨大版本升级

注意:必须是用域名的方式(也就是有内网的dns),如果以前用ip,则本方法无效!

Harbor1.2之前的版本不能直接升级到新版本,想要升级到最新版并且业务不中断,可以采用如下方式。

大体流程如下:

B机器搭一个新harbor -> 手动将旧harbor的镜像push到新harbor -> 更改A域名指向到B主机ip ->

测试B的harbor服务是否正常 -> 铲掉A上的旧harbor -> 在A上重新搭建harbor -> B机器上的harbor同步到A上的harbor

测试A的harbor服务是否正常 -> 改回A域名指向A主机 -> 删掉B上的同步。

手动push旧harbor镜像到新harbor所用到的脚本:
pip install python_harborclient
get_all.py:

1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/python
from registry import RegistryApi
api = RegistryApi('admin', 'password', 'http://pk8stemp02.rmz.flamingo-inc.com:8888')
maxsize = 65536
repos = api.getRepositoryList(maxsize)
repositories = repos.get('repositories')
for repo in repositories:
tags = api.getTagList(repo).get('tags')
if tags:
for tag in tags:
print(repo + ":" +tag)
```

python get_all.py > all_repos.txt
allimages=$(cat all_repos.txt)
ORIGIN_HOST=”pk8snode01.rmz.flamingo-inc.com:8888” #旧harbor
BACK_HOST=”pk8stemp02.rmz.flamingo-inc.com:8888” #新harbor

#提前登录一下

#docker login $BACK_HOST
for image in ${allimages}; do
docker pull ${ORIGIN_HOST}/$image
docker tag ${ORIGIN_HOST}/$image ${BACK_HOST}/$image
docker push ${BACK_HOST}/$image
sleep 1
echo $image “done”
done
`

使用Gitlab/Bitbucket等CI搭建自己的临时代理

这篇文章只是从技术层面探讨可行性,不接受一切反驳!

使用条件

  • 一个有外网的主机(frp需要)
  • gitlab或bitbucket账号

frp服务端搭建

具体可以查看frp github主页

下载对应你操作系统版本的包(我的docker打包的客户端是0.17.0版本,想使用新版的可以自行打包)

服务端配置如下(frps.ini):

1
2
3
[common]
bind_port = 7000
token = 123456

解压下载的压缩包,启动服务端: ./frps -c frps.ini

注意开通7000及需要frp客户端映射端口(这里用到了6200)

frp客户端

Gitlab参见 https://gitlab.com/0312birdzhang/frp_proxy

客户端配置如下(frpc.ini):

1
2
3
4
5
6
7
8
9
[common]
server_addr = 12.13.14.15
server_port = 7000
token = 123456

[socks_proxy_6200]
type = tcp
plugin = socks5
remote_port = 6200

fork代码后,需要修改server_addrserver_porttokenremote_port 为你服务器相关的,然后保存即可。

Bitbucket的参考:

bitbucket-pipelines.yml

image: 0312birdzhang/frpc_proxy:v2

pipelines:
  default:
    - step:
        caches:
          - pip
        script:
          - cp frpc.ini /app/my_frpc.ini
          - /app/frpc -c /app/my_frpc.ini

使用

12.13.14.15:6200 即是你的socks5代理地址

Nginx获取用户真实IP

首先强调的是,这里需要两层nginx,用户访问nginx1,转发到nginx2(192.168.1.111),nginx2到真实后端。

nginx1 配置

1
2
3
4
5
6
7
8
9
10
server{
...
listen 8888;
location /test {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $remote_addr;
proxy_pass http://nginx2:8888/test2;
}
}

nginx2 配置

1
2
3
4
5
6
7
8
9
server{
...
listen 8888;
location /test2 {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-real-ip $remote_addr;
default_type text/html;
return 200 'This is text!';
}

测试

用户访问

1
curl -i -H "X-Forwarded-For: 110.110.110.110" -H "X-real-ip: 110.110.110.110" -s nginx1:8888/test -v

nginx1 日志:

1
192.168.1.110 0.000 - [12/Sep/2018:11:01:51 +0800] "GET /test HTTP/1.1" 200 13 - "-" "curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.19.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2" 110.110.110.110 110.110.110.110

nginx2 日志:

1
192.168.1.111 0.000 - [12/Sep/2018:11:01:51 +0800] "GET /test2 HTTP/1.1" 200 13 - "-" "curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.19.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2" 192.168.1.110 110.110.110.110

其中192.168.1.111为nginx1的ip

可以看到,在nginx2中可以拿X-real-ip获取用户的真实ip,在后端中可以拿这个头信息。

注意!必须要规定好nginx是在架构的哪一层级,根据所处的层级配置,否则该方法无效。

Docker on SailfishOS

How to install Docker on SailfishOS/如何将Docker安装到SailfishOS

This post will show you how to install Docker on SailfishOS, and some hacks need to do.

这篇文章将介绍如何将Docker安装到SailfishOS上,和需要做的一些hack。

Prerequisites/先决条件

https://docs.docker.com/install/linux/docker-ce/binaries/#install-daemon-and-client-binaries-on-linux

  • A 64-bit installation
  • Version 3.10 or higher of the Linux kernel. The latest version of the kernel available for you platform is recommended.
  • iptables version 1.4 or higher
  • git version 1.7 or higher
  • A ps executable, usually provided by procps or a similar package.
  • XZ Utils 4.9 or higher
  • A properly mounted cgroupfs hierarchy; a single, all-encompassing cgroup mount point is not sufficient. See Github issues #2683, #3485, #4568).

  • 64位系统

  • 3.10内核或更高
  • iptable版本至少是1.4
  • git版本至少1.7
  • 可以执行ps
  • xz工具版本至少4.9
  • 正确安装的cgroupfs层次结构; 一个单一的,无所不包的cgroup挂载点是不够的。

Check Kernel support/检查内核支持

Use this script check-config.sh
使用这个脚本 check-config.sh

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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
[nemo@Sailfish ~]$ ./check-config.sh 
info: reading kernel config from /proc/config.gz ...

Generally Necessary:
- cgroup hierarchy: properly mounted [/sys/fs/cgroup]
- CONFIG_NAMESPACES: enabled
- CONFIG_NET_NS: enabled
- CONFIG_PID_NS: enabled
- CONFIG_IPC_NS: enabled
- CONFIG_UTS_NS: enabled
- CONFIG_CGROUPS: enabled
- CONFIG_CGROUP_CPUACCT: enabled
- CONFIG_CGROUP_DEVICE: enabled
- CONFIG_CGROUP_FREEZER: enabled
- CONFIG_CGROUP_SCHED: enabled
- CONFIG_CPUSETS: enabled
- CONFIG_MEMCG: enabled
- CONFIG_KEYS: enabled
- CONFIG_VETH: enabled
- CONFIG_BRIDGE: enabled
- CONFIG_BRIDGE_NETFILTER: enabled (as module)
- CONFIG_NF_NAT_IPV4: enabled
- CONFIG_IP_NF_FILTER: enabled
- CONFIG_IP_NF_TARGET_MASQUERADE: enabled
- CONFIG_NETFILTER_XT_MATCH_ADDRTYPE: enabled
- CONFIG_NETFILTER_XT_MATCH_CONNTRACK: enabled
- CONFIG_NETFILTER_XT_MATCH_IPVS: enabled
- CONFIG_IP_NF_NAT: enabled
- CONFIG_NF_NAT: enabled
- CONFIG_NF_NAT_NEEDED: enabled
- CONFIG_POSIX_MQUEUE: enabled
- CONFIG_DEVPTS_MULTIPLE_INSTANCES: enabled

Optional Features:
- CONFIG_USER_NS: enabled
- CONFIG_SECCOMP: enabled
- CONFIG_CGROUP_PIDS: missing
- CONFIG_MEMCG_SWAP: enabled
- CONFIG_MEMCG_SWAP_ENABLED: enabled
(cgroup swap accounting is currently enabled)
- CONFIG_MEMCG_KMEM: enabled
- CONFIG_RESOURCE_COUNTERS: enabled
- CONFIG_BLK_CGROUP: enabled
- CONFIG_BLK_DEV_THROTTLING: missing
- CONFIG_IOSCHED_CFQ: enabled
- CONFIG_CFQ_GROUP_IOSCHED: missing
- CONFIG_CGROUP_PERF: enabled
- CONFIG_CGROUP_HUGETLB: missing
- CONFIG_NET_CLS_CGROUP: enabled
- CONFIG_CGROUP_NET_PRIO: enabled
- CONFIG_CFS_BANDWIDTH: missing
- CONFIG_FAIR_GROUP_SCHED: enabled
- CONFIG_RT_GROUP_SCHED: enabled
- CONFIG_IP_VS: enabled
- CONFIG_IP_VS_NFCT: enabled
- CONFIG_IP_VS_RR: enabled
- CONFIG_EXT3_FS: enabled
- CONFIG_EXT3_FS_XATTR: enabled
- CONFIG_EXT3_FS_POSIX_ACL: enabled
- CONFIG_EXT3_FS_SECURITY: enabled
- CONFIG_EXT4_FS: enabled
- CONFIG_EXT4_FS_POSIX_ACL: missing
- CONFIG_EXT4_FS_SECURITY: enabled
enable these ext4 configs if you are using ext4 as backing filesystem
- Network Drivers:
- "overlay":
- CONFIG_VXLAN: enabled
Optional (for encrypted networks):
- CONFIG_CRYPTO: enabled
- CONFIG_CRYPTO_AEAD: enabled
- CONFIG_CRYPTO_GCM: enabled
- CONFIG_CRYPTO_SEQIV: enabled
- CONFIG_CRYPTO_GHASH: enabled
- CONFIG_XFRM: enabled
- CONFIG_XFRM_USER: enabled
- CONFIG_XFRM_ALGO: enabled
- CONFIG_INET_ESP: enabled
- CONFIG_INET_XFRM_MODE_TRANSPORT: enabled
- "ipvlan":
- CONFIG_IPVLAN: missing
- "macvlan":
- CONFIG_MACVLAN: enabled
- CONFIG_DUMMY: missing
- "ftp,tftp client in container":
- CONFIG_NF_NAT_FTP: enabled
- CONFIG_NF_CONNTRACK_FTP: enabled
- CONFIG_NF_NAT_TFTP: enabled
- CONFIG_NF_CONNTRACK_TFTP: enabled
- Storage Drivers:
- "aufs":
- CONFIG_AUFS_FS: missing
- "btrfs":
- CONFIG_BTRFS_FS: enabled
- CONFIG_BTRFS_FS_POSIX_ACL: enabled
- "devicemapper":
- CONFIG_BLK_DEV_DM: enabled
- CONFIG_DM_THIN_PROVISIONING: missing
- "overlay":
- CONFIG_OVERLAY_FS: enabled
- "zfs":
- /dev/zfs: missing
- zfs command: missing
- zpool command: missing

Limits:
- /proc/sys/kernel/keys/root_maxkeys: 1000000

[nemo@Sailfish ~]$

Generally Necessary must be all enabled, if not enabled, you must enable it in your kernel defconfig, and rebuild kernel.
Generally Necessary 部分必须全部是enabled, 如果没有启用,必须启用然后重启编译内核。

Download the static binary archive/下载静态二进制文件

https://download.docker.com/linux/static/stable/aarch64/

Extract the archive and put them to /usr/bin/, 18.06 is a working version.

Add nemo to docker group/将nemo用户添加到docker组

1
2
groupadd docker
usermod -a -G docker nemo

Run Docker/启动Docker

Start docker daemon/ 启动docker守护进程
devel-su /usr/bin/dockerd

Or use systemd/ 或者使用systemd

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target

[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TimeoutStartSec=0
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target

Check version/检查版本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@Sailfish nemo]# docker version

Client:
Version: 18.06.1-ce
API version: 1.38
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:20:38 2018
OS/Arch: linux/arm64
Experimental: false

Server:
Engine:
Version: 18.06.1-ce
API version: 1.38 (minimum version 1.12)
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:27:20 2018
OS/Arch: linux/arm64
Experimental: false

Test/测试
devel-su docker run hello-world

This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits. / 这个命令会下载一个测试镜像,如果执行成功会打印如下信息

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
[root@Sailfish nemo]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
255483503861: Pull complete
Digest: sha256:4b8ff392a12ed9ea17784bd3c9a8b1fa3299cac44aca35a85c90c5e3c7afacdc
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(arm64v8)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/

Test network mapping /测试网络映射

On one terminal/在一个终端中执行

1
2
3
[root@Sailfish nemo]# docker run -it --rm -p 6080:80 nginx:latest        
172.17.0.1 - - [05/Sep/2018:08:54:52 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.58.0-DEV" "-"
172.17.0.1 - - [05/Sep/2018:08:55:51 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.58.0-DEV" "-"

Vist on another terminal/在另一个终端中访问

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
[nemo@Sailfish ~]$ curl -s 127.0.0.1:6080
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
[nemo@Sailfish ~]$

TODO

Wayland forward /wayland转发

Reference/参考:

Have fun ;)

从iOS迁移到SailfishOS计划

本文作为一个实验性计划,从iOS迁移到SailfishOS

首先我们来整理一下软件替代品

  • 即时通讯类
  • 拍照类
  • 金融类
  • 新闻类
  • 文本阅读类
  • 浏览器
  • 地图导航类
  • 智能穿戴设备手机端
  • SNS类
  • 一些工具类

下面展开以上几种类型有哪些及替代品

即时通讯类

  • QQ
  • 微信
  • Telegram
  • IRC

拍照类

  • 暂无需求

新闻类

  • IT之家等
  • 网易新闻等

文本阅读类

  • 暂无需求

浏览器

  • Chrome

地图导航类

  • 高德地图

智能穿戴设备手机端

  • 暂无

SNS类

  • 微博

一些工具类

  • 翻译/查询快递/等等

#### 未完待续…

本文准备弃坑

参考如下:

https://raimue.blog/2018/01/09/goodbye-sailfish-os-and-jolla/

清理kubernetes中未正常退出的pod

长时间运行的k8s节点可能会存在某些pod不自动退出,一直处于Terminating的状态
于是我们可以用这个脚本定时进行清理

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
#!/bin/bash
#############################
### clean terminated pods ###
### run at you own risk ! ###
#############################
export PATH=/usr/local/cfssl/bin:/usr/local/docker/:/usr/local/kubernetes/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
getns(){
namespaces=`kubectl get namespaces|grep -v "NAME"|awk '{print $1}'`
for n in ${namespaces};
do
pods_str=`kubectl get pods -n ${n}|grep "Terminating"`
IFS=$'\n' read -rd '' -a pods <<<"$pods_str"
if [ -n "$pods" ]; then
getpod ${n} $pods;
fi
done
}
getpod(){
ns=$1;
for podinfo in $2;
do
pod=`echo $podinfo|awk '{print $1}'`
delpod $pod $ns;
done
}
delpod(){
echo "kubectl delete pods $1 -n $2 --grace-period=0 --force"
kubectl delete pods $1 -n $2 --grace-period=0 --force
}
main(){
getns
}
main