记录一下服务器重装过程。

System Info

OS: Ubuntu 22.04.4 LTS x86_64

挂载数据盘

mkdir /data && mount /dev/sdb1 /data

mkdir /data && mount /dev/sda1 /data

换源

更换为USTC的源

sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list
sed -i 's/security.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
sed -i 's/http:/https:/g' /etc/apt/sources.list

更新软件包:

apt-get update -y && apt-get upgrade -y

将语言设置为中文

生成简体中文环境支持文件

locale-gen zh_CN.UTF-8

安装语言包

apt-get install language-pack-zh-hans language-pack-zh-hant -y

安装字符集

cd /usr/share/locales && ./install-language-pack zh_CN 

安装中文字体

apt install fonts-noto-cjk fonts-noto-color-emoji -y

将语言配置写入 /etc/profile 文件

sed -i '$a export LANG=zh_CN.UTF-8\nexport LANGUAGE=zh_CN:zh' /etc/profile

使配置生效

source /etc/profile

验证是否生效

locale

如果生效了,终端应该会有如下的输出:

LANG=zh_CN.UTF-8
LANGUAGE=zh_CN:zh
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=

更改时区

修改时区为上海

timedatectl set-timezone Asia/Shanghai

生效配置

systemctl restart systemd-timesyncd

安装必要软件包

apt-get install neofetch zip unzip openjdk-17-jre-headless dotnet-runtime-8.0 python3-pip python3.10-venv -y

安装 MCSManager

sudo wget -qO- https://gitee.com/mcsmanager/script/raw/master/setup_cn.sh | bash

Yunzai 相关

安装 Redis

apt install redis-server -y

添加 Node.js 源

curl -sL https://deb.nodesource.com/setup_21.x | sudo -E bash -

安装 Node.js

apt-get install nodejs -y

npm换源

npm config set registry https://registry.npmmirror.com

安装pnpm

npm i pnpm -g

安装Chrome

npx puppeteer browsers install chrome

安装缺失的库

apt-get install -y libatk1.0-dev libatk-bridge2.0-dev libxcomposite-dev libxdamage-dev libxrandr-dev libgbm-dev libxkbcommon-dev

Nonebot 相关

pip换源

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

安装pipx

pip install pipx

添加到环境变量

pipx ensurepath

安装脚手架

pip install nb-cli

激活一个虚拟环境

source .venv/bin/activate

安装playwright依赖

apt-get install libatk1.0-0 libatk-bridge2.0-0 libxkbcommon0 libatspi2.0-0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 -y

Lagrange appsettings.json

{
    "Logging": {
        "LogLevel": {
            "Default": "Information",
            "Microsoft": "Warning",
            "Microsoft.Hosting.Lifetime": "Information"
        }
    },
    "SignServerUrl": "",
    "Account": {
        "Uin": 0,
        "Password": "",
        "Protocol": "Linux",
        "AutoReconnect": true,
        "GetOptimumServer": true
    },
    "Message": {
      "IgnoreSelf": true
    },
    "Implementations": [
      {
        "Type": "ForwardWebSocket",
        "Host": "0.0.0.0",
        "Port": 8080,
        "HeartBeatInterval": 5000,
        "AccessToken": ""
      },
      {
        "Type": "ForwardWebSocket",
        "Host": "0.0.0.0",
        "Port": 8081,
        "HeartBeatInterval": 5000,
        "AccessToken": ""
      },
      {
        "Type": "ForwardWebSocket",
        "Host": "0.0.0.0",
        "Port": 8082,
        "HeartBeatInterval": 5000,
        "AccessToken": ""
      },
      {
        "Type": "ForwardWebSocket",
        "Host": "0.0.0.0",
        "Port": 8083,
        "HeartBeatInterval": 5000,
        "AccessToken": ""
      },
      {
        "Type": "ForwardWebSocket",
        "Host": "0.0.0.0",
        "Port": 8084,
        "HeartBeatInterval": 5000,
        "AccessToken": ""
      },
      {
        "Type": "ForwardWebSocket",
        "Host": "0.0.0.0",
        "Port": 8085,
        "HeartBeatInterval": 5000,
        "AccessToken": ""
      }
    ]
}