Home

Awesome

前言

Hits

所有脚本如需在国内服务器使用,请在链接前加上https://cdn.spiritlhl.net/确保命令可以下载本仓库的shell脚本执行

目录

一键修复脚本

运行所有一键修复脚本前注意看说明,以及保证服务器无重要数据,运行后造成的一切后果作者不负任何责任,自行评判风险!

一键尝试修复apt源

curl -L https://raw.githubusercontent.com/spiritLHLS/one-click-installation-script/main/repair_scripts/package.sh -o package.sh && chmod +x package.sh && bash package.sh

一键尝试修复系统时间

curl -L https://raw.githubusercontent.com/spiritLHLS/one-click-installation-script/main/repair_scripts/modify_time.sh -o modify_time.sh && chmod +x modify_time.sh && bash modify_time.sh

一键尝试修复sudo警告

不要在生产环境上使用该脚本,否则容易造成网络hosts配置错误,配置的host名字不在外网IP上反而在内网IP(127.0.0.1)上

curl -L https://raw.githubusercontent.com/spiritLHLS/one-click-installation-script/main/repair_scripts/check_sudo.sh -o check_sudo.sh && chmod +x check_sudo.sh && bash check_sudo.sh

一键修改系统自带的journal日志记录大小释放系统盘空间

curl -L https://raw.githubusercontent.com/spiritLHLS/one-click-installation-script/main/repair_scripts/resize_journal.sh -o resize_journal.sh && chmod +x resize_journal.sh && bash resize_journal.sh

一键尝试修复网络

该脚本轻易勿要使用,请确保运行时服务器无重要文件或程序,出现运行bug后续可能需要重装系统

一定要在screen中执行该脚本,否则可能导致修改过程中ssh断链接而修改失败卡住最终SSH无法连接!不在screen中执行后果自负!

curl -L https://cdn.spiritlhl.workers.dev/https://raw.githubusercontent.com/spiritLHLS/one-click-installation-script/main/repair_scripts/network.sh -o network.sh && chmod +x network.sh && bash network.sh

如果是纯V6的也可以不使用上面脚本的nat64,使用warp添加V4网络

比如:https://gitlab.com/fscarmen/warp

wget -N https://gitlab.com/fscarmen/warp/-/raw/main/menu.sh && bash menu.sh [option] [lisence/url/token]

非纯V6的,带V4切换优先级到IPV4可用以下命令

sudo sed -i 's/.*precedence ::ffff:0:0\/96.*/precedence ::ffff:0:0\/96  100/g' /etc/gai.conf && sudo systemctl restart networking

一键解除进程数限制

curl -L https://raw.githubusercontent.com/spiritLHLS/one-click-installation-script/main/repair_scripts/unlimit.sh -o unlimit.sh && chmod +x unlimit.sh && bash unlimit.sh

一键环境安装脚本

只推荐在新服务器上安装,环境不纯净不保证不出bug

运行所有一键环境安装脚本前注意看说明,以及保证服务器无重要数据,运行后造成的一切后果作者不负任何责任,自行评判风险!

一键安装jupyter环境

原始用途是方便快捷的在按小时计费的超大型服务器上部署python环境进行科学计算,充分利用时间别浪费在构建环境上。

curl -L https://raw.githubusercontent.com/spiritLHLS/one-click-installation-script/main/install_scripts/jupyter.sh -o jupyter.sh && chmod +x jupyter.sh && bash jupyter.sh

一键安装R语言环境

curl -L https://raw.githubusercontent.com/spiritLHLS/one-click-installation-script/main/install_scripts/R.sh -o R.sh && chmod +x R.sh && bash R.sh

一键安装rust环境

curl -L https://raw.githubusercontent.com/spiritLHLS/one-click-installation-script/main/install_scripts/rust.sh -o rust.sh && chmod +x rust.sh && bash rust.sh 

一键安装C环境

curl -L https://raw.githubusercontent.com/spiritLHLS/one-click-installation-script/main/install_scripts/cplusplus.sh -o cplusplus.sh && chmod +x cplusplus.sh && bash cplusplus.sh 

一键安装vnstat环境

curl -L https://raw.githubusercontent.com/spiritLHLS/one-click-installation-script/main/install_scripts/vnstat.sh -o vnstat.sh && chmod +x vnstat.sh && bash vnstat.sh 

一键升级低版本debian为debian11

curl -L https://raw.githubusercontent.com/spiritLHLS/one-click-installation-script/main/install_scripts/todebian11.sh -o todebian11.sh && chmod +x todebian11.sh && bash todebian11.sh

一键升级低版本ubuntu为ubuntu22

curl -L https://raw.githubusercontent.com/spiritLHLS/one-click-installation-script/main/install_scripts/toubuntu22.sh -o toubuntu22.sh && chmod +x toubuntu22.sh && bash toubuntu22.sh

一键安装zipline平台

curl -L https://raw.githubusercontent.com/spiritLHLS/one-click-installation-script/main/install_scripts/zipline.sh -o zipline.sh && chmod +x zipline.sh && bash zipline.sh

如果需要删除0字节文件,打开/root/zipline文件夹,执行

docker-compose exec zipline yarn scripts:clear-zero-byte

按照提示操作

一键安装filebrowser平台

curl -L https://raw.githubusercontent.com/spiritLHLS/one-click-installation-script/main/install_scripts/filebrowser.sh -o filebrowser.sh && chmod +x filebrowser.sh && bash filebrowser.sh

一键删除平台监控

curl -L https://raw.githubusercontent.com/spiritLHLS/one-click-installation-script/main/install_scripts/dlm.sh -o dlm.sh && chmod +x dlm.sh && bash dlm.sh

部分手动命令

一键开启root登陆并替换密码

bash <(curl -sSL https://raw.githubusercontent.com/fscarmen/tools/main/root.sh) [PASSWORD]

一键屏蔽邮件端口避免被恶意程序使用

iptables -A INPUT -p tcp --dport 25 -j DROP
iptables -A OUTPUT -p tcp --dport 25 -j DROP
/sbin/iptables-save

设置语言包

sudo apt update
sudo apt install -y locales
sudo locale-gen en_US.UTF-8
echo 'LANG=en_US.UTF-8' | sudo tee /etc/default/locale
echo 'LC_ALL=en_US.UTF-8' | sudo tee -a /etc/default/locale
sudo sed -i '/^#.* en_US.UTF-8 /s/^#//' /etc/locale.gen
sudo locale-gen
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale

重新连接SSH或重启服务器以使得设置生效

ubuntu更新源被锁

sudo rm -rf /var/cache/apt/archives/lock
sudo pkill apt
sudo rm /var/lib/dpkg/lock-frontend
sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock
sudo dpkg --configure -a

然后重启系统

debian缺失公钥

apt-get install debian-keyring debian-archive-keyring -y

ubuntu或debian缺失公钥

后续这块有计划整理为一个一键脚本

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 公钥

centos换源

sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
sudo sed -i 's/^mirrorlist=http/mirrorlist=https/' /etc/yum.repos.d/CentOS-Base.repo

安装gitea

安装时使用这里的方法:

https://gitlab.com/packaging/gitea

但不要设置无人值守自动升级版本,容易升级到一个有BUG的新版本

更改默认配置需要更改文件/etc/gitea/app.ini

比如设置文件上传无限制

[repository.upload]
ENABLED = true
ALLOWED_TYPES =
FILE_MAX_SIZE = 1024
MAX_FILES = 100

写在[security]上面,每个模块[]的内容之间间隔一个空行

卸载aapanel

apt install sysv-rc-conf -y && service bt stop && sysv-rc-conf bt off && rm -f /etc/init.d/bt && rm -rf /www/server/panel

查询是什么东西占用硬盘大于100M

find / -type f -size +100M -exec ls -lh {} \;

卸载dns缓存机制避免配置覆写

systemctl stop systemd-resolved
systemctl disable systemd-resolved

安装docker和docker-compose

安装24版本的docker

curl -sSL https://get.docker.com/ | sh

或安装最新版本的docker(都选官方源即可)

bash <(curl -sSL https://linuxmirrors.cn/docker.sh)

安装docker-compose最新版本

curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-linux-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version

卸载所有docker镜像和容器

docker rm -f $(docker ps -aq); docker rmi $(docker images -aq)

删除累积的docker日志

cd /var/lib/docker/containers/ && for container_id in */; do container_path="/var/lib/docker/containers/${container_id}"; log_file="${container_id%/}-json.log"; rm -rf "${container_path}${log_file}" && echo "已删除 ${container_path}${log_file}"; done

通过docker安装code-server

安装

mkdir -p ~/.config
docker run --restart=always --name code-server -p 0.0.0.0:8886:8080 \
  -v "$HOME/.config:/home/coder/.config" \
  -v "$PWD:/home/coder/project" \
  -u "$(id -u):$(id -g)" \
  -e "DOCKER_USER=$USER" \
  codercom/code-server:latest

新窗口

docker exec code-server cat /root/.config/code-server/config.yaml

curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run
sudo systemctl enable --now code-server@root
sed -i '1s/127.0.0.1:8080/0.0.0.0:8536/' ~/.config/code-server/config.yaml
sudo systemctl restart code-server@root
cat .config/code-server/config.yaml

卸载需要

sudo systemctl stop code-server@root
sudo systemctl disable code-server@root
rm -rf ~/.cache/coder
sudo apt remove coder -y

友链

一键测试服务器的融合怪脚本

https://github.com/spiritLHLS/ecs

一键批量开NAT服务器的LXD脚本

https://github.com/spiritLHLS/lxd

一键安装PVE和使用PVE批量开设虚拟机的脚本

https://github.com/spiritLHLS/pve

朋友fscarmen的常用一键工具仓库

https://github.com/fscarmen/tools