centos
已经被“招安”了,取而代之的是rockylinux
,本文记录我自己的配置,主要需求是使用termux
安装rockylinux
文件系统,并使用supervisor
自启动code-server
安装termux
从https://github.com/termux/termux-app/releases/
获取最新的安装包
目前最新的是v0.118.1,安卓机一般是选arm64-v8
的版本
配置ssh
手机输入命令总归有点不习惯,还是用电脑ssh登陆比较好
# 更新当前包版本,以防有不兼容
pkg update
# 安装openssh
pkg install openssh
# 启动ssh服务
sshd
# 配置termux密码
passwd
# 通过本机wifi获取手机ip,电脑在同一局域网下进行 `ssh root@手机ip -p 8022` 连接
安装proot-distro
pkg install proot-distro
配置proot-distro支持自定义镜像
(可选)获取最新rocky linux rootfs
往https://rockylinux.org/download
找最新的文件目录,选择ARM
版本的image
。
或者直接查看目录https://download.rockylinux.org/pub/rocky/9/images/
或者国内阿里云镜像https://mirrors.aliyun.com/rockylinux/9/images
,按照cpu架构(安卓9手机一般是aarch64
arm最新架构),获取镜像地址https://mirrors.aliyun.com/rockylinux/9/images/aarch64/Rocky-9-Container-Base.latest.aarch64.tar.xz
,以及checksumhttps://mirrors.aliyun.com/rockylinux/9/images/aarch64/Rocky-9-Container-Base-9.4-20240523.0.aarch64.tar.xz.CHECKSUM
里的SHA256信息更新到以下rocky9.sh
脚本,如果不需要直接使用即可
配置proot-distro rocky9镜像
cat << EOF > $HOME/../../files/usr/etc/proot-distro/rocky9.sh
# This is a default distribution plug-in.
# Do not modify this file as your changes will be overwritten on next update.
# If you want customize installation, please make a copy.
DISTRO_NAME="Rocky Linux"
DISTRO_COMMENT="Latest Release."TARBALL_MIRROR_URL="https://mirrors.aliyun.com/rockylinux"TARBALL_URL['aarch64']="\${TARBALL_MIRROR_URL}/9/images/aarch64/Rocky-9-Container-Base-9.4-20240523.0.aarch64.tar.xz"
TARBALL_SHA256['aarch64']="ccc9fbef24be4d64e6430f4f5738a4c9f3ca6994ba174647fddec1f3e2714b54"
TARBALL_URL['x86_64']="\${TARBALL_MIRROR_URL}/9/images/x86_64/Rocky-9-Container-Base-9.4-20240523.0.x86_64.tar.xz"
TARBALL_SHA256['x86_64']="c629dd41510cbe273a73b76c7d4e4a549d2c2192fce59dc89d5549b95edfd6ca"
EOF
安装&配置 rocky9 linux 文件系统
proot-distro install rocky9
# 登陆子系统
proot-distro login rocky9
安装&配置code-server
[root@localhost ~]curl -fsSL https://code-server.dev/install.sh | sh
# (可选)如果太慢可以选择使用github镜像加速hub.gitmirror.com等
# curl -fsSL https://code-server.dev/install.sh |sed 's#https://github.com#https://hub.gitmirror.com/https://github.com#g' | sh
[root@localhost ~]code-server
[root@localhost ~]vi .config/code-server/config.yaml
修改文件中的bind-addr和password
bind-addr: 0.0.0.0:8080
auth: password
password: 你的密码
cert: false
安装 supervisor 管理code-server
[root@localhost ~] dnf install epel-release
[root@localhost ~] dnf install supervisor
[root@localhost ~] mkdir .log
[root@localhost ~] cat << EOF > /etc/supervisord.d/vscode.ini
[program:vscode]
command=code-server
autorestart=true
redirect_stderr=true
stdout_logfile = ~/.log/vscodeserver.log
loglevel=info
autostart=true
EOF
[root@localhost ~] supervisord -c /etc/supervisor/supervisord.conf