#!/bin/sh
apt update
apt install wget curl bash-completion gnupg2 pciutils command-not-found -y

update-command-not-found
apt update

cat > /root/.bashrc << "EOF"
# ~/.bashrc: executed by bash(1) for non-login shells.

# Note: PS1 and umask are already set in /etc/profile. You should not
# need this unless you want different defaults for root.
# PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ '
umask 022

# You may uncomment the following lines if you want `ls' to be colorized:
export LS_OPTIONS='--color=auto'
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'
PS1='\[\033[01;31m\]\u\[\033[00m\]@\[\033[01;32m\]\h:\[\033[00m\]\w\$ '
# Some more alias to avoid making mistakes:
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias grep='grep --color=auto'
EOF

cat > /etc/motd << EOF
EOF

cat > /etc/update-motd.d/10-uname << "EOF"
#!/bin/sh
/usr/local/bin/screenfetch -n
EOF

ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
echo 'Asia/Shanghai' >/etc/timezone

cat > /etc/apt/sources.list << "EOF"
deb http://deb.debian.org/debian bullseye main contrib non-free
deb http://deb.debian.org/debian bullseye-updates main contrib non-free
deb http://security.debian.org/debian-security bullseye-security main
deb http://ftp.debian.org/debian bullseye-backports main contrib non-free
EOF

cat >> '/etc/profile' << "EOF"
ulimit -SHn 51200
EOF

cat > '/etc/sysctl.conf' << "EOF"
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_forward=1
net.ipv4.tcp_no_metrics_save = 1
net.ipv4.tcp_mtu_probing = 1
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
EOF

cat > '/etc/systemd/system.conf' << "EOF"
[Manager]
#DefaultTimeoutStartSec=90s
DefaultTimeoutStopSec=30s
#DefaultRestartSec=100ms
DefaultLimitCORE=infinity
DefaultLimitNOFILE=51200
DefaultLimitNPROC=51200
EOF

cat > '/etc/security/limits.conf' << "EOF"
* soft nofile 51200
* hard nofile 51200
* soft nproc 51200
* hard nproc 51200
EOF

mkdir /root/.ssh
touch /root/.ssh/authorized_keys

wget -O /usr/local/bin/screenfetch https://down.aliwap.cf/Linxu/screenfetch
chmod +x /usr/local/bin/screenfetch

wget -O /usr/local/bin/besttrace https://down.aliwap.cf/Linux/besttrace
chmod +x /usr/local/bin/besttrace

curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | bash
apt install speedtest -y
