#!/bin/bash # 安装必需软件包 apt-get update apt-get install -y bash-completion chrony htop jq lrzsz ngrep pv rsync tmux vim wget apt-get install -y python3-dev libmysqlclient-dev python3-pip gcc # 配置 sysctl curl https://phus.lu/sysctl.conf | tee /etc/sysctl.d/10-phuslu.conf sysctl --system # 禁用防火墙(ufw 是 Debian 默认防火墙) systemctl disable ufw || true systemctl stop ufw || true # 设置资源限制 echo -e "* soft nofile 1048576\n* hard nofile 1048576" | tee /etc/security/limits.d/99-phuslu.conf # 为中国服务器配置镜像 curl ip.phus.lu | grep -i china && ( cat </dev/null || ( adduser --disabled-password --gecos "" debian echo 'debian ALL=(ALL) NOPASSWD:ALL' | tee /etc/sudoers.d/10-debian chmod 0440 /etc/sudoers.d/10-debian mkdir -p /home/debian/.ssh curl -sS https://github.com/phuslu.keys | tee /home/debian/.ssh/authorized_keys chown -R debian:debian /home/debian/.ssh chmod 0700 /home/debian/.ssh chmod 0600 /home/debian/.ssh/authorized_keys ) # 为用户 'debian' 安装 z.sh test -f /home/debian/.z.sh || ( su - debian -c 'cd; curl https://phus.lu/bashrc | grep ^# | tail -n +2 | cut -b3- | grep ^curl | bash -xe' )