├── .github └── FUNDING.yml ├── LICENSE ├── README.md ├── back ├── conda.md ├── debian.txt └── ubuntu.txt ├── install_scripts ├── FOSSBilling-compose.yml ├── R.sh ├── cplusplus.sh ├── dlm.sh ├── filebrowser.sh ├── fossbilling.sh ├── golang.sh ├── jupyter.sh ├── rust.sh ├── todebian11.sh ├── toubuntu22.sh ├── vnstat.sh └── zipline.sh └── repair_scripts ├── check_sudo.sh ├── modify_time.sh ├── nat64_optimizer.sh ├── network.sh ├── package.sh ├── resize_journal.sh └── unlimit.sh /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: spiritlhl 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 spiritLHLS 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 前言 2 | 3 | [![Hits](https://hits.spiritlhl.net/one-click-installation-script.svg?action=hit&title=Hits&title_bg=%23555555&count_bg=%2324dde1&edge_flat=false)](https://hits.spiritlhl.net) 4 | 5 | 所有脚本如需在国内服务器使用,请在链接前加上```https://cdn.spiritlhl.net/```确保命令可以下载本仓库的shell脚本执行 6 | 7 | # 目录 8 | 9 | * [一键修复脚本](#一键修复脚本) 10 | * [一键尝试修复apt源](#一键尝试修复apt源) 11 | * [一键尝试修复系统时间](#一键尝试修复系统时间) 12 | * [一键尝试修复sudo警告](#一键尝试修复sudo警告) 13 | * [一键修改系统自带的journal日志记录大小释放系统盘空间](#一键修改系统自带的journal日志记录大小释放系统盘空间) 14 | * [一键尝试修复网络](#一键尝试修复网络) 15 | * [一键给纯IPV6服务器添加最优的nat64网络](#一键给纯IPV6服务器添加最优的nat64网络) 16 | * [一键解除进程数限制](#一键解除进程数限制) 17 | * [一键环境安装脚本](#一键环境安装脚本) 18 | * [一键安装golang环境](#一键安装golang环境) 19 | * [一键安装jupyter环境](#一键安装jupyter环境) 20 | * [一键安装R语言环境](#一键安装R语言环境) 21 | * [一键安装rust环境](#一键安装rust环境) 22 | * [一键安装C++环境](#一键安装C环境) 23 | * [一键安装vnstat环境](#一键安装vnstat环境) 24 | * [一键升级低版本debian为debian11](#一键升级低版本debian为debian11) 25 | * [一键升级低版本ubuntu为ubuntu22](#一键升级低版本ubuntu为ubuntu22) 26 | * [一键安装zipline平台](#一键安装zipline平台) 27 | * [一键安装filebrowser平台](#一键安装filebrowser平台) 28 | * [一键删除平台监控](#一键删除平台监控) 29 | * [部分手动命令](#部分手动命令) 30 | * [一键开启root登陆并替换密码](#一键开启root登陆并替换密码) 31 | * [一键屏蔽邮件端口避免被恶意程序使用](#一键屏蔽邮件端口避免被恶意程序使用) 32 | * [设置语言包](#设置语言包) 33 | * [ubuntu更新源被锁](#ubuntu更新源被锁) 34 | * [debian缺失公钥](#debian缺失公钥) 35 | * [ubuntu或debian缺失公钥](#ubuntu或debian缺失公钥) 36 | * [centos换源](#centos换源) 37 | * [安装gitea](#安装gitea) 38 | * [卸载aapanel](#卸载aapanel) 39 | * [查询是什么东西占用硬盘大于100M](#查询是什么东西占用硬盘大于100M) 40 | * [卸载dns缓存机制避免配置覆写](#卸载dns缓存机制避免配置覆写) 41 | * [安装docker和docker-compose](#安装docker和docker-compose) 42 | * [通过docker安装code-server](#通过docker安装code-server) 43 | * [友链](#友链) 44 | * [一键测试服务器的融合怪脚本](#一键测试服务器的融合怪脚本) 45 | * [一键批量开NAT服务器LXC](#一键批量开NAT服务器LXC) 46 | * [一键安装PVE](#一键安装PVE) 47 | * [朋友fscarmen的常用一键工具仓库](#朋友fscarmen的常用一键工具仓库) 48 | 49 | ## 一键修复脚本 50 | 51 | 运行所有一键修复脚本前注意看说明,以及保证服务器无重要数据,运行后造成的一切后果作者不负任何责任,自行评判风险! 52 | 53 | #### 一键尝试修复apt源 54 | 55 | - 支持系统:Ubuntu 12+,Debian 6+ 56 | - 修复apt下载包进程意外退出导致的源锁死 57 | - 修复apt源broken损坏 58 | - 修复apt源多进程占用锁死 59 | - 修复apt源公钥缺失 60 | - 修复替换系统可用的apt源列表,国内用阿里源,国外用官方源 61 | - 修复本机的Ubuntu系统是EOL非长期维护的版本(奇数或陈旧的偶数版本),将替换为Ubuntu官方的old-releases仓库以支持apt的使用 62 | - 修复只保证```apt update```不会报错,其他命令报错未修复 63 | - 如若修复后install还有问题,重启服务器解决问题 64 | 65 | ```bash 66 | 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 67 | ``` 68 | 69 | #### 一键尝试修复系统时间 70 | 71 | - 支持系统:Ubuntu 18+,Debian 8+,centos 7+,Fedora,Almalinux 8.5+ 72 | - 由于系统时间不准确都是未进行时区时间同步造成的,使用chronyd进行时区时间同步后应当解决了问题 73 | 74 | ```bash 75 | 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 76 | ``` 77 | 78 | #### 一键尝试修复sudo警告 79 | 80 | - 一键尝试修复```sudo: unable to resolve host xxx: Name or service not known```警告(爆错) 81 | 82 | 不要在生产环境上使用该脚本,否则容易造成网络hosts配置错误,配置的host名字不在外网IP上反而在内网IP(127.0.0.1)上 83 | 84 | ```bash 85 | 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 86 | ``` 87 | 88 | #### 一键修改系统自带的journal日志记录大小释放系统盘空间 89 | 90 | - 支持系统:Ubuntu 18+,Debian 8+,centos 7+,Fedora,Almalinux 8.5+ 91 | - 1.自定义修改大小,单位为MB,一般500或者1000即可,有的系统日志默认给了5000甚至更多,不是做站啥的没必要 92 | - 请注意,修改journal目录大小会影响系统日志的记录,因此,在修改journal目录大小之前如果需要之前的日志,建议先备份系统日志到本地 93 | - 2.自定义修改设置系统日志保留日期时长,超过日期时长的日志将被清除 94 | - 3.默认修改日志只记录warning等级(无法自定义) 95 | - 4.以后日志的产生将受到日志文件大小,日志保留时间,日志保留等级的限制 96 | 97 | ```bash 98 | 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 99 | ``` 100 | 101 | #### 一键尝试修复网络 102 | 103 | **该脚本轻易勿要使用,请确保运行时服务器无重要文件或程序,出现运行bug后续可能需要重装系统** 104 | 105 | **一定要在screen中执行该脚本,否则可能导致修改过程中ssh断链接而修改失败卡住最终SSH无法连接!不在screen中执行后果自负!** 106 | - 支持系统:Ubuntu 18+,Debian 8+,centos 7+,Fedora,Almalinux 8.5+ 107 | - 尝试修复nameserver为google源或cloudflare源 108 | - 尝试修复为IP类型对应的网络优先级(默认IPV4类型,纯V6类型再替换为IPV6类型) 109 | 110 | ```bash 111 | 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 112 | ``` 113 | 114 | 如果是纯V6的也可以不使用上面脚本的nat64,使用warp添加V4网络 115 | 116 | 比如:https://gitlab.com/fscarmen/warp 117 | 118 | ```bash 119 | wget -N https://gitlab.com/fscarmen/warp/-/raw/main/menu.sh && bash menu.sh [option] [lisence/url/token] 120 | ``` 121 | 122 | 非纯V6的,带V4切换优先级到IPV4可用以下命令 123 | 124 | ```bash 125 | sudo sed -i 's/.*precedence ::ffff:0:0\/96.*/precedence ::ffff:0:0\/96 100/g' /etc/gai.conf && sudo systemctl restart networking 126 | ``` 127 | 128 | #### 一键给纯IPV6服务器添加最优的nat64网络 129 | 130 | ```bash 131 | curl -L https://cdn.spiritlhl.workers.dev/https://raw.githubusercontent.com/spiritLHLS/one-click-installation-script/main/repair_scripts/nat64_optimizer.sh -o nat64_optimizer.sh && chmod +x nat64_optimizer.sh && bash nat64_optimizer.sh 132 | ``` 133 | 134 | #### 一键解除进程数限制 135 | 136 | ```bash 137 | 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 138 | ``` 139 | 140 | ## 一键环境安装脚本 141 | 142 | 只推荐在新服务器上安装,环境不纯净不保证不出bug 143 | 144 | 运行所有一键环境安装脚本前注意看说明,以及保证服务器无重要数据,运行后造成的一切后果作者不负任何责任,自行评判风险! 145 | 146 | #### 一键安装golang环境 147 | 148 | ```shell 149 | curl -L https://raw.githubusercontent.com/spiritLHLS/one-click-installation-script/main/install_scripts/golang.sh -o golang.sh && chmod +x golang.sh && bash golang.sh 150 | ``` 151 | 152 | #### 一键安装jupyter环境 153 | 154 | - **本脚本尝试使用Miniconda3安装虚拟环境jupyter-env再进行jupyter和jupyterlab的安装,如若安装机器不纯净勿要轻易使用本脚本!** 155 | - **本脚本为实验性脚本可能会有各种bug,勿要轻易尝试!** 156 | - 验证已支持的系统: 157 | - Ubuntu 系 - 推荐,脚本自动挂起到后台 158 | - Debian 系 - 部分可能需要手动挂起到后台,详看脚本运行安装完毕的后续提示 159 | - 可能支持的系统(未验证):centos 7+,Fedora,Almalinux 8.5+ 160 | - 执行脚本,之前有用本脚本安装过则直接打印设置的登陆信息,没安装过则进行安装再打印信息,如果已安装但未启动则自动启动后再打印信息 161 | - 如果是初次安装无脑输入y回车即可,按照提示进行操作即可,安装完毕将在后台常驻运行,自动添加常用的安装包通道源 162 | - 安装完毕后,如果需要在lab中安装第三方库需要在lab中使用terminal并使用conda进行下载而不是pip3下载,这是需要注意的一点 163 | - 安装过程中有判断是否为中国IP,可选择是否使用中国镜像 164 | 165 | 原始用途是方便快捷的在按小时计费的超大型服务器上部署python环境进行科学计算,充分利用时间别浪费在构建环境上。 166 | 167 | ```bash 168 | 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 169 | ``` 170 | 171 | 如果有别的环境需求,推荐宿主机安装好docker环境后,使用 https://github.com/oneclickvirt/dockerfile-templates/ 自行制作在线IDE镜像,后续使用只需要挂载共享文件夹即可开设容器进行使用 172 | 173 | #### 一键安装R语言环境 174 | 175 | - **安装前需使用Miniconda3安装虚拟环境jupyter-env,然后进行jupyter和jupyterlab的安装,再然后才能安装本内核** 176 | - **简单的说,需要执行本仓库对应的jupyter安装脚本再运行本脚本安装R语言环境,会自动安装R环境内核和图形设备支持库** 177 | - x11可能需要手动启动一下,执行```sudo /usr/bin/Xorg``` 178 | - 可能支持的系统(未验证):centos 7+,Fedora,Almalinux 8.5+ 179 | 180 | ```bash 181 | 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 182 | ``` 183 | 184 | #### 一键安装rust环境 185 | 186 | - 支持系统:Ubuntu 18+,Debian 8+,centos 7+,Fedora,Almalinux 8.5+ 187 | - 加载官方脚本安装,前置条件适配系统以及后置条件判断安装的版本 188 | 189 | ```bash 190 | 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 191 | ``` 192 | 193 | #### 一键安装C环境 194 | 195 | - 一键安装C++环境 196 | - 支持系统:使用apt或者yum作为包管理器的系统 197 | - 如果未安装则安装,如果有安装则提示升级 198 | 199 | ```bash 200 | 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 201 | ``` 202 | 203 | #### 一键安装vnstat环境 204 | 205 | - 支持系统:Ubuntu 18+,Debian 8+,centos 7+,Fedora,Almalinux 8.5+ 206 | - 加载官方文件编译安装,前置条件适配系统以及后置条件判断安装的版本 207 | 208 | ```bash 209 | 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 210 | ``` 211 | 212 | #### 一键升级低版本debian为debian11 213 | 214 | - 支持系统:debian 6+ 215 | - 升级后需要重启系统加载内核,升级过程中需要选择的都无脑按回车即可 216 | - 升级是一个版本迭代一个版本,所以如果版本低,每执行一次升级一个版本,直至升级到debian11 217 | 218 | ```bash 219 | 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 220 | ``` 221 | 222 | #### 一键升级低版本ubuntu为ubuntu22 223 | 224 | - 支持系统:Ubuntu 16+ 225 | - 升级后需要重启系统加载内核,升级过程中需要选择的都无脑按回车即可 226 | - 升级是一个版本迭代一个版本,所以如果版本低,每执行一次升级一个版本,直至升级到ubuntu22 227 | 228 | ```bash 229 | 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 230 | ``` 231 | 232 | #### 一键安装zipline平台 233 | 234 | - 应该支持的系统:Ubuntu 18+,Debian 8+,centos 7+,Fedora,Almalinux 8.5+ 235 | - 暂时只在Ubuntu上验证无问题 236 | - 如若要设置反向代理绑定域名,安装前请保证原服务器未安装过nginx,如若已安装过nginx,请自行配置反向代理本机的3000端口 237 | - 默认一路回车是不启用反代不安装nginx的,自行选择,如需通过本脚本配置反代系统一定要未安装过nginx并在填写y或Y开启安装 238 | - [zipline](https://github.com/diced/zipline) 平台功能: ShareX,自定义短链接,文件上传分享,多用户校验,高亮显示,阅后即焚,设置简单 (含pastebin) 239 | - 自动安装docker,docker-compose,如若已安装zipline在/root目录下,则自动更新 240 | - 反向代理如若已设置成功,还需要在面板设置中填写域名,绑定启用 241 | 242 | ```bash 243 | 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 244 | ``` 245 | 246 | 如果需要删除0字节文件,打开```/root/zipline```文件夹,执行 247 | 248 | ``` 249 | docker-compose exec zipline yarn scripts:clear-zero-byte 250 | ``` 251 | 252 | 按照提示操作 253 | 254 | #### 一键安装filebrowser平台 255 | 256 | - 端口设置为3030了,其他登陆信息详见提示 257 | - [filebrowser](https://github.com/filebrowser/filebrowser)平台支持下载上传文件到服务器,批量下载多个文件(自定义压缩格式),构建文件分享链接,设置分享时长 258 | - 如果本地有启用IPV6优先级可能绑定到V6去了,使用```lsof -i:3030```查看绑定情况,切换优先级后再安装就正常了 259 | 260 | ```bash 261 | 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 262 | ``` 263 | 264 | #### 一键删除平台监控 265 | 266 | - 一键移除大多数云服务器监控 267 | - 涵盖阿里云、腾讯云、华为云、UCLOUD、甲骨文云、京东云 268 | 269 | ```bash 270 | 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 271 | ``` 272 | 273 | ## 部分手动命令 274 | 275 | ### 一键开启root登陆并替换密码 276 | 277 | ``` 278 | bash <(curl -sSL https://raw.githubusercontent.com/fscarmen/tools/main/root.sh) [PASSWORD] 279 | ``` 280 | 281 | ### 一键屏蔽邮件端口避免被恶意程序使用 282 | 283 | ```bash 284 | iptables -A INPUT -p tcp --dport 25 -j DROP 285 | iptables -A OUTPUT -p tcp --dport 25 -j DROP 286 | /sbin/iptables-save 287 | ``` 288 | 289 | ### 设置语言包 290 | 291 | ```bash 292 | sudo apt update 293 | sudo apt install -y locales 294 | sudo locale-gen en_US.UTF-8 295 | echo 'LANG=en_US.UTF-8' | sudo tee /etc/default/locale 296 | echo 'LC_ALL=en_US.UTF-8' | sudo tee -a /etc/default/locale 297 | sudo sed -i '/^#.* en_US.UTF-8 /s/^#//' /etc/locale.gen 298 | sudo locale-gen 299 | export LANG=en_US.UTF-8 300 | export LC_ALL=en_US.UTF-8 301 | locale 302 | ``` 303 | 304 | 重新连接SSH或重启服务器以使得设置生效 305 | 306 | ### ubuntu更新源被锁 307 | 308 | ```bash 309 | sudo rm -rf /var/cache/apt/archives/lock 310 | sudo pkill apt 311 | sudo rm /var/lib/dpkg/lock-frontend 312 | sudo rm /var/lib/apt/lists/lock 313 | sudo rm /var/cache/apt/archives/lock 314 | sudo rm /var/lib/dpkg/lock 315 | sudo dpkg --configure -a 316 | ``` 317 | 318 | 然后重启系统 319 | 320 | ### debian缺失公钥 321 | 322 | ```bash 323 | apt-get install debian-keyring debian-archive-keyring -y 324 | ``` 325 | 326 | ### ubuntu或debian缺失公钥 327 | 328 | 后续这块有计划整理为一个一键脚本 329 | 330 | ```bash 331 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 公钥 332 | ``` 333 | 334 | ### centos换源 335 | 336 | ```bash 337 | sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup 338 | sudo sed -i 's/^mirrorlist=http/mirrorlist=https/' /etc/yum.repos.d/CentOS-Base.repo 339 | ``` 340 | 341 | ### 安装gitea 342 | 343 | 安装时使用这里的方法: 344 | 345 | https://gitlab.com/packaging/gitea 346 | 347 | 但不要设置无人值守自动升级版本,容易升级到一个有BUG的新版本 348 | 349 | 更改默认配置需要更改文件```/etc/gitea/app.ini``` 350 | 351 | 比如设置文件上传无限制 352 | 353 | ``` 354 | [repository.upload] 355 | ENABLED = true 356 | ALLOWED_TYPES = 357 | FILE_MAX_SIZE = 1024 358 | MAX_FILES = 100 359 | ``` 360 | 361 | 写在```[security]```上面,每个模块```[]```的内容之间间隔一个空行 362 | 363 | ### 卸载aapanel 364 | 365 | ```bash 366 | 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 367 | ``` 368 | 369 | ### 查询是什么东西占用硬盘大于100M 370 | 371 | ```bash 372 | find / -type f -size +100M -exec ls -lh {} \; 373 | ``` 374 | 375 | ### 卸载dns缓存机制避免配置覆写 376 | 377 | ```bash 378 | systemctl stop systemd-resolved 379 | systemctl disable systemd-resolved 380 | ``` 381 | 382 | ### 安装docker和docker-compose 383 | 384 | 安装24版本的docker 385 | 386 | ```bash 387 | curl -sSL https://get.docker.com/ | sh 388 | ``` 389 | 390 | 或安装最新版本的docker(都选官方源即可) 391 | 392 | ``` 393 | bash <(curl -sSL https://linuxmirrors.cn/docker.sh) 394 | ``` 395 | 396 | 安装docker-compose最新版本 397 | 398 | ``` 399 | curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-linux-$(uname -m)" -o /usr/local/bin/docker-compose 400 | chmod +x /usr/local/bin/docker-compose 401 | docker-compose --version 402 | ``` 403 | 404 | 卸载所有docker镜像和容器 405 | 406 | ``` 407 | docker rm -f $(docker ps -aq); docker rmi $(docker images -aq) 408 | ``` 409 | 410 | 删除累积的docker日志 411 | 412 | ``` 413 | 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 414 | ``` 415 | 416 | ### 通过docker安装code-server 417 | 418 | 安装 419 | 420 | ```shell 421 | mkdir -p ~/.config 422 | docker run --restart=always --name code-server -p 0.0.0.0:8886:8080 \ 423 | -v "$HOME/.config:/home/coder/.config" \ 424 | -v "$PWD:/home/coder/project" \ 425 | -u "$(id -u):$(id -g)" \ 426 | -e "DOCKER_USER=$USER" \ 427 | codercom/code-server:latest 428 | ``` 429 | 430 | 新窗口 431 | 432 | ```shell 433 | docker exec code-server cat /root/.config/code-server/config.yaml 434 | ``` 435 | 436 | 或 437 | 438 | ``` 439 | curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run 440 | sudo systemctl enable --now code-server@root 441 | sed -i '1s/127.0.0.1:8080/0.0.0.0:8536/' ~/.config/code-server/config.yaml 442 | sudo systemctl restart code-server@root 443 | cat .config/code-server/config.yaml 444 | ``` 445 | 446 | 卸载需要 447 | 448 | ``` 449 | sudo systemctl stop code-server@root 450 | sudo systemctl disable code-server@root 451 | rm -rf ~/.cache/coder 452 | sudo apt remove coder -y 453 | ``` 454 | 455 | ## 友链 456 | 457 | #### 一键测试服务器的融合怪脚本 458 | 459 | https://github.com/spiritLHLS/ecs 460 | 461 | #### 一键批量开NAT服务器的LXD脚本 462 | 463 | https://github.com/spiritLHLS/lxd 464 | 465 | #### 一键安装PVE和使用PVE批量开设虚拟机的脚本 466 | 467 | https://github.com/spiritLHLS/pve 468 | 469 | #### 朋友fscarmen的常用一键工具仓库 470 | 471 | https://github.com/fscarmen/tools 472 | -------------------------------------------------------------------------------- /back/conda.md: -------------------------------------------------------------------------------- 1 | ``` 2 | conda install pandas numpy openpyxl 3 | ``` 4 | -------------------------------------------------------------------------------- /back/debian.txt: -------------------------------------------------------------------------------- 1 | deb http://deb.debian.org/debian/ bullseye main contrib non-free 2 | deb-src http://deb.debian.org/debian/ bullseye main contrib non-free 3 | 4 | deb http://security.debian.org/debian-security bullseye/updates main contrib non-free 5 | deb-src http://security.debian.org/debian-security bullseye/updates main contrib non-free 6 | 7 | deb http://deb.debian.org/debian/ bullseye-updates main contrib non-free 8 | deb-src http://deb.debian.org/debian/ bullseye-updates main contrib non-free 9 | -------------------------------------------------------------------------------- /back/ubuntu.txt: -------------------------------------------------------------------------------- 1 | deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse 2 | deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse 3 | 4 | deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse 5 | deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse 6 | 7 | deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse 8 | deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse 9 | 10 | deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse 11 | deb-src http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse 12 | -------------------------------------------------------------------------------- /install_scripts/FOSSBilling-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | services: 3 | fossbilling: 4 | image: fossbilling/fossbilling 5 | restart: always 6 | ports: 7 | - 80:80 8 | volumes: 9 | - fossbilling:/var/www/html 10 | mysql: 11 | image: mysql:8.0 12 | restart: always 13 | environment: 14 | MYSQL_DATABASE: exampledb 15 | MYSQL_USER: exampleuser 16 | MYSQL_PASSWORD: examplepass 17 | MYSQL_RANDOM_ROOT_PASSWORD: '1' 18 | volumes: 19 | - mysql:/var/lib/mysql 20 | ports: 21 | - 127.0.0.1:3306:3306 22 | 23 | volumes: 24 | fossbilling: 25 | mysql: 26 | -------------------------------------------------------------------------------- /install_scripts/R.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #by spiritlhl 3 | #from https://github.com/spiritLHLS/one-click-installation-script 4 | #version: 2023.04.08 5 | 6 | utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8") 7 | if [[ -z "$utf8_locale" ]]; then 8 | echo "No UTF-8 locale found" 9 | else 10 | export LC_ALL="$utf8_locale" 11 | export LANG="$utf8_locale" 12 | export LANGUAGE="$utf8_locale" 13 | echo "Locale set to $utf8_locale" 14 | fi 15 | ver="2023.04.08" 16 | changeLog="一键安装R语言环境" 17 | source ~/.bashrc 18 | red() { echo -e "\033[31m\033[01m$1$2\033[0m"; } 19 | green() { echo -e "\033[32m\033[01m$1$2\033[0m"; } 20 | yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; } 21 | blue() { echo -e "\033[36m\033[01m$@\033[0m"; } 22 | reading() { read -rp "$(green "$1")" "$2"; } 23 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'" "fedora" "arch") 24 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Fedora" "Arch") 25 | PACKAGE_UPDATE=("! apt-get update && apt-get --fix-broken install -y && apt-get update" "apt-get update" "yum -y update" "yum -y update" "yum -y update" "pacman -Sy") 26 | PACKAGE_INSTALL=("apt-get -y install" "apt-get -y install" "yum -y install" "yum -y install" "yum -y install" "pacman -Sy --noconfirm --needed") 27 | PACKAGE_REMOVE=("apt-get -y remove" "apt-get -y remove" "yum -y remove" "yum -y remove" "yum -y remove" "pacman -Rsc --noconfirm") 28 | PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "") 29 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)") 30 | SYS="${CMD[0]}" 31 | [[ -n $SYS ]] || exit 1 32 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 33 | if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then 34 | SYSTEM="${RELEASE[int]}" 35 | [[ -n $SYSTEM ]] && break 36 | fi 37 | done 38 | apt-get --fix-broken install -y >/dev/null 2>&1 39 | clear 40 | echo "#######################################################################" 41 | echo "# ${YELLOW}一键安装R语言环境${PLAIN} #" 42 | echo "# 版本:$ver #" 43 | echo "# 更新日志:$changeLog #" 44 | echo "# ${GREEN}作者${PLAIN}: spiritlhl #" 45 | echo "# ${GREEN}仓库${PLAIN}: https://github.com/spiritLHLS/one-click-installation-script #" 46 | echo "#######################################################################" 47 | echo "验证已支持的系统:" 48 | echo "Ubuntu 18/20/22 - 推荐,脚本自动挂起到后台" 49 | echo "Debian 9/10/11 - 还行,需要手动挂起到后台,详看脚本运行安装完毕的后续提示" 50 | echo "可能支持的系统:centos 7+,Fedora,Almalinux 8.5+" 51 | yellow "安装前需使用Miniconda3安装虚拟环境jupyter-env,然后进行jupyter和jupyterlab的安装,再然后才能安装本内核" 52 | yellow "简单的说,需要执行本仓库对应的jupyter安装脚本再运行本脚本安装R语言环境" 53 | yellow "如果是初次安装无脑回车即可,按照提示进行操作即可" 54 | 55 | checkupdate() { 56 | yellow "Updating package management sources" 57 | ${PACKAGE_UPDATE[int]} >/dev/null 2>&1 58 | apt-key update >/dev/null 2>&1 59 | } 60 | 61 | checkroot() { 62 | [[ $EUID -ne 0 ]] && echo -e "${RED}请使用 root 用户运行本脚本!${PLAIN}" && exit 1 63 | } 64 | 65 | checkR() { 66 | ${PACKAGE_INSTALL[int]} xorg xserver-xorg-dev libx11-dev libxt-dev libcairo2-dev 67 | source activate jupyter-env 68 | if ! Rscript -e "IRkernel::installspec()" &>/dev/null; then 69 | reading "IRkernel is not installed on this system. Do you want to install it? (y/n) " confirminstall 70 | echo "" 71 | if [ "$confirminstall" != "y" ]; then 72 | exit 0 73 | fi 74 | conda install -c r r-irkernel 75 | green "Installed IRkernel package and registered kernel" 76 | else 77 | blue "IRkernel is installed" 78 | fi 79 | } 80 | 81 | checkroot 82 | checkupdate 83 | checkR 84 | green "R语言已安装完毕" 85 | -------------------------------------------------------------------------------- /install_scripts/cplusplus.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #by spiritlhl 3 | #from https://github.com/spiritLHLS/one-click-installation-script 4 | #version: 2022.12.27 5 | 6 | utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8") 7 | if [[ -z "$utf8_locale" ]]; then 8 | echo "No UTF-8 locale found" 9 | else 10 | export LC_ALL="$utf8_locale" 11 | export LANG="$utf8_locale" 12 | export LANGUAGE="$utf8_locale" 13 | echo "Locale set to $utf8_locale" 14 | fi 15 | # Check if C++ is installed 16 | if ! type "g++" >/dev/null; then 17 | # Install C++ if it is not installed 18 | echo "C++ is not installed. Installing C++..." 19 | # Check OS and install C++ using appropriate package manager 20 | if type "apt-get" >/dev/null; then 21 | # Ubuntu, Debian 22 | sudo apt-get update 23 | sudo apt-get install g++ 24 | elif type "yum" >/dev/null; then 25 | # CentOS, Fedora, AlmaLinux 26 | sudo yum update 27 | sudo yum install gcc-c++ 28 | else 29 | echo "Error: unknown operating system. C++ installation failed." 30 | exit 1 31 | fi 32 | else 33 | # Get C++ version 34 | g++ --version 35 | # Ask if the user wants to update C++ 36 | read -p "Do you want to update C++? (y/n) " -n 1 -r 37 | echo 38 | # Update C++ if the user chose to update 39 | if [[ $REPLY =~ ^[Yy]$ ]]; then 40 | echo "Updating C++..." 41 | # Check OS and update C++ using appropriate package manager 42 | if type "apt-get" >/dev/null; then 43 | # Ubuntu, Debian 44 | sudo apt-get update 45 | sudo apt-get install g++ 46 | elif type "yum" >/dev/null; then 47 | # CentOS, Fedora, AlmaLinux 48 | sudo yum update 49 | sudo yum install gcc-c++ 50 | else 51 | echo "Error: unknown operating system. C++ update failed." 52 | exit 1 53 | fi 54 | fi 55 | fi 56 | -------------------------------------------------------------------------------- /install_scripts/dlm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # by spiritlhl 3 | # from https://github.com/spiritLHLS/one-click-installation-script 4 | # version: 2023.11.01 5 | 6 | export DEBIAN_FRONTEND=noninteractive 7 | AEGIS_INSTALL_DIR="/usr/local/aegis" 8 | #check linux Gentoo os 9 | var=$(lsb_release -a | grep Gentoo) 10 | if [ -z "${var}" ]; then 11 | var=$(cat /etc/issue | grep Gentoo) 12 | fi 13 | checkCoreos=$(cat /etc/os-release 2>/dev/null | grep coreos) 14 | if [ -d "/etc/runlevels/default" -a -n "${var}" ]; then 15 | LINUX_RELEASE="GENTOO" 16 | elif [ -f "/etc/os-release" -a -n "${checkCoreos}" ]; then 17 | LINUX_RELEASE="COREOS" 18 | AEGIS_INSTALL_DIR="/opt/aegis" 19 | else 20 | LINUX_RELEASE="OTHER" 21 | fi 22 | 23 | _red() { echo -e "\033[31m\033[01m$@\033[0m"; } 24 | _green() { echo -e "\033[32m\033[01m$@\033[0m"; } 25 | _yellow() { echo -e "\033[33m\033[01m$@\033[0m"; } 26 | _blue() { echo -e "\033[36m\033[01m$@\033[0m"; } 27 | reading() { read -rp "$(_green "$1")" "$2"; } 28 | 29 | uninstall_qcloud() { 30 | # 腾讯云 31 | /usr/local/qcloud/stargate/admin/uninstall.sh 32 | /usr/local/qcloud/YunJing/uninst.sh 33 | /usr/local/qcloud/monitor/barad/admin/uninstall.sh 34 | rm -f /etc/cron.d/sgagenttask 35 | crontab -l | grep -v '/usr/local/qcloud/stargate/admin' | crontab - 36 | rm -rf /usr/local/qcloud 37 | } 38 | 39 | uninstall_oralce() { 40 | # 甲骨文云 41 | systemctl stop oracle-cloud-agent 42 | systemctl disable oracle-cloud-agent 43 | systemctl stop oracle-cloud-agent-updater 44 | systemctl disable oracle-cloud-agent-updater 45 | systemctl disable --now qemu-guest-agent 46 | if command -v snap >/dev/null 2>&1; then 47 | snap remove oracle-cloud-agent 48 | fi 49 | } 50 | 51 | uninstall_jdcloud() { 52 | # 其他云 53 | /etc/KsyunAgent/uninstall.py 54 | service uma stop 55 | systemctl disable --now uma 56 | /usr/local/uniagent/extension/install/telescope/telescoped stop 57 | # 京东云 58 | systemctl stop --no-block jcs-agent-core 59 | systemctl --no-reload disable jcs-agent-core 60 | if command -v stop >/dev/null 2>&1; then 61 | stop --no-wait jcs-agent-core /etc/init.d/jcs-agent-core 62 | fi 63 | 64 | if [[ -f "/etc/centos-release" && $(grep ' 6' "/etc/centos-release") ]]; then 65 | chkconfig --level 2345 expand-root off >/dev/null 2>&1 66 | sysv-rc-conf --level 2345 expand-root off >/dev/null 2>&1 67 | rm -rf "/usr/share/dracut/modules.d/50growroot" 68 | dracut --force 69 | rm -f "/usr/bin/sgdisk" 70 | rm -f "/usr/bin/growpart" 71 | fi 72 | 73 | systemctl stop --no-block jcs-shutdown-scripts 74 | systemctl stop --no-block jcs-entry 75 | systemctl --no-reload disable jcs-shutdown-scripts 76 | systemctl --no-reload disable jcs-entry 77 | if command -v stop >/dev/null 2>&1; then 78 | stop --no-wait jcs-shutdown-scripts 79 | stop --no-wait jcs-entry 80 | stop --no-wait /etc/init.d/jcs-shutdown-scripts 81 | stop --no-wait /etc/init.d/jcs-entry 82 | fi 83 | service jcs-entry stop 84 | service jcs-shutdown-scripts stop 85 | chkconfig jcs-entry off >/dev/null 2>&1 86 | chkconfig jcs-shutdown-scripts off >/dev/null 2>&1 87 | sysv-rc-conf jcs-entry off >/dev/null 2>&1 88 | sysv-rc-conf jcs-shutdown-scripts off >/dev/null 2>&1 89 | update-rc.d jcs-entry remove 90 | update-rc.d jcs-shutdown-scripts remove 91 | pkill jdog 92 | rm -rf "/usr/local/share/jcloud" 93 | } 94 | 95 | kill_processes() { 96 | local process 97 | local killall_processes=("aegis_cli" "aegis_update" "AliYunDun" "AliYunDunMonitor" "AliHids" "AliHips" "AliYunDunUpdate") 98 | for process in "${killall_processes[@]}"; do 99 | killall -9 "$process" >/dev/null 2>&1 100 | printf "%-40s %40s\n" "Killall $process" "[ OK ]" 101 | done 102 | } 103 | 104 | pkill_processes() { 105 | local process 106 | local pkill_processes=("assist_daemon" "assist-daemon" "aliyun*" "AliYunDun*" "AliSecure*" "aegis*") 107 | for process in "${pkill_processes[@]}"; do 108 | pkill "$process" >/dev/null 2>&1 109 | printf "%-40s %40s\n" "Pkill $process" "[ OK ]" 110 | done 111 | killall -9 aegis_quartz >/dev/null 2>&1 112 | printf "%-40s %40s\n" "Killall aegis_quartz" "[ OK ]" 113 | } 114 | 115 | uninstall_aegis() { 116 | if [ -d "$AEGIS_INSTALL_DIR" ]; then 117 | rm -rf "$AEGIS_INSTALL_DIR/aegis_client" 118 | rm -rf "$AEGIS_INSTALL_DIR/aegis_update" 119 | rm -rf "$AEGIS_INSTALL_DIR/alihids" 120 | fi 121 | 122 | if [ -d "$AEGIS_INSTALL_DIR/aegis_debug" ]; then 123 | umount "$AEGIS_INSTALL_DIR/aegis_debug" 124 | rm -rf "$AEGIS_INSTALL_DIR/aegis_debug" 125 | fi 126 | 127 | if [ -f "/etc/init.d/aegis" ]; then 128 | /etc/init.d/aegis stop >/dev/null 2>&1 129 | rm -f "/etc/init.d/aegis" 130 | fi 131 | 132 | if [ "$LINUX_RELEASE" = "GENTOO" ]; then 133 | rc-update del aegis default 2>/dev/null 134 | rm -f "/etc/runlevels/default/aegis" >/dev/null 2>&1 135 | elif [ -f "/etc/init.d/aegis" ]; then 136 | /etc/init.d/aegis uninstall 137 | for ((var = 2; var <= 5; var++)); do 138 | if [ -d "/etc/rc${var}.d/" ]; then 139 | rm -f "/etc/rc${var}.d/S80aegis" 140 | elif [ -d "/etc/rc.d/rc${var}.d" ]; then 141 | rm -f "/etc/rc.d/rc${var}.d/S80aegis" 142 | fi 143 | done 144 | fi 145 | } 146 | 147 | wait_aegis_exit() { 148 | var=1 149 | limit=10 150 | echo "wait aegis exit" 151 | 152 | while [[ $var -lt $limit ]]; do 153 | if [ -n "$(ps -ef | grep aegis_client | grep -v grep)" ]; then 154 | sleep 1 155 | else 156 | return 157 | fi 158 | 159 | ((var++)) 160 | done 161 | 162 | _red "wait AliYunDun process exit fail, possibly due to self-protection, please uninstall aegis or disable self-protection from the aegis console." 163 | } 164 | 165 | uninstall_cloud_monitoring() { 166 | # 阿里云 167 | ARCH=$(arch) 168 | /usr/local/cloudmonitor/CmsGoAgent.linux-${ARCH} stop 169 | /usr/local/cloudmonitor/CmsGoAgent.linux-${ARCH} uninstall 170 | rm -rf "/usr/local/cloudmonitor" 171 | 172 | service aegis stop 173 | update-rc.d aegis disable 174 | chkconfig --del aegis >/dev/null 2>&1 175 | sysv-rc-conf --del aegis >/dev/null 2>&1 176 | 177 | /usr/local/cloudmonitor/wrapper/bin/cloudmonitor.sh stop 178 | /usr/local/cloudmonitor/wrapper/bin/cloudmonitor.sh remove 179 | rm -rf "/usr/local/cloudmonitor" 180 | 181 | systemctl stop aliyun.service 182 | pkill aliyun-service 183 | pkill AliYunDun 184 | pkill agetty 185 | pkill AliYunDunUpdate 186 | 187 | rm -rf "/etc/init.d/aegis" 188 | rm -rf "/etc/init.d/agentwatch" 189 | rm -rf "/etc/systemd/system/aliyun.service" 190 | rm -rf "/usr/sbin/aliyun_installer" 191 | rm -rf "/usr/sbin/aliyun-service" 192 | rm -rf "/usr/sbin/aliyun-service.backup" 193 | rm -rf "/usr/sbin/agetty" 194 | rm -rf "$AEGIS_INSTALL_DIR" 195 | rm -rf "/usr/local/share/aliyun-assist" 196 | rm -rf "/usr/local/cloudmonitor" 197 | } 198 | 199 | check_root() { 200 | [ $(id -u) != "0" ] && { 201 | echo "Error: You must be root to run this script" 202 | exit 1 203 | } 204 | } 205 | 206 | remove_aegis() { 207 | if [ -d $AEGIS_INSTALL_DIR ]; then 208 | systemctl stop aegis.service 2>/dev/null 209 | systemctl disable aegis.service 2>/dev/null 210 | rm -rf "/etc/systemd/system/aegis.service" 211 | umount "$AEGIS_INSTALL_DIR/aegis_debug" 212 | rm -rf $AEGIS_INSTALL_DIR/* >/dev/null 2>&1 213 | rm -rf /usr/local/share/assist-daemon/* >/dev/null 2>&1 214 | rm -rf /usr/local/share/aliyun* >/dev/null 2>&1 215 | rm -rf /sys/fs/cgroup/devices/system.slice/aegis.service >/dev/null 2>&1 216 | fi 217 | 218 | kprobeArr=( 219 | "/sys/kernel/debug/tracing/instances/aegis_do_sys_open/set_event" 220 | "/sys/kernel/debug/tracing/instances/aegis_inet_csk_accept/set_event" 221 | "/sys/kernel/debug/tracing/instances/aegis_tcp_connect/set_event" 222 | "/sys/kernel/debug/tracing/instances/aegis/set_event" 223 | "/sys/kernel/debug/tracing/instances/aegis_/set_event" 224 | "/sys/kernel/debug/tracing/instances/aegis_accept/set_event" 225 | "/sys/kernel/debug/tracing/kprobe_events" 226 | "$AEGIS_INSTALL_DIR/aegis_debug/tracing/set_event" 227 | "$AEGIS_INSTALL_DIR/aegis_debug/tracing/kprobe_events" 228 | ) 229 | for value in ${kprobeArr[@]}; do 230 | if [ -f "$value" ]; then 231 | echo >$value 232 | fi 233 | done 234 | 235 | if [ -d "${AEGIS_INSTALL_DIR}" ]; then 236 | umount ${AEGIS_INSTALL_DIR}/aegis_debug 237 | if [ -d "${AEGIS_INSTALL_DIR}/cgroup/cpu" ]; then 238 | umount ${AEGIS_INSTALL_DIR}/cgroup/cpu 239 | fi 240 | if [ -d "${AEGIS_INSTALL_DIR}/cgroup" ]; then 241 | umount ${AEGIS_INSTALL_DIR}/cgroup 242 | fi 243 | rm -rf ${AEGIS_INSTALL_DIR}/aegis_client 244 | rm -rf ${AEGIS_INSTALL_DIR}/aegis_update 245 | rm -rf ${AEGIS_INSTALL_DIR}/alihids 246 | rm -f ${AEGIS_INSTALL_DIR}/globalcfg/domaincfg.ini >/dev/null 2>&1 247 | fi 248 | if [ -d $AEGIS_INSTALL_DIR/aegis_debug ]; then 249 | if [ -d $AEGIS_INSTALL_DIR/aegis_debug/tracing/instances/aegis ]; then 250 | echo >$AEGIS_INSTALL_DIR/aegis_debug/tracing/instances/aegis/set_event 251 | else 252 | echo >$AEGIS_INSTALL_DIR/aegis_debug/tracing/set_event 253 | fi 254 | fi 255 | } 256 | 257 | remove_agentwatch() { 258 | agentwatch=$(ps aux | grep 'agentwatch') 259 | if [[ -n $agentwatch ]]; then 260 | systemctl stop agentwatch.service 261 | systemctl disable agentwatch.service 262 | cd / 263 | find . -name 'agentwatch*' -type d -exec rm -rf {} \; 264 | find . -name 'agentwatch*' -type f -exec rm -rf {} \; 265 | fi 266 | } 267 | 268 | remove_all_aliyunfiles() { 269 | aliyunsrv=$(ps aux | grep 'aliyun') 270 | if [[ -n $aliyunsrv ]]; then 271 | cd / 272 | systemctl stop aliyun-util.service 273 | systemctl disable aliyun-util.service 274 | systemctl stop aliyun.service 275 | systemctl disable aliyun.service 276 | 277 | rm -fr /usr/sbin/aliyun-service /usr/sbin/aliyun_installer 278 | rm /etc/systemd/system/aliyun-util.service 279 | rm -rf /etc/aliyun-util >/dev/null 2>&1 280 | 281 | rm -rf /etc/systemd/system/multi-user.target.wants/ecs_mq.service >/dev/null 2>&1 282 | rm -rf /etc/systemd/system/multi-user.target.wants/aliyun.service >/dev/null 2>&1 283 | 284 | find . -iname "*aliyu*" -type f -print -exec rm -rf {} \; 285 | find . -iname "*aliyu*" | xargs rm -rf 286 | # find . -iname "*aegis*" -type f -print -exec rm -rf {} \; 287 | # find . -iname "*aegis*" | xargs rm -rf 288 | find . -iname "*AliVulfix*" -type f -print -exec rm -rf {} \; 289 | find . -iname "*AliVulfix*" | xargs rm -rf 290 | fi 291 | } 292 | 293 | remove_cloud_monitor() { 294 | CloudMonitorSrv=$(ps aux | grep 'cloudmonitor') 295 | if [[ -n $CloudMonitorSrv ]]; then 296 | cd / 297 | rm -rf /usr/local/cloudmonitor 298 | fi 299 | } 300 | 301 | rescue_localhost_name() { 302 | hostname=$(cat /etc/hostname) 303 | echo "" >/etc/hostname 304 | echo "localhost" >/etc/hostname 305 | sed -i "s/${hostname}/localhost/g" /etc/hosts 306 | } 307 | 308 | check_root 309 | touch /etc/cloud/cloud-init.disabled 310 | uninstall_qcloud 311 | uninstall_oralce 312 | uninstall_jdcloud 313 | kill_processes 314 | pkill_processes 315 | wait_aegis_exit 316 | uninstall_aegis 317 | remove_aegis 318 | uninstall_cloud_monitoring 319 | remove_aegis 320 | if [ -d "$AEGIS_INSTALL_DIR/aegis_debug" ]; then 321 | umount "$AEGIS_INSTALL_DIR/aegis_debug" 322 | rm -rf "$AEGIS_INSTALL_DIR/aegis_debug" 323 | fi 324 | remove_agentwatch 325 | remove_all_aliyunfiles 326 | remove_cloud_monitor 327 | rescue_localhost_name 328 | _green "Uninstallation complete, please reboot to change completely." 329 | -------------------------------------------------------------------------------- /install_scripts/filebrowser.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #by spiritlhl 3 | #from https://github.com/spiritLHLS/one-click-installation-script 4 | #version: 2023.04.18 5 | 6 | utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8") 7 | if [[ -z "$utf8_locale" ]]; then 8 | echo "No UTF-8 locale found" 9 | else 10 | export LC_ALL="$utf8_locale" 11 | export LANG="$utf8_locale" 12 | export LANGUAGE="$utf8_locale" 13 | echo "Locale set to $utf8_locale" 14 | fi 15 | cd /root >/dev/null 2>&1 16 | ver="2023.04.18" 17 | changeLog="一键安装filebrowser平台" 18 | source ~/.bashrc 19 | red() { echo -e "\033[31m\033[01m$1$2\033[0m"; } 20 | green() { echo -e "\033[32m\033[01m$1$2\033[0m"; } 21 | yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; } 22 | blue() { echo -e "\033[36m\033[01m$@\033[0m"; } 23 | reading() { read -rp "$(green "$1")" "$2"; } 24 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'" "fedora" "arch") 25 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Fedora" "Arch") 26 | PACKAGE_UPDATE=("! apt-get update && apt-get --fix-broken install -y && apt-get update" "apt-get update" "yum -y update" "yum -y update" "yum -y update" "pacman -Sy") 27 | PACKAGE_INSTALL=("apt-get -y install" "apt-get -y install" "yum -y install" "yum -y install" "yum -y install" "pacman -Sy --noconfirm --needed") 28 | PACKAGE_REMOVE=("apt-get -y remove" "apt-get -y remove" "yum -y remove" "yum -y remove" "yum -y remove" "pacman -Rsc --noconfirm") 29 | PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "") 30 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)") 31 | SYS="${CMD[0]}" 32 | [[ -n $SYS ]] || exit 1 33 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 34 | if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then 35 | SYSTEM="${RELEASE[int]}" 36 | [[ -n $SYSTEM ]] && break 37 | fi 38 | done 39 | apt-get --fix-broken install -y >/dev/null 2>&1 40 | 41 | check_ipv4() { 42 | API_NET=("ip.sb" "ipget.net" "ip.ping0.cc" "https://ip4.seeip.org" "https://api.my-ip.io/ip" "https://ipv4.icanhazip.com" "api.ipify.org") 43 | for p in "${API_NET[@]}"; do 44 | response=$(curl -s4m8 "$p") 45 | sleep 1 46 | if [ $? -eq 0 ] && ! echo "$response" | grep -q "error"; then 47 | IP_API="$p" 48 | break 49 | fi 50 | done 51 | ! curl -s4m8 $IP_API | grep -q '\.' && red " ERROR:The host must have IPv4. " && exit 1 52 | IPV4=$(curl -s4m8 "$IP_API") 53 | } 54 | 55 | checkwget() { 56 | if [ ! -e '/usr/bin/wget' ]; then 57 | yellow "Installing wget" 58 | ${PACKAGE_INSTALL[int]} wget 59 | fi 60 | } 61 | 62 | checktar() { 63 | yellow "checking tar" 64 | if [ ! -e '/usr/bin/tar' ]; then 65 | yellow "Installing tar" 66 | ${PACKAGE_INSTALL[int]} tar 67 | fi 68 | if [ $? -ne 0 ]; then 69 | apt-get -f install >/dev/null 2>&1 70 | ${PACKAGE_INSTALL[int]} tar >/dev/null 2>&1 71 | fi 72 | } 73 | 74 | build() { 75 | cd /root >/dev/null 2>&1 76 | local sysarch="$(uname -m)" 77 | case "${sysarch}" in 78 | "x86_64" | "x86" | "amd64" | "x64") sys_bit="amd64" ;; 79 | "i386" | "i686") sys_bit="386" ;; 80 | "aarch64" | "armv8" | "armv8l") sys_bit="arm64" ;; 81 | "armv5l") sys_bit="armv5" ;; 82 | "armv6l") sys_bit="armv6" ;; 83 | "armv7l") sys_bit="armv7" ;; 84 | *) sys_bit="amd64" ;; 85 | esac 86 | wget https://github.com/filebrowser/filebrowser/releases/download/v2.23.0/linux-${sys_bit}-filebrowser.tar.gz 87 | tar -xzvf linux-${sys_bit}-filebrowser.tar.gz 88 | rm -rf linux-${sys_bit}-filebrowser.tar.gz* 89 | } 90 | 91 | run() { 92 | nohup ./filebrowser -a 0.0.0.0 -p 3030 >/dev/null 2>&1 & 93 | } 94 | 95 | check_ipv4 96 | checkwget 97 | checktar 98 | build 99 | run 100 | green "Checking http://$IPV4:3030/ " 101 | green "You may login to the dashboard with:" 102 | green "Username: admin" 103 | green "Password: admin" 104 | green "Remember to change this password in the manage user page" 105 | rm -rf CHANGELOG.md LICENSE README.md 106 | -------------------------------------------------------------------------------- /install_scripts/fossbilling.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #by spiritlhl 3 | #from https://github.com/spiritLHLS/one-click-installation-script 4 | #version: 2023.05.29 5 | 6 | utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8") 7 | if [[ -z "$utf8_locale" ]]; then 8 | echo "No UTF-8 locale found" 9 | else 10 | export LC_ALL="$utf8_locale" 11 | export LANG="$utf8_locale" 12 | export LANGUAGE="$utf8_locale" 13 | echo "Locale set to $utf8_locale" 14 | fi 15 | source ~/.bashrc 16 | red() { echo -e "\033[31m\033[01m$1$2\033[0m"; } 17 | green() { echo -e "\033[32m\033[01m$1$2\033[0m"; } 18 | yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; } 19 | blue() { echo -e "\033[36m\033[01m$@\033[0m"; } 20 | reading() { read -rp "$(green "$1")" "$2"; } 21 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'" "fedora" "arch") 22 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Fedora" "Arch") 23 | PACKAGE_UPDATE=("! apt-get update && apt-get --fix-broken install -y && apt-get update" "apt-get update" "yum -y update" "yum -y update" "yum -y update" "pacman -Sy") 24 | PACKAGE_INSTALL=("apt-get -y install" "apt-get -y install" "yum -y install" "yum -y install" "yum -y install" "pacman -Sy --noconfirm --needed") 25 | PACKAGE_REMOVE=("apt-get -y remove" "apt-get -y remove" "yum -y remove" "yum -y remove" "yum -y remove" "pacman -Rsc --noconfirm") 26 | PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "") 27 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)") 28 | SYS="${CMD[0]}" 29 | [[ -n $SYS ]] || exit 1 30 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 31 | if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then 32 | SYSTEM="${RELEASE[int]}" 33 | [[ -n $SYSTEM ]] && break 34 | fi 35 | done 36 | apt-get --fix-broken install -y >/dev/null 2>&1 37 | 38 | check_ipv4() { 39 | API_NET=("ip.sb" "ipget.net" "ip.ping0.cc" "https://ip4.seeip.org" "https://api.my-ip.io/ip" "https://ipv4.icanhazip.com" "api.ipify.org") 40 | for p in "${API_NET[@]}"; do 41 | response=$(curl -s4m8 "$p") 42 | sleep 1 43 | if [ $? -eq 0 ] && ! echo "$response" | grep -q "error"; then 44 | IP_API="$p" 45 | break 46 | fi 47 | done 48 | ! curl -s4m8 $IP_API | grep -q '\.' && red " ERROR:The host must have IPv4. " && exit 1 49 | IPV4=$(curl -s4m8 "$IP_API") 50 | } 51 | 52 | check_ipv4 53 | curl -sSL https://get.docker.com/ | sh 54 | sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose 55 | sudo chmod +x /usr/local/bin/docker-compose 56 | docker-compose --version 57 | curl -L https://raw.githubusercontent.com/spiritLHLS/one-click-installation-script/main/install_scripts/FOSSBilling-compose.yml -o FOSSBilling-compose.yml && chmod +x FOSSBilling-compose.yml 58 | docker-compose -f FOSSBilling-compose.yml up 59 | echo "Please open http://${IPV4}/install/install.php" 60 | -------------------------------------------------------------------------------- /install_scripts/golang.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Author: spiritLHLS 3 | # GitHub: https://github.com/spiritLHLS/one-click-installation-script 4 | # Version: 2024.12.02 5 | 6 | set -euo pipefail 7 | HOME="${HOME:-/root}" 8 | LOG_FILE="/tmp/golang_install_$(date +%Y%m%d_%H%M%S).log" 9 | RED="\033[31m" 10 | GREEN="\033[32m" 11 | YELLOW="\033[33m" 12 | BLUE="\033[36m" 13 | RESET="\033[0m" 14 | 15 | log() { 16 | echo -e "$1" | tee -a "$LOG_FILE" 17 | } 18 | 19 | color_echo() { 20 | local color="$1" 21 | local message="${@:2}" 22 | echo -e "\033[${color}${message}${RESET}" | tee -a "$LOG_FILE" 23 | } 24 | 25 | error_exit() { 26 | color_echo "$RED" "错误: $1" 27 | exit 1 28 | } 29 | 30 | network_check() { 31 | local host="$1" 32 | if ping -c 2 -W 2 "$host" > /dev/null 2>&1; then 33 | return 0 34 | else 35 | return 1 36 | fi 37 | } 38 | 39 | get_system_arch() { 40 | local arch=$(uname -m) 41 | local os=$(uname -s) 42 | 43 | case "$os" in 44 | "Darwin") 45 | os="darwin" 46 | ;; 47 | "Linux") 48 | os="linux" 49 | ;; 50 | *) 51 | error_exit "不支持的操作系统: $os" 52 | ;; 53 | esac 54 | 55 | case "$arch" in 56 | "x86_64") arch="amd64" ;; 57 | "aarch64") arch="arm64" ;; 58 | "armv7l") arch="armv6l" ;; 59 | "i686"|"i386")arch="386" ;; 60 | *) arch="amd64" ;; 61 | esac 62 | 63 | echo "${os}-${arch}" 64 | } 65 | 66 | get_latest_go_version() { 67 | local versions 68 | local proxy_url="https://goproxy.cn" 69 | for url in "https://go.dev/dl/" "https://golang.google.cn/dl/" "https://github.com/golang/go/tags"; do 70 | versions=$(curl -s --connect-timeout 10 "$url" | grep -oE 'go[0-9]+\.[0-9]+(\.[0-9]+)?' | sort -V | tail -n 1) 71 | if [[ -n "$versions" ]]; then 72 | echo "${versions#go}" 73 | return 0 74 | fi 75 | done 76 | error_exit "无法获取Go版本" 77 | } 78 | 79 | setup_go_environment() { 80 | local gopath="${HOME}/go" 81 | local go_bin="/usr/local/go/bin" 82 | mkdir -p "${gopath}/"{src,pkg,bin} 83 | local profiles=("${HOME}/.bashrc" "${HOME}/.zshrc" "/etc/profile") 84 | for profile in "${profiles[@]}"; do 85 | if [[ -f "$profile" ]]; then 86 | if ! grep -q "GOPATH" "$profile"; then 87 | { 88 | echo "export GOPATH=${gopath}" 89 | echo "export GOMODCACHE=\${GOPATH}/pkg/mod" 90 | echo "export PATH=\$PATH:${go_bin}:\${GOPATH}/bin" 91 | echo "export GOCACHE=${gopath}/.cache/go-build" 92 | } >> "$profile" 93 | fi 94 | fi 95 | done 96 | export GOPATH="${gopath}" 97 | export GOMODCACHE="${gopath}/pkg/mod" 98 | export GOCACHE="${gopath}/.cache/go-build" 99 | mkdir -p $GOCACHE 100 | export PATH="${PATH}:${go_bin}:${gopath}/bin" 101 | } 102 | 103 | install_golang() { 104 | local version="$1" 105 | local platform="$2" 106 | local filename="go${version}.${platform}.tar.gz" 107 | local download_url="https://golang.google.cn/dl/${filename}" 108 | local temp_dir=$(mktemp -d) 109 | color_echo "$BLUE" "准备下载Go ${version}" 110 | if ! curl -L "${download_url}" -o "${temp_dir}/${filename}"; then 111 | error_exit "下载失败,请检查网络" 112 | fi 113 | tar -C "${temp_dir}" -xzf "${temp_dir}/${filename}" 114 | [[ -d "/usr/local/go" ]] && sudo rm -rf /usr/local/go 115 | sudo mv "${temp_dir}/go" /usr/local/ 116 | rm -rf "${temp_dir}" 117 | color_echo "$GREEN" "Go ${version} 安装成功!" 118 | } 119 | 120 | main() { 121 | if [[ $EUID -ne 0 ]]; then 122 | error_exit "此脚本需要root权限运行" 123 | fi 124 | if ! network_check "golang.org"; then 125 | color_echo "$YELLOW" "国外网络不通,将使用国内代理" 126 | export GOPROXY=https://goproxy.cn,direct 127 | fi 128 | local platform=$(get_system_arch) 129 | local version=$(get_latest_go_version) 130 | install_golang "$version" "$platform" 131 | setup_go_environment 132 | go version 133 | color_echo "$GREEN" "Golang 安装和配置完成!" 134 | } 135 | 136 | main 137 | -------------------------------------------------------------------------------- /install_scripts/jupyter.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #by spiritlhl 3 | #from https://github.com/spiritLHLS/one-click-installation-script 4 | #version: 2023.09.26 5 | 6 | utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8") 7 | if [[ -z "$utf8_locale" ]]; then 8 | echo "No UTF-8 locale found" 9 | else 10 | export LC_ALL="$utf8_locale" 11 | export LANG="$utf8_locale" 12 | export LANGUAGE="$utf8_locale" 13 | echo "Locale set to $utf8_locale" 14 | fi 15 | cd /root >/dev/null 2>&1 16 | ver="2023.07.26" 17 | changeLog="一键安装jupyter环境" 18 | source ~/.bashrc 19 | red() { echo -e "\033[31m\033[01m$1$2\033[0m"; } 20 | green() { echo -e "\033[32m\033[01m$1$2\033[0m"; } 21 | yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; } 22 | reading() { read -rp "$(green "$1")" "$2"; } 23 | temp_file_apt_fix="apt_fix.txt" 24 | REGEX=("debian|astra" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'" "fedora" "arch" "freebsd") 25 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Fedora" "Arch" "FreeBSD") 26 | PACKAGE_UPDATE=("! apt-get update && apt-get --fix-broken install -y && apt-get update" "apt-get update" "yum -y update" "yum -y update" "yum -y update" "pacman -Sy" "pkg update") 27 | PACKAGE_INSTALL=("apt-get -y install" "apt-get -y install" "yum -y install" "yum -y install" "yum -y install" "pacman -Sy --noconfirm --needed" "pkg install -y") 28 | PACKAGE_REMOVE=("apt-get -y remove" "apt-get -y remove" "yum -y remove" "yum -y remove" "yum -y remove" "pacman -Rsc --noconfirm" "pkg delete") 29 | PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "" "pkg autoremove") 30 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(uname -s)") 31 | SYS="${CMD[0]}" 32 | [[ -n $SYS ]] || exit 1 33 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 34 | if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then 35 | SYSTEM="${RELEASE[int]}" 36 | [[ -n $SYSTEM ]] && break 37 | fi 38 | done 39 | 40 | clear 41 | echo "#######################################################################" 42 | echo "# ${YELLOW}一键安装jupyter环境${PLAIN} #" 43 | echo "# 版本:$ver #" 44 | echo "# 更新日志:$changeLog #" 45 | echo "# ${GREEN}作者${PLAIN}: spiritlhl #" 46 | echo "# ${GREEN}仓库${PLAIN}: https://github.com/spiritLHLS/one-click-installation-script #" 47 | echo "#######################################################################" 48 | echo "验证已支持的系统:" 49 | echo "Ubuntu 系 - 推荐,脚本自动挂起到后台" 50 | echo "Debian 系 - 部分可能需要手动挂起到后台,详看脚本运行安装完毕的后续提示" 51 | echo "可能支持的系统:centos 7+,Fedora,Almalinux 8.5+" 52 | red "本脚本尝试使用Miniconda3安装虚拟环境jupyter-env再进行jupyter和jupyterlab的安装,如若安装机器不纯净勿要轻易使用本脚本!" 53 | yellow "执行脚本,之前有用本脚本安装过则直接打印设置的登陆信息,没安装过则进行安装再打印信息,如果已安装但未启动则自动启动后再打印信息" 54 | yellow "如果是初次安装无脑y无脑回车即可,按照提示进行操作即可,安装完毕将在后台常驻运行,自动添加常用的安装包通道源" 55 | 56 | check_china() { 57 | yellow "IP area being detected ......" 58 | if [[ -z "${CN}" ]]; then 59 | if [[ $(curl -m 6 -s https://ipapi.co/json | grep 'China') != "" ]]; then 60 | yellow "根据ipapi.co提供的信息,当前IP可能在中国" 61 | read -e -r -p "是否选用中国镜像完成相关组件安装? ([y]/n) " input 62 | case $input in 63 | [yY][eE][sS] | [yY]) 64 | echo "使用中国镜像" 65 | CN=true 66 | ;; 67 | [nN][oO] | [nN]) 68 | echo "不使用中国镜像" 69 | ;; 70 | *) 71 | echo "使用中国镜像" 72 | CN=true 73 | ;; 74 | esac 75 | else 76 | if [[ $? -ne 0 ]]; then 77 | if [[ $(curl -m 6 -s cip.cc) =~ "中国" ]]; then 78 | yellow "根据cip.cc提供的信息,当前IP可能在中国" 79 | read -e -r -p "是否选用中国镜像完成相关组件安装? [Y/n] " input 80 | case $input in 81 | [yY][eE][sS] | [yY]) 82 | echo "使用中国镜像" 83 | CN=true 84 | ;; 85 | [nN][oO] | [nN]) 86 | echo "不使用中国镜像" 87 | ;; 88 | *) 89 | echo "不使用中国镜像" 90 | ;; 91 | esac 92 | fi 93 | fi 94 | fi 95 | fi 96 | } 97 | 98 | check_update() { 99 | yellow "Updating package management sources" 100 | if command -v apt-get >/dev/null 2>&1; then 101 | apt_update_output=$(apt-get update 2>&1) 102 | echo "$apt_update_output" >"$temp_file_apt_fix" 103 | if grep -q 'NO_PUBKEY' "$temp_file_apt_fix"; then 104 | public_keys=$(grep -oE 'NO_PUBKEY [0-9A-F]+' "$temp_file_apt_fix" | awk '{ print $2 }') 105 | joined_keys=$(echo "$public_keys" | paste -sd " ") 106 | yellow "No Public Keys: ${joined_keys}" 107 | apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ${joined_keys} 108 | apt-get update 109 | if [ $? -eq 0 ]; then 110 | green "Fixed" 111 | fi 112 | fi 113 | rm "$temp_file_apt_fix" 114 | else 115 | ${PACKAGE_UPDATE[int]} 116 | fi 117 | rm -rf $temp_file_apt_fix 118 | } 119 | 120 | check_sudo() { 121 | yellow "checking sudo" 122 | if ! command -v sudo >/dev/null 2>&1; then 123 | yellow "Installing sudo" 124 | ${PACKAGE_INSTALL[int]} sudo >/dev/null 2>&1 125 | fi 126 | } 127 | 128 | check_wget() { 129 | if ! which wget >/dev/null; then 130 | yellow "Installing wget" 131 | ${PACKAGE_INSTALL[int]} wget 132 | fi 133 | } 134 | 135 | check_curl() { 136 | if ! which curl >/dev/null; then 137 | yellow "Installing curl" 138 | ${PACKAGE_INSTALL[int]} curl 139 | fi 140 | if [ $? -ne 0 ]; then 141 | apt-get -f install >/dev/null 2>&1 142 | ${PACKAGE_INSTALL[int]} curl 143 | fi 144 | } 145 | 146 | check_ufw() { 147 | if ! which ufw >/dev/null; then 148 | yellow "Installing ufw" 149 | ${PACKAGE_INSTALL[int]} ufw 150 | fi 151 | } 152 | 153 | is_private_ipv4() { 154 | local ip_address=$1 155 | local ip_parts 156 | if [[ -z $ip_address ]]; then 157 | return 0 # 输入为空 158 | fi 159 | IFS='.' read -r -a ip_parts <<<"$ip_address" 160 | # 检查IP地址是否符合内网IP地址的范围 161 | # 去除 回环,REC 1918,多播 地址 162 | if [[ ${ip_parts[0]} -eq 10 ]] || 163 | [[ ${ip_parts[0]} -eq 172 && ${ip_parts[1]} -ge 16 && ${ip_parts[1]} -le 31 ]] || 164 | [[ ${ip_parts[0]} -eq 192 && ${ip_parts[1]} -eq 168 ]] || 165 | [[ ${ip_parts[0]} -eq 127 ]] || 166 | [[ ${ip_parts[0]} -eq 0 ]] || 167 | [[ ${ip_parts[0]} -ge 224 ]]; then 168 | return 0 # 是内网IP地址 169 | else 170 | return 1 # 不是内网IP地址 171 | fi 172 | } 173 | 174 | check_ipv4() { 175 | IPV4=$(ip -4 addr show | grep global | awk '{print $2}' | cut -d '/' -f1 | head -n 1) 176 | if is_private_ipv4 "$IPV4"; then # 由于是内网IPV4地址,需要通过API获取外网地址 177 | IPV4="" 178 | local API_NET=("ipv4.ip.sb" "ipget.net" "ip.ping0.cc" "https://ip4.seeip.org" "https://api.my-ip.io/ip" "https://ipv4.icanhazip.com" "api.ipify.org") 179 | for p in "${API_NET[@]}"; do 180 | response=$(curl -s4m8 "$p") 181 | sleep 1 182 | if [ $? -eq 0 ] && ! echo "$response" | grep -q "error"; then 183 | IP_API="$p" 184 | IPV4="$response" 185 | break 186 | fi 187 | done 188 | fi 189 | export IPV4 190 | } 191 | 192 | install_jupyter() { 193 | rm -rf Miniconda3-latest-Linux-x86_64.sh* 194 | check_update 195 | check_sudo 196 | check_wget 197 | check_curl 198 | check_ufw 199 | if ! command -v conda &>/dev/null; then 200 | wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh 201 | bash Miniconda3-latest-Linux-x86_64.sh -b -u 202 | echo 'export PATH="$PATH:$HOME/miniconda3/bin:$HOME/miniconda3/condabin"' >>~/.bashrc 203 | echo 'export PATH="$PATH:$HOME/.local/share/jupyter"' >>~/.bashrc 204 | source ~/.bashrc 205 | sleep 1 206 | echo 'export PATH="/home/user/miniconda3/bin:$PATH"' >>~/.bashrc 207 | source ~/.bashrc 208 | sleep 1 209 | export PATH="/home/user/miniconda3/bin:$PATH" 210 | green "请关闭本窗口开一个新窗口再执行本脚本,否则无法加载一些预设的环境变量(或断开SSH连接后重新连接)" && exit 0 211 | fi 212 | green "加载预设的conda环境变量成功,准备安装jupyter,无脑输入y和回车即可" 213 | conda create -n jupyter-env python=3 214 | sleep 5 215 | source activate jupyter-env 216 | sleep 1 217 | conda install jupyter jupyterlab 218 | check_china 219 | if [[ -n "${CN}" && "${CN}" == true ]]; then 220 | conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ 221 | conda config --set show_channel_urls yes 222 | fi 223 | echo 'export PATH="$PATH:~/.local/share/jupyter"' >>/etc/profile 224 | source /etc/profile 225 | # jupyter notebook --generate-config 226 | # cp ~/.jupyter/jupyter_notebook_config.py ~/.jupyter/jupyter_server_config.py 227 | jupyter server --generate-config 228 | # echo "c.ServerApp.password = 'spiritlhl'" >> ~/.jupyter/jupyter_server_config.py 229 | # echo "c.ServerApp.username = 'spiritlhl'" >> ~/.jupyter/jupyter_server_config.py 230 | if command -v ufw &>/dev/null; then 231 | sudo ufw allow 13692/tcp 232 | elif command -v firewall-cmd &>/dev/null; then 233 | sudo firewall-cmd --add-port=13692/tcp --permanent 234 | sudo firewall-cmd --reload 235 | fi 236 | ubuntu_version=$(lsb_release -rs) 237 | channels_to_add=( 238 | "dglteam" 239 | "pytorch" 240 | "conda-forge" 241 | "anaconda" 242 | ) 243 | 244 | source activate jupyter-env 245 | sleep 1 246 | rm -rf nohup.out 247 | green "后台执行的pid的进程ID和输出日志文件名字如下" 248 | nohup jupyter lab --port 13692 --no-browser --ip=0.0.0.0 --allow-root & 249 | green $! 250 | sleep 5 251 | if grep -q 'token=' nohup.out >/dev/null 2>&1; then 252 | cat nohup.out 253 | else 254 | echo "你可能在不支持的系统是执行,运行的最后几行可能有如下提示" 255 | yellow "nohup: failed to run command 'jupyter': No such file or directory" 256 | echo "你需要手动执行下面的命令" 257 | yellow "source activate jupyter-env" 258 | yellow "nohup jupyter lab --port 13692 --no-browser --ip=0.0.0.0 --allow-root" 259 | green "等待5秒后关闭本窗口,开新窗口执行下面的命令查看登陆信息" 260 | yellow "cat nohup.out" 261 | green "如若无成功输出,可尝试重新运行本脚本" 262 | fi 263 | current_channels=$(conda config --get channels) 264 | for channel in "${channels_to_add[@]}"; do 265 | if echo "$current_channels" | grep -q "$channel" >/dev/null 2>&1; then 266 | : 267 | else 268 | conda config --add channels "$channel" >/dev/null 2>&1 269 | fi 270 | done 271 | paths="./miniconda3/envs/jupyter-env/etc/jupyter:./miniconda3/envs/jupyter-env/bin/jupyter:./miniconda3/envs/jupyter-env/share/jupyter" 272 | export PATH="$paths:$PATH" 273 | new_path=$(echo "$PATH" | tr ':' '\n' | awk '!x[$0]++' | tr '\n' ':') 274 | export PATH="$new_path" 275 | source ~/.bashrc 276 | check_ipv4 277 | jpyurl="http://${IPV4}:13692/" 278 | green "已安装jupyter lab的web端到外网端口13692上,请打开你的 外网IP:13692" 279 | green "如果你是在云服务上运行,那么请打开 ${jpyurl} 如果是在本地安装的,请打开 http://127.0.0.1:13692/" 280 | green "初次安装会要求输入token设置密码,token详见上方打印信息或当前目录的nohup.out日志" 281 | green "同时已保存日志输出到当前目录的nohup.out中且已打印5秒日志如上" 282 | green "如果需要进一步查询,请关闭本窗口开一个新窗口再执行本脚本,否则无法加载一些预设的环境变量" 283 | green "如果想要手动查询,输入 source activate jupyter-env && jupyter server list && conda deactivate 即可查询" 284 | exit 0 285 | } 286 | 287 | query_jupyter_info() { 288 | source activate jupyter-env >/dev/null 2>&1 289 | if ! jupyter --version &>/dev/null; then 290 | echo "Error: Jupyter is not installed on this system." 291 | return 1 292 | fi 293 | check_ipv4 294 | jpyurl="http://${IPV4}:13692/" 295 | source activate jupyter-env && jupyter server list && conda deactivate 296 | cat nohup.out 297 | green "已查询登陆信息如上" 298 | green "如果你是在云服务上运行,那么请打开 ${jpyurl} 如果是在本地安装的,请打开 http://127.0.0.1:13692/" 299 | green "token详见上方打印信息或当前目录的nohup.out日志" 300 | green "如果想要手动查询,输入 source activate jupyter-env && jupyter server list && conda deactivate 即可查询" 301 | } 302 | 303 | main() { 304 | source activate jupyter-env >/dev/null 2>&1 305 | if jupyter --version &>/dev/null; then 306 | green "Jupyter is already installed on this system." 307 | if ! (nc -z localhost 13692) >/dev/null 2>&1; then 308 | source activate jupyter-env 309 | rm -rf nohup.out 310 | green "后台未启动jupyter,正在启动" 311 | nohup jupyter lab --port 13692 --no-browser --ip=0.0.0.0 --allow-root & 312 | green $! 313 | sleep 1 314 | jupyter lab 315 | fi 316 | else 317 | reading "Jupyter is not installed on this system. Do you want to install it? (y/n) " confirminstall 318 | echo "" 319 | if [ "$confirminstall" != "y" ]; then 320 | exit 0 321 | fi 322 | install_jupyter 323 | fi 324 | green "The current info for Jupyter:" 325 | query_jupyter_info 326 | } 327 | 328 | main 329 | -------------------------------------------------------------------------------- /install_scripts/rust.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #by spiritlhl 3 | #from https://github.com/spiritLHLS/one-click-installation-script 4 | #version: 2022.12.17 5 | 6 | utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8") 7 | if [[ -z "$utf8_locale" ]]; then 8 | echo "No UTF-8 locale found" 9 | else 10 | export LC_ALL="$utf8_locale" 11 | export LANG="$utf8_locale" 12 | export LANGUAGE="$utf8_locale" 13 | echo "Locale set to $utf8_locale" 14 | fi 15 | red() { echo -e "\033[31m\033[01m$1$2\033[0m"; } 16 | green() { echo -e "\033[32m\033[01m$1$2\033[0m"; } 17 | yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; } 18 | reading() { read -rp "$(green "$1")" "$2"; } 19 | 20 | # 支持系统:Ubuntu 18+,Debian 8+,centos 7+,Fedora,Almalinux 8.5+ 21 | ver="2022.12.18" 22 | changeLog="一键安装rust,加载官方脚本" 23 | clear 24 | echo "#######################################################################" 25 | echo "# ${YELLOW}一键安装rust脚本${PLAIN} #" 26 | echo "# 版本:$ver #" 27 | echo "# 更新日志:$changeLog #" 28 | echo "# ${GREEN}作者${PLAIN}: spiritlhl #" 29 | echo "# ${GREEN}仓库${PLAIN}: https://github.com/spiritLHLS/one-click-installation-script #" 30 | echo "#######################################################################" 31 | echo "支持系统:Ubuntu 18+,Debian 8+,centos 7+,Fedora,Almalinux 8.5+" 32 | # Display prompt asking whether to proceed with installation 33 | reading "Do you want to proceed with the Rust installation? [y/n] " confirm 34 | echo "" 35 | 36 | # Check user's input and exit if they do not want to proceed 37 | if [ "$confirm" != "y" ]; then 38 | exit 0 39 | fi 40 | 41 | # Update package manager's package list 42 | if [ -x "$(command -v apt-get)" ]; then 43 | sudo apt-get update -y 44 | sudo apt-get upgrade -y 45 | sudo apt-get install curl build-essential gcc make -y 46 | elif [ -x "$(command -v yum)" ]; then 47 | sudo yum update -y 48 | sudo yum install curl make gcc-c++ -y 49 | elif [ -x "$(command -v dnf)" ]; then 50 | sudo dnf update -y 51 | sudo dnf install curl make gcc-c++ -y 52 | elif [ -x "$(command -v pacman)" ]; then 53 | sudo pacman -Syu 54 | sudo pacman -S curl make gcc -y 55 | else 56 | echo "Error: This script requires a package manager (apt, yum, dnf, pacman) to be installed on the system." 57 | exit 1 58 | fi 59 | 60 | # Install Rust 61 | echo "Loading official installation script and selecting option 1 for installation" 62 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh 63 | 64 | # Source Rust environment variables 65 | if [ -f "$HOME/.cargo/env" ]; then 66 | source "$HOME/.cargo/env" 67 | fi 68 | if [ -f "$HOME/.profile" ]; then 69 | source "$HOME/.profile" 70 | fi 71 | 72 | # Update Rust 73 | echo "Updating Rust" 74 | rustup update 75 | 76 | # Print version information for cargo, rustc, and rustdoc 77 | echo "Printing version information for cargo, rustc, and rustdoc. If any of these tools are not found or have incorrect versions, the installation may have failed." 78 | cargo --version 79 | rustc --version 80 | rustdoc --version 81 | -------------------------------------------------------------------------------- /install_scripts/todebian11.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #by spiritlhl 3 | #from https://github.com/spiritLHLS/one-click-installation-script 4 | #version: 2023.02.25 5 | 6 | utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8") 7 | if [[ -z "$utf8_locale" ]]; then 8 | echo "No UTF-8 locale found" 9 | else 10 | export LC_ALL="$utf8_locale" 11 | export LANG="$utf8_locale" 12 | export LANGUAGE="$utf8_locale" 13 | echo "Locale set to $utf8_locale" 14 | fi 15 | 16 | # 打印信息 17 | _red() { echo -e "\033[31m\033[01m$@\033[0m"; } 18 | _green() { echo -e "\033[32m\033[01m$@\033[0m"; } 19 | _yellow() { echo -e "\033[33m\033[01m$@\033[0m"; } 20 | _blue() { echo -e "\033[36m\033[01m$@\033[0m"; } 21 | 22 | # 检查是否为 root 用户 23 | if [ "$(id -u)" != "0" ]; then 24 | _red "请使用 root 用户执行脚本" 25 | exit 1 26 | fi 27 | 28 | # 判断是否为 Debian 系统 29 | if [ ! -f /etc/debian_version ]; then 30 | _red "当前系统不是 Debian 系统" 31 | exit 1 32 | fi 33 | 34 | # 从文件中读取当前版本代号 35 | CURRENT_VERSION=$(lsb_release -cs) 36 | 37 | # 判断当前版本是否为最新版本 38 | version=$(cat /etc/debian_version) 39 | if [ $CURRENT_VERSION == "bullseye" ]; then 40 | _blue "当前系统版本为最新版本,Debian version: $version , 代号 $CURRENT_VERSION" 41 | exit 0 42 | else 43 | _blue "当前 Debian version: $version , 代号 $CURRENT_VERSION ,开始升级" 44 | fi 45 | 46 | # 检查脚本是否已经在执行 47 | if [ -f /tmp/debian_upgrade_in_progress ]; then 48 | _yellow "升级正在进行中,请勿重复执行,如若已停止执行请重启服务器并删除文件 /tmp/debian_upgrade_in_progress " 49 | exit 1 50 | fi 51 | 52 | # 标记脚本已经在执行 53 | touch /tmp/debian_upgrade_in_progress 54 | 55 | # 设置升级前备份的文件夹路径 56 | BACKUP_DIR="/root/debian_upgrade_backup" 57 | 58 | # 创建备份文件夹 59 | mkdir -p $BACKUP_DIR 60 | 61 | # 更新软件包列表 62 | apt update 63 | 64 | # 升级已安装的软件包 65 | apt upgrade -y 66 | 67 | # 升级系统到最新版本 68 | if [ $CURRENT_VERSION == "squeeze" ]; then 69 | sed -i 's/squeeze/wheezy/g' /etc/apt/sources.list 70 | elif [ $CURRENT_VERSION == "wheezy" ]; then 71 | sed -i 's/wheezy/jessie/g' /etc/apt/sources.list 72 | elif [ $CURRENT_VERSION == "jessie" ]; then 73 | sed -i 's/jessie/stretch/g' /etc/apt/sources.list 74 | elif [ $CURRENT_VERSION == "stretch" ]; then 75 | sed -i 's/stretch/buster/g' /etc/apt/sources.list 76 | elif [ $CURRENT_VERSION == "buster" ]; then 77 | sed -i 's/buster/bullseye/g' /etc/apt/sources.list 78 | fi 79 | 80 | replace() { 81 | sed -i 's/^deb http:\/\/security.debian.org\/debian-security wheezy\/updates main/# &/' /etc/apt/sources.list 82 | sed -i 's/^deb-src http:\/\/security.debian.org\/debian-security wheezy\/updates main/# &/' /etc/apt/sources.list 83 | sed -i 's/^deb http:\/\/security.debian.org\/debian-security jessie\/updates main/# &/' /etc/apt/sources.list 84 | sed -i 's/^deb-src http:\/\/security.debian.org\/debian-security jessie\/updates main/# &/' /etc/apt/sources.list 85 | sed -i 's/^deb http:\/\/security.debian.org\/debian-security stretch\/updates main/# &/' /etc/apt/sources.list 86 | sed -i 's/^deb-src http:\/\/security.debian.org\/debian-security stretch\/updates main/# &/' /etc/apt/sources.list 87 | sed -i 's/^deb http:\/\/security.debian.org\/debian-security buster\/updates main/# &/' /etc/apt/sources.list 88 | sed -i 's/^deb-src http:\/\/security.debian.org\/debian-security buster\/updates main/# &/' /etc/apt/sources.list 89 | sed -i 's/^deb http:\/\/security.debian.org\/debian-security bullseye\/updates main/# &/' /etc/apt/sources.list 90 | sed -i 's/^deb-src http:\/\/security.debian.org\/debian-security bullseye\/updates main/# &/' /etc/apt/sources.list 91 | } 92 | 93 | apt-get update 94 | if [ $? -ne 0 ]; then 95 | # 去除漏洞修补源避免更新异常 96 | replace >/dev/null 2>&1 97 | apt-get update 98 | fi 99 | apt-get upgrade -y 100 | apt-get full-upgrade -y 101 | 102 | # 清理系统 103 | apt-get autoremove -y 104 | apt-get autoclean 105 | 106 | # 备份系统配置文件 107 | cp -r /etc $BACKUP_DIR 108 | 109 | # 删除标记文件 110 | rm /tmp/debian_upgrade_in_progress 111 | 112 | _green "脚本执行完毕系统内核应当已升级到最新版本,执行 reboot 重启系统以完成内核升级" 113 | -------------------------------------------------------------------------------- /install_scripts/toubuntu22.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #from https://github.com/spiritLHLS/one-click-installation-script 3 | 4 | utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8") 5 | if [[ -z "$utf8_locale" ]]; then 6 | echo "No UTF-8 locale found" 7 | else 8 | export LC_ALL="$utf8_locale" 9 | export LANG="$utf8_locale" 10 | export LANGUAGE="$utf8_locale" 11 | echo "Locale set to $utf8_locale" 12 | fi 13 | 14 | # 打印信息 15 | _red() { echo -e "\033[31m\033[01m$@\033[0m"; } 16 | _green() { echo -e "\033[32m\033[01m$@\033[0m"; } 17 | _yellow() { echo -e "\033[33m\033[01m$@\033[0m"; } 18 | _blue() { echo -e "\033[36m\033[01m$@\033[0m"; } 19 | reading() { read -rp "$(_green "$1")" "$2"; } 20 | 21 | # 检查是否有sudo权限 22 | if [ $(id -u) -ne 0 ]; then 23 | _red "This script must be run as root. Please run with sudo." >&2 24 | exit 1 25 | fi 26 | 27 | # 获取当前系统版本 28 | CURRENT_VER=$(lsb_release -rs) 29 | 30 | # 支持升级的版本 31 | SUPPORTED_VERSIONS=("16.04" "17.04" "17.10" "18.04" "19.04" "19.10" "20.04" "20.10" "21.04" "21.10") 32 | 33 | # 检查是否支持当前版本的升级 34 | if [[ ! " ${SUPPORTED_VERSIONS[@]} " =~ " ${CURRENT_VER} " ]]; then 35 | _red "Unsupported Ubuntu version. This script supports Ubuntu 16, 17, 18, 19, 20 and 21 only." >&2 36 | exit 1 37 | fi 38 | 39 | # 更新软件源和安装必要的升级工具 40 | apt-get update 41 | apt-get install -y update-manager-core 42 | 43 | # 升级 Ubuntu 16 到 18 44 | if [ "$CURRENT_VER" == "16.04" ]; then 45 | _green "Upgrading Ubuntu 16 to 18..." 46 | sed -i 's/xenial/bionic/g' /etc/apt/sources.list 47 | do-release-upgrade -d -f DistUpgradeViewNonInteractive 48 | 49 | # 升级 Ubuntu 17 到 18 50 | elif [ "$CURRENT_VER" == "17.04" ] || [ "$CURRENT_VER" == "17.10" ]; then 51 | _green "Upgrading Ubuntu 17 to 18..." 52 | sed -i 's/zesty/bionic/g' /etc/apt/sources.list 53 | do-release-upgrade -d -f DistUpgradeViewNonInteractive 54 | 55 | # 升级 Ubuntu 18 到 20 56 | elif [ "$CURRENT_VER" == "18.04" ]; then 57 | _green "Upgrading Ubuntu 18 to 20..." 58 | do-release-upgrade -d -f DistUpgradeViewNonInteractive 59 | 60 | # 升级 Ubuntu 19 到 20 61 | elif [ "$CURRENT_VER" == "19.04" ] || [ "$CURRENT_VER" == "19.10" ]; then 62 | _green "Upgrading Ubuntu 19 to 20..." 63 | sed -i 's/disco/eoan/g' /etc/apt/sources.list 64 | do-release-upgrade -d -f DistUpgradeViewNonInteractive 65 | 66 | # 升级 Ubuntu 20 或 21 到 22 67 | else 68 | _green "Upgrading Ubuntu 20/21 to 22..." 69 | do-release-upgrade -d -f DistUpgradeViewNonInteractive 70 | fi 71 | -------------------------------------------------------------------------------- /install_scripts/vnstat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #by spiritlhl 3 | #from https://github.com/spiritLHLS/one-click-installation-script 4 | #version: 2023.02.15 5 | 6 | utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8") 7 | if [[ -z "$utf8_locale" ]]; then 8 | echo "No UTF-8 locale found" 9 | else 10 | export LC_ALL="$utf8_locale" 11 | export LANG="$utf8_locale" 12 | export LANGUAGE="$utf8_locale" 13 | echo "Locale set to $utf8_locale" 14 | fi 15 | red() { echo -e "\033[31m\033[01m$1$2\033[0m"; } 16 | green() { echo -e "\033[32m\033[01m$1$2\033[0m"; } 17 | yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; } 18 | reading() { read -rp "$(green "$1")" "$2"; } 19 | 20 | head() { 21 | ver="2023.02.15" 22 | changeLog="一键安装vnstat脚本" 23 | clear 24 | echo "#######################################################################" 25 | echo "# ${YELLOW}一键安装vnstat脚本${PLAIN} #" 26 | echo "# 版本:$ver #" 27 | echo "# 更新日志:$changeLog #" 28 | echo "# ${GREEN}作者${PLAIN}: spiritlhl #" 29 | echo "# ${GREEN}仓库${PLAIN}: https://github.com/spiritLHLS/one-click-installation-script #" 30 | echo "#######################################################################" 31 | echo "支持系统:Ubuntu 18+,Debian 8+,centos 7+,Fedora,Almalinux 8.5+" 32 | echo "加载官方文件编译安装,前置条件适配系统以及后置条件判断安装的版本" 33 | # Display prompt asking whether to proceed with installation 34 | reading "Do you want to proceed with installation? [y/n] " confirm 35 | echo "" 36 | 37 | # Check user's input and exit if they do not want to proceed 38 | if [ "$confirm" != "y" ]; then 39 | exit 0 40 | fi 41 | } 42 | 43 | check_os() { 44 | # 检测系统类型 45 | if [ -f /etc/lsb-release ]; then 46 | # Ubuntu/Debian/Almalinux 47 | OS="Ubuntu/Debian/Almalinux" 48 | elif [ -f /etc/redhat-release ]; then 49 | # CentOS/Fedora 50 | OS="CentOS/Fedora" 51 | else 52 | # 未知系统 53 | OS="Unknown" 54 | fi 55 | } 56 | 57 | main() { 58 | if [ "$OS" == "Ubuntu/Debian/Almalinux" ]; then 59 | # Update package repositories and install dependencies 60 | apt-get update 61 | apt-get install -y wget sudo curl build-essential libsqlite3-dev 62 | 63 | # Download and extract vnstat source code 64 | wget https://github.com/vergoh/vnstat/releases/download/v2.10/vnstat-2.10.tar.gz 65 | tar -xvf vnstat-2.10.tar.gz 66 | cd vnstat-2.10/ 67 | 68 | # Compile and install vnstat 69 | ./configure --prefix=/usr --sysconfdir=/etc 70 | make 71 | make install 72 | 73 | # Enable and start the vnstat service 74 | systemctl enable vnstat 75 | systemctl start vnstat 76 | 77 | apt-get install chkconfig -y 78 | if [ $? -ne 0 ]; then 79 | apt-get install sysv-rc-conf -y 80 | if [ $? -ne 0 ]; then 81 | apt-get update && apt-get install sysv-rc-conf -y 82 | fi 83 | fi 84 | ! chkconfig vnstat on && echo "replace chkconfig with sysv-rc-conf" && sysv-rc-conf vnstat on 85 | service vnstat start 86 | 87 | # Check if vnstat is installed and working properly 88 | vnstat -v 89 | vnstatd -v 90 | 91 | # Check if vnstati is installed and working properly 92 | if which vnstati >/dev/null; then 93 | vnstati -v 94 | else 95 | echo "vnstat was compiled and installed without the vnstati tool. If you need to use it, please run 'apt-get install vnstati -y' to install the version from the package repository." 96 | fi 97 | elif [ "$OS" == "CentOS/Fedora" ]; then 98 | yum update -y 99 | yum install -y wget sudo curl make gcc sqlite-devel 100 | 101 | # Download and extract vnstat source code 102 | wget https://github.com/vergoh/vnstat/releases/download/v2.10/vnstat-2.10.tar.gz 103 | tar -xvf vnstat-2.10.tar.gz 104 | cd vnstat-2.10/ 105 | 106 | # Compile and install vnstat 107 | ./configure --prefix=/usr --sysconfdir=/etc 108 | make 109 | make install 110 | 111 | # Enable and start the vnstat service 112 | systemctl enable vnstat 113 | systemctl start vnstat 114 | 115 | # Check if vnstat is installed and working properly 116 | vnstat -v 117 | vnstatd -v 118 | 119 | # Check if vnstati is installed and working properly 120 | if which vnstati >/dev/null; then 121 | vnstati -v 122 | else 123 | echo "vnstat was compiled and installed without the vnstati tool. If you need to use it, please run 'yum install vnstati -y' or 'dnf install vnstati -y' to install the version from the package repository." 124 | fi 125 | fi 126 | } 127 | 128 | head 129 | check_os 130 | main 131 | -------------------------------------------------------------------------------- /install_scripts/zipline.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #by spiritlhl 3 | #from https://github.com/spiritLHLS/one-click-installation-script 4 | #version: 2023.06.05 5 | 6 | utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8") 7 | if [[ -z "$utf8_locale" ]]; then 8 | echo "No UTF-8 locale found" 9 | else 10 | export LC_ALL="$utf8_locale" 11 | export LANG="$utf8_locale" 12 | export LANGUAGE="$utf8_locale" 13 | echo "Locale set to $utf8_locale" 14 | fi 15 | cd /root >/dev/null 2>&1 16 | ver="2023.06.05" 17 | changeLog="一键安装Zipline平台" 18 | source ~/.bashrc 19 | red() { echo -e "\033[31m\033[01m$1$2\033[0m"; } 20 | green() { echo -e "\033[32m\033[01m$1$2\033[0m"; } 21 | yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; } 22 | blue() { echo -e "\033[36m\033[01m$@\033[0m"; } 23 | reading() { read -rp "$(green "$1")" "$2"; } 24 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'" "fedora" "arch") 25 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Fedora" "Arch") 26 | PACKAGE_UPDATE=("! apt-get update && apt-get --fix-broken install -y && apt-get update" "apt-get update" "yum -y update" "yum -y update" "yum -y update" "pacman -Sy") 27 | PACKAGE_INSTALL=("apt-get -y install" "apt-get -y install" "yum -y install" "yum -y install" "yum -y install" "pacman -Sy --noconfirm --needed") 28 | PACKAGE_REMOVE=("apt-get -y remove" "apt-get -y remove" "yum -y remove" "yum -y remove" "yum -y remove" "pacman -Rsc --noconfirm") 29 | PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "") 30 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)") 31 | SYS="${CMD[0]}" 32 | [[ -n $SYS ]] || exit 1 33 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 34 | if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then 35 | SYSTEM="${RELEASE[int]}" 36 | [[ -n $SYSTEM ]] && break 37 | fi 38 | done 39 | apt-get --fix-broken install -y >/dev/null 2>&1 40 | clear 41 | echo "#######################################################################" 42 | echo "# ${YELLOW}一键安装Zipline平台${PLAIN} #" 43 | echo "# 版本:$ver #" 44 | echo "# 更新日志:$changeLog #" 45 | echo "# ${GREEN}作者${PLAIN}: spiritlhl #" 46 | echo "# ${GREEN}仓库${PLAIN}: https://github.com/spiritLHLS/one-click-installation-script #" 47 | echo "#######################################################################" 48 | 49 | # 判断宿主机的 IPv4 或双栈情况 没有拉取不了 docker 50 | check_ipv4() { 51 | # 遍历本机可以使用的 IP API 服务商 52 | # 定义可能的 IP API 服务商 53 | API_NET=("ip.sb" "ipget.net" "ip.ping0.cc" "https://ip4.seeip.org" "https://api.my-ip.io/ip" "https://ipv4.icanhazip.com" "api.ipify.org") 54 | 55 | # 遍历每个 API 服务商,并检查它是否可用 56 | for p in "${API_NET[@]}"; do 57 | # 使用 curl 请求每个 API 服务商 58 | response=$(curl -s4m8 "$p") 59 | sleep 1 60 | # 检查请求是否失败,或者回传内容中是否包含 error 61 | if [ $? -eq 0 ] && ! echo "$response" | grep -q "error"; then 62 | # 如果请求成功且不包含 error,则设置 IP_API 并退出循环 63 | IP_API="$p" 64 | break 65 | fi 66 | done 67 | 68 | # 判断宿主机的 IPv4 、IPv6 和双栈情况 69 | ! curl -s4m8 $IP_API | grep -q '\.' && red " ERROR:The host must have IPv4. " && exit 1 70 | IPV4=$(curl -s4m8 "$IP_API") 71 | } 72 | 73 | build() { 74 | if ! systemctl is-active docker >/dev/null 2>&1; then 75 | green "\n Install docker.\n " 76 | if [ $SYSTEM = "CentOS" ]; then 77 | ${PACKAGE_INSTALL[int]} yum-utils 78 | yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo && 79 | ${PACKAGE_INSTALL[int]} docker-ce docker-ce-cli containerd.io 80 | systemctl enable --now docker 81 | else 82 | ${PACKAGE_INSTALL[int]} docker.io 83 | fi 84 | fi 85 | 86 | if ! command -v docker-compose >/dev/null 2>&1; then 87 | green "\n Install Docker Compose \n" 88 | curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-linux-$(uname -m)" -o /usr/local/bin/docker-compose 89 | chmod +x /usr/local/bin/docker-compose 90 | fi 91 | 92 | if [ ! -d "zipline" ] && ! docker ps -a | awk '{print $NF}' | grep -q -E 'postgres|zipline'; then 93 | green "\n Building \n " 94 | git clone https://github.com/diced/zipline 95 | if ! command -v git >/dev/null 2>&1; then 96 | green "\n Install git.\n " 97 | if [ $SYSTEM = "CentOS" ]; then 98 | ${PACKAGE_INSTALL[int]} git 99 | else 100 | ${PACKAGE_INSTALL[int]} git-core 101 | fi 102 | fi 103 | cd /root/zipline 104 | docker-compose up -d 105 | CORE_SECRET=$(cat /dev/urandom | tr -dc 'a-z' | fold -w 8 | head -n 1) 106 | sed -i "s/CORE_SECRET=changethis/CORE_SECRET=$CORE_SECRET/g" docker-compose.yml 107 | docker-compose pull 108 | docker-compose up -d 109 | elif [ -d "zipline" ] && docker ps -a | awk '{print $NF}' | grep -q -E 'postgres|zipline'; then 110 | green "\n Updating \n " 111 | cd zipline 112 | docker-compose pull 113 | docker-compose up -d 114 | fi 115 | 116 | green "Checking http://$IPV4:3000/ " 117 | green "You may login to the dashboard with:" 118 | green "Username: administrator" 119 | green "Password: password" 120 | green "Remember to change this password in the manage user page" 121 | } 122 | 123 | check_nginx() { 124 | if ! [ -x "$(command -v nginx)" ]; then 125 | green "\n Install nginx.\n " 126 | ${PACKAGE_UPDATE[int]} 127 | ${PACKAGE_INSTALL[int]} nginx 128 | fi 129 | } 130 | 131 | build_reverse_proxy() { 132 | green "\n Build reverse proxy. \n " 133 | reading "Enter the domain name to bind to (format: www.example.com): " domain_name 134 | resolved_ip=$(dig +short $domain_name) 135 | if [ "$resolved_ip" != "$IPV4" ]; then 136 | red "Error: $domain_name is not bound to the local IP address." 137 | exit 1 138 | fi 139 | 140 | sudo tee /etc/nginx/sites-available/reverse-proxy </dev/null | grep -i -m 1 -E "UTF-8|utf8") 7 | if [[ -z "$utf8_locale" ]]; then 8 | echo "No UTF-8 locale found" 9 | else 10 | export LC_ALL="$utf8_locale" 11 | export LANG="$utf8_locale" 12 | export LANGUAGE="$utf8_locale" 13 | echo "Locale set to $utf8_locale" 14 | fi 15 | red() { echo -e "\033[31m\033[01m$1$2\033[0m"; } 16 | green() { echo -e "\033[32m\033[01m$1$2\033[0m"; } 17 | yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; } 18 | reading() { read -rp "$(green "$1")" "$2"; } 19 | 20 | head() { 21 | # 支持系统:Ubuntu 12+,Debian 6+ 22 | ver="2022.12.18" 23 | changeLog="修复sudo: unable to resolve host警告" 24 | clear 25 | echo "#######################################################################" 26 | echo "# ${YELLOW}修复sudo: unable to resolve host xxx: Name or service not known警告${PLAIN} #" 27 | echo "# 版本:$ver #" 28 | echo "# 更新日志:$changeLog #" 29 | echo "# ${GREEN}作者${PLAIN}: spiritlhl #" 30 | echo "# ${GREEN}仓库${PLAIN}: https://github.com/spiritLHLS/one-click-installation-script #" 31 | echo "#######################################################################" 32 | echo "支持系统:Ubuntu 18+,Debian 8+,centos 7+,Fedora,Almalinux 8.5+" 33 | echo "检测修复sudo: unable to resolve host xxx: Name or service not known爆错" 34 | # Display prompt asking whether to proceed with fixing 35 | reading "Do you want to proceed with fixing? [y/n] " confirm 36 | echo "" 37 | 38 | # Check user's input and exit if they do not want to proceed 39 | if [ "$confirm" != "y" ]; then 40 | exit 0 41 | fi 42 | } 43 | 44 | # Check if the hostname is set correctly in /etc/hosts 45 | HOSTNAME=$(cat /etc/hostname) 46 | HOSTS_LINE="$(grep $HOSTNAME /etc/hosts)" 47 | 48 | if [ -z "$HOSTS_LINE" ]; then 49 | # Hostname not found in /etc/hosts. Add it. 50 | yellow "Updating /etc/hosts with hostname: $HOSTNAME" 51 | echo "127.0.0.1 $HOSTNAME" | sudo tee -a /etc/hosts 52 | else 53 | # Hostname found in /etc/hosts. Check if the IP address is correct. 54 | HOSTS_IP="$(awk '{print $1}' <<<$HOSTS_LINE)" 55 | if [ "$HOSTS_IP" != "127.0.0.1" ]; then 56 | # IP address is incorrect. Update it. 57 | yellow "Updating IP address for $HOSTNAME in /etc/hosts" 58 | temp_file=$(mktemp) 59 | backup_file="/etc/hosts-$(date +%Y%m%d%H%M%S).bak" 60 | cp /etc/hosts "$backup_file" 61 | yellow "Backed up /etc/hosts to $backup_file" 62 | awk -v new_ip="127.0.0.1" -v hostname="$HOSTNAME" '{ if ($2 == hostname) { print new_ip " " $2 } else { print $0 } }' /etc/hosts >"$temp_file" 63 | cp "$temp_file" /etc/hosts 64 | rm "$temp_file" 65 | else 66 | # Hostname and IP address are correct. No changes needed. 67 | green "Hostname and IP address in /etc/hosts are correct." 68 | fi 69 | fi 70 | 71 | # Check if the sudo command works 72 | sudo yellow "Testing sudo command..." 73 | if [ $? -eq 0 ]; then 74 | # Sudo command works. Exit the script. 75 | green "Fix successful. Exiting script." 76 | else 77 | # Sudo command failed. Try restarting the networking interface. 78 | yellow "Sudo command still failing. Restarting networking interface." 79 | sudo service networking restart 80 | 81 | # Check if the sudo command works after restarting the networking interface 82 | sudo echo "Testing sudo command after restarting networking interface..." 83 | if [ $? -eq 0 ]; then 84 | # Sudo command works. Exit the script. 85 | green "Fix successful. Exiting script." 86 | else 87 | # Sudo command failed. Try restarting the DNS server. 88 | yellow "Sudo command still failing. Restarting DNS server." 89 | sudo service bind9 restart 90 | 91 | # Check if the sudo command works after restarting the DNS server 92 | sudo echo "Testing sudo command after restarting DNS server..." 93 | if [ $? -eq 0 ]; then 94 | # Sudo command works. Exit the script. 95 | green "Fix successful. Exiting script." 96 | else 97 | # Sudo command still failing. Exiting script. 98 | red "Unable to fix problem. Exiting script." 99 | fi 100 | fi 101 | fi 102 | -------------------------------------------------------------------------------- /repair_scripts/modify_time.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #by spiritlhl 3 | #from https://github.com/spiritLHLS/one-click-installation-script 4 | #version: 2023.05.22 5 | 6 | red() { echo -e "\033[31m\033[01m$1$2\033[0m"; } 7 | green() { echo -e "\033[32m\033[01m$1$2\033[0m"; } 8 | yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; } 9 | reading() { read -rp "$(green "$1")" "$2"; } 10 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'" "fedora" "arch") 11 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Fedora" "Arch") 12 | PACKAGE_UPDATE=("! apt-get update && apt-get --fix-broken install -y && apt-get update" "apt-get update" "yum -y update" "yum -y update" "yum -y update" "pacman -Sy") 13 | PACKAGE_INSTALL=("apt-get -y install" "apt-get -y install" "yum -y install" "yum -y install" "yum -y install" "pacman -Sy --noconfirm --needed") 14 | PACKAGE_REMOVE=("apt-get -y remove" "apt-get -y remove" "yum -y remove" "yum -y remove" "yum -y remove" "pacman -Rsc --noconfirm") 15 | PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "") 16 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)") 17 | SYS="${CMD[0]}" 18 | [[ -n $SYS ]] || exit 1 19 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 20 | if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then 21 | SYSTEM="${RELEASE[int]}" 22 | [[ -n $SYSTEM ]] && break 23 | fi 24 | done 25 | utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8") 26 | if [[ -z "$utf8_locale" ]]; then 27 | yellow "No UTF-8 locale found" 28 | else 29 | export LC_ALL="$utf8_locale" 30 | export LANG="$utf8_locale" 31 | export LANGUAGE="$utf8_locale" 32 | green "Locale set to $utf8_locale" 33 | fi 34 | apt-get --fix-broken install -y >/dev/null 2>&1 35 | rm -rf test_result.txt >/dev/null 2>&1 36 | 37 | head() { 38 | ver="2023.05.22" 39 | changeLog="一键修复本机系统时间" 40 | clear 41 | echo "#######################################################################" 42 | echo "# ${YELLOW}一键修复本机系统时间脚本${PLAIN} #" 43 | echo "# 版本:$ver #" 44 | echo "# 更新日志:$changeLog #" 45 | echo "# ${GREEN}作者${PLAIN}: spiritlhl #" 46 | echo "# ${GREEN}作仓库${PLAIN}: https://github.com/spiritLHLS/one-click-installation-script #" 47 | echo "#######################################################################" 48 | echo "支持系统:Ubuntu 18+,Debian 8+,centos 7+,Fedora,Almalinux 8.5+" 49 | echo "由于系统时间不准确都是未进行时区时间同步造成的,使用chronyd进行时区时间同步后应当解决了问题" 50 | # Display prompt asking whether to proceed with checking and changing 51 | reading "Do you want to proceed with checking and changing? [y/n] " confirm 52 | echo "" 53 | 54 | # Check user's input and exit if they do not want to proceed 55 | if [ "$confirm" != "y" ]; then 56 | exit 0 57 | fi 58 | } 59 | 60 | check_time_zone() { 61 | _yellow "adjusting the time" 62 | if ! command -v chronyd >/dev/null 2>&1; then 63 | ${PACKAGE_INSTALL[int]} chrony >/dev/null 2>&1 64 | fi 65 | systemctl stop chronyd 66 | chronyd -q 67 | systemctl start chronyd 68 | sleep 0.5 69 | } 70 | 71 | head 72 | check_time_zone 73 | sleep 1 74 | -------------------------------------------------------------------------------- /repair_scripts/nat64_optimizer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #by spiritlhl 3 | #from https://github.com/spiritLHLS/one-click-installation-script 4 | #version: 2024.12.25 5 | 6 | 7 | # 颜色和提示函数 8 | red() { echo -e "\033[31m\033[01m$1$2\033[0m"; } 9 | green() { echo -e "\033[32m\033[01m$1$2\033[0m"; } 10 | yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; } 11 | reading() { read -rp "$(green "$1")" "$2"; } 12 | 13 | # 判断系统环境 14 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'" "fedora" "arch") 15 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Fedora" "Arch") 16 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 17 | 18 | SYS="${CMD[0]}" 19 | [[ -n $SYS ]] || exit 1 20 | 21 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 22 | if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then 23 | SYSTEM="${RELEASE[int]}" 24 | [[ -n $SYSTEM ]] && break 25 | fi 26 | done 27 | 28 | # 检查 root 权限 29 | [[ $EUID -ne 0 ]] && red "请在root用户下运行脚本" && exit 1 30 | 31 | # 设置UTF-8 32 | utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8") 33 | if [[ -n "$utf8_locale" ]]; then 34 | export LC_ALL="$utf8_locale" 35 | export LANG="$utf8_locale" 36 | export LANGUAGE="$utf8_locale" 37 | fi 38 | 39 | # 临时文件 40 | tmp_servers="/tmp/nat64_servers.txt" 41 | 42 | # 清理函数 43 | cleanup() { 44 | rm -f "$tmp_servers" 45 | stty sane 46 | } 47 | trap cleanup EXIT INT TERM 48 | 49 | # 主逻辑 50 | green "开始获取 NAT64 服务器列表..." 51 | 52 | # 下载并解析服务器列表 53 | curl -g -6 -s "https://raw.githubusercontent.com/level66network/nat64.xyz/refs/heads/main/content/_index.md" | \ 54 | awk -F'|' ' 55 | /\|.*\|.*\|/ { 56 | if ($0 !~ /Provider.*Country.*DNS64/) { 57 | provider = $2 58 | location = $3 59 | dns64 = $4 60 | prefix = $5 61 | 62 | while (match(dns64, /[0-9a-fA-F:]+::[0-9a-fA-F:]*[0-9a-fA-F]+/)) { 63 | ip = substr(dns64, RSTART, RLENGTH) 64 | dns64 = substr(dns64, RSTART + RLENGTH) 65 | 66 | if (match(prefix, /[0-9a-fA-F:]+::[0-9a-fA-F:]*\/[0-9]+/)) { 67 | nat64prefix = substr(prefix, RSTART, RLENGTH) 68 | gsub(/^[[:space:]]+|[[:space:]]+$/, "", ip) 69 | gsub(/^[[:space:]]+|[[:space:]]+$/, "", nat64prefix) 70 | gsub(/^[[:space:]]+|[[:space:]]+$/, "", provider) 71 | gsub(/^[[:space:]]+|[[:space:]]+$/, "", location) 72 | if (ip != "" && nat64prefix != "") { 73 | print provider "|" location "|" ip "|" nat64prefix 74 | } 75 | } 76 | } 77 | } 78 | }' > "$tmp_servers" 79 | 80 | # 测试服务器 81 | green "开始测试服务器延迟..." 82 | best_latency=999999 83 | best_config="" 84 | 85 | while IFS='|' read -r provider location dns64 prefix; do 86 | [[ -z "$provider" ]] && continue 87 | 88 | yellow "测试 $provider ($location)" 89 | yellow "DNS64: $dns64" 90 | 91 | if latency=$(ping6 -c 4 -w 5 "$dns64" 2>/dev/null | grep 'rtt' | cut -d'/' -f5); then 92 | latency=${latency%.*} 93 | green "延迟: ${latency}ms" 94 | 95 | if [ "$latency" -lt "$best_latency" ]; then 96 | best_latency=$latency 97 | best_config="$provider|$location|$dns64|$prefix|$latency" 98 | fi 99 | else 100 | red "无法连接" 101 | fi 102 | done < "$tmp_servers" 103 | 104 | # 显示最佳结果 105 | if [[ -n "$best_config" ]]; then 106 | IFS='|' read -r provider location dns64 prefix latency <<< "$best_config" 107 | green "\n最佳 NAT64 服务器配置:" 108 | yellow "提供商: $provider" 109 | yellow "位置: $location" 110 | yellow "DNS64: $dns64" 111 | yellow "NAT64 前缀: $prefix" 112 | yellow "延迟: ${latency}ms" 113 | 114 | reading "是否要应用这些设置?(y/n) " yn 115 | case $yn in 116 | [Yy]*) 117 | # 备份当前设置 118 | cp /etc/resolv.conf "/etc/resolv.conf.backup.$(date +%Y%m%d_%H%M%S)" 119 | 120 | # 配置 DNS64 121 | echo "nameserver $dns64" > /etc/resolv.conf 122 | 123 | # systemd-resolved 配置 124 | if [[ -f /etc/systemd/resolved.conf ]]; then 125 | sed -i '/^DNS=/c\DNS='"$dns64" /etc/systemd/resolved.conf 126 | systemctl restart systemd-resolved 127 | fi 128 | 129 | green "配置完成!" 130 | yellow "NAT64 前缀: $prefix" 131 | ;; 132 | *) 133 | yellow "已取消配置" 134 | ;; 135 | esac 136 | else 137 | red "未找到可用的 NAT64 服务器" 138 | fi 139 | 140 | exit 0 -------------------------------------------------------------------------------- /repair_scripts/network.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #by spiritlhl 3 | #from https://github.com/spiritLHLS/one-click-installation-script 4 | #version: 2023.01.05 5 | 6 | utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8") 7 | if [[ -z "$utf8_locale" ]]; then 8 | echo "No UTF-8 locale found" 9 | else 10 | export LC_ALL="$utf8_locale" 11 | export LANG="$utf8_locale" 12 | export LANGUAGE="$utf8_locale" 13 | echo "Locale set to $utf8_locale" 14 | fi 15 | 16 | red() { echo -e "\033[31m\033[01m$1$2\033[0m"; } 17 | green() { echo -e "\033[32m\033[01m$1$2\033[0m"; } 18 | yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; } 19 | reading() { read -rp "$(green "$1")" "$2"; } 20 | 21 | head() { 22 | # 支持系统:Ubuntu 18+,Debian 8+,centos 7+,Fedora,Almalinux 8.5+ 23 | ver="2023.01.05" 24 | changeLog="一键修复linux网络脚本" 25 | clear 26 | echo "#######################################################################" 27 | echo "# ${YELLOW}一键修复linux网络脚本${PLAIN} #" 28 | echo "# 版本:$ver #" 29 | echo "# 更新日志:$changeLog #" 30 | echo "# ${GREEN}作者${PLAIN}: spiritlhl #" 31 | echo "# ${GREEN}仓库${PLAIN}: https://github.com/spiritLHLS/one-click-installation-script #" 32 | echo "#######################################################################" 33 | echo "支持系统:Ubuntu 18+,Debian 8+,centos 7+,Fedora,Almalinux 8.5+" 34 | echo "1.检测ping谷歌和GitHub如果有问题修改nameserver为google源或cloudflare源" 35 | echo "2.检测ping谷歌和Github还有问题尝试修复为IP类型对应的网络优先级(默认IPV4类型,纯V6类型再替换为IPV6类型)" 36 | # Display prompt asking whether to proceed with checking and changing 37 | reading "Do you want to proceed with checking and changing nameserver? [y/n] " confirm 38 | echo "" 39 | 40 | # Check user's input and exit if they do not want to proceed 41 | if [ "$confirm" != "y" ]; then 42 | exit 0 43 | fi 44 | } 45 | 46 | main() { 47 | external_ip=$(host myip.opendns.com resolver1.opendns.com | grep "myip.opendns.com has" | awk '{print $4}') 48 | # 判断 IP 类型并执行对应的函数 49 | if [[ $external_ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then 50 | main_v4 51 | elif [[ $external_ip =~ ^[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}$ ]]; then 52 | main_v6 53 | else 54 | echo "无法识别外网 IP 地址类型" 55 | fi 56 | } 57 | 58 | main_v4() { 59 | # Check if /etc/resolv.conf and /etc/gai.conf exist before backing them up 60 | if [ -f /etc/resolv.conf ]; then 61 | cp /etc/resolv.conf /etc/resolv.conf.bak 62 | fi 63 | if [ -f /etc/gai.conf ]; then 64 | cp /etc/gai.conf /etc/gai.conf.bak 65 | fi 66 | 67 | # Check if ping to google.com is successful 68 | if ping -c 1 google.com; then 69 | return 70 | fi 71 | 72 | # Try using Google's nameserver 73 | echo "nameserver 8.8.8.8" >/etc/resolv.conf 74 | if ping -c 1 google.com; then 75 | return 76 | fi 77 | 78 | # Try using Cloudflare's nameserver 79 | echo "nameserver 1.1.1.1" >/etc/resolv.conf 80 | if ping -c 1 google.com; then 81 | return 82 | fi 83 | 84 | # Display prompt asking whether to proceed with checking and changing priority 85 | reading "Do you want to proceed with checking and changing network priority? [y/n] " priority 86 | echo "" 87 | 88 | # Check user's input and exit if they do not want to proceed 89 | if [ "$priority" != "y" ]; then 90 | exit 0 91 | fi 92 | 93 | # Check IP type and network priority 94 | ip_type=$(curl -s ip.sb | grep -oP '(?<=is )(.+)(?=\.)') 95 | if [ -z "$ip_type" ]; then 96 | echo "Error: curl request failed" 97 | exit 1 98 | fi 99 | 100 | if [ "$ip_type" = "IPv4" ]; then 101 | priority=$(grep precedence /etc/gai.conf | grep -oP '(?<=precedence ::ffff:0:0\/96 )\d+') 102 | else 103 | priority=$(grep precedence /etc/gai.conf | grep -oP '(?<=precedence ::/0 )\d+') 104 | fi 105 | 106 | # Modify network priority if necessary 107 | if [ "$ip_type" = "IPv4" ] && [ "$priority" -gt "100" ]; then 108 | echo "precedence ::ffff:0:0/96 50" >/etc/gai.conf 109 | elif [ "$ip_type" = "IPv6" ] && [ "$priority" -lt "100" ]; then 110 | echo "precedence ::/0 100" >/etc/gai.conf 111 | fi 112 | 113 | # Check if ping to google.com is successful after modifying network priority 114 | if ping -c 1 google.com; then 115 | green "Ping successful after modifying network priority" 116 | return 117 | else 118 | # Restore original configuration if ping fails after modifying network priority 119 | mv /etc/resolv.conf.bak /etc/resolv.conf 120 | mv /etc/gai.conf.bak /etc/gai.conf 121 | echo "Error: Network problem is not related to nameserver or network priority. Original configuration restored." 122 | exit 1 123 | fi 124 | } 125 | 126 | main_v6() { 127 | # 定义 nameserver 列表 128 | nameservers=( 129 | "2001:67c:2960:5353:5353:5353:5353:5353" 130 | "2001:67c:2960:6464:6464:6464:6464:6464" 131 | "2602:fc23:18::7" 132 | "2001:67c:27e4::60" 133 | "2001:67c:27e4:15::64" 134 | "2001:67c:27e4::64" 135 | "2001:67c:27e4:15::6411" 136 | "2a01:4f9:c010:3f02::1" 137 | "2a00:1098:2c::1" 138 | "2a00:1098:2b::1" 139 | "2a01:4f8:c2c:123f::1" 140 | "2001:67c:2960::64" 141 | "2001:67c:2960::6464" 142 | "2001:67c:2960::64" 143 | "2001:67c:2960::6464" 144 | "2001:67c:2b0::6" 145 | "2001:67c:2b0::4" 146 | "2a03:7900:2:0:31:3:104:161" 147 | ) 148 | 149 | # 保存当前 nameserver 的值,以便之后恢复 150 | current_nameserver=$(cat /etc/resolv.conf | grep "nameserver" | awk '{print $2}') 151 | 152 | # 循环尝试替换 nameserver 并测试网络 153 | for nameserver in "${nameservers[@]}"; do 154 | # 替换 nameserver 155 | echo "nameserver $nameserver" >/etc/resolv.conf 156 | 157 | # 让修改生效 158 | resolvconf -u 159 | 160 | # ping 测试 161 | if ping -c 3 google.com &>/dev/null && ping -c 3 github.com &>/dev/null; then 162 | green "网络恢复成功" 163 | return 164 | fi 165 | done 166 | 167 | # 如果所有 nameserver 都尝试过了仍然无法修复,则恢复为原来的 nameserver 168 | echo "nameserver $current_nameserver" >/etc/resolv.conf 169 | resolvconf -u 170 | } 171 | 172 | head 173 | main 174 | # ping 测试 175 | if ping -c 3 google.com &>/dev/null && ping -c 3 github.com &>/dev/null; then 176 | green "V4网络恢复成功" 177 | fi 178 | -------------------------------------------------------------------------------- /repair_scripts/package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #by spiritlhl 3 | #from https://github.com/spiritLHLS/one-click-installation-script 4 | #version: 2023.07.30 5 | 6 | utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8") 7 | if [[ -z "$utf8_locale" ]]; then 8 | echo "No UTF-8 locale found" 9 | else 10 | export LC_ALL="$utf8_locale" 11 | export LANG="$utf8_locale" 12 | export LANGUAGE="$utf8_locale" 13 | echo "Locale set to $utf8_locale" 14 | fi 15 | temp_file_apt_fix="/tmp/apt_fix.txt" 16 | red() { echo -e "\033[31m\033[01m$1$2\033[0m"; } 17 | green() { echo -e "\033[32m\033[01m$1$2\033[0m"; } 18 | yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; } 19 | reading() { read -rp "$(green "$1")" "$2"; } 20 | 21 | head() { 22 | # 支持系统:Ubuntu 12+,Debian 6+ 23 | ver="2023.05.31" 24 | changeLog="一键修复apt源,加载对应的源" 25 | clear 26 | echo "#######################################################################" 27 | echo "# ${YELLOW}一键修复apt源脚本${PLAIN} #" 28 | echo "# 版本:$ver #" 29 | echo "# 更新日志:$changeLog #" 30 | echo "# ${GREEN}作者${PLAIN}: spiritlhl #" 31 | echo "# ${GREEN}仓库${PLAIN}: https://github.com/spiritLHLS/one-click-installation-script #" 32 | echo "#######################################################################" 33 | echo "支持系统:Ubuntu 12+,Debian 6+" 34 | echo "0.修复apt源broken损坏" 35 | echo "1.修复apt源锁死" 36 | echo "2.修复apt源公钥缺失" 37 | echo "3.修复替换系统可用的apt源列表,国内用阿里源,国外用官方源" 38 | echo "4.修复本机的Ubuntu系统是EOL非长期维护的版本,将替换为Ubuntu官方的old-releases仓库以支持apt的使用" 39 | echo "5.修复只保证apt update不会报错,其他命令报错未修复" 40 | echo "6.如若修复后install还有问题,重启服务器解决问题" 41 | # Display prompt asking whether to proceed with checking 42 | reading "Do you want to proceed with checking? [y/n] " confirm 43 | echo "" 44 | 45 | # Check user's input and exit if they do not want to proceed 46 | if [ "$confirm" != "y" ]; then 47 | exit 0 48 | fi 49 | } 50 | 51 | backup_source() { 52 | # Backup current sources list 53 | if test -f /etc/apt/sources.list.bak; then 54 | sudo cp /etc/apt/sources.list /etc/apt/sources.list2.bak 55 | yellow "backup the current /etc/apt/sources.list to /etc/apt/sources.list2.bak" 56 | else 57 | sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak 58 | yellow "backup the current /etc/apt/sources.list to /etc/apt/sources.list.bak" 59 | fi 60 | } 61 | 62 | change_debian_apt_sources() { 63 | # Check if the IP is in China 64 | ip=$(curl -s https://ipapi.co/ip) 65 | location=$(curl -s https://ipapi.co/$ip/country_name) 66 | 67 | # Backup current sources list 68 | cp /etc/apt/sources.list /etc/apt/sources.list.bak 69 | yellow "backup the current /etc/apt/sources.list to /etc/apt/sources.list.bak" 70 | 71 | # Determine Debian version 72 | DEBIAN_VERSION=$(lsb_release -sr) 73 | 74 | # Use official sources list if IP is not in China 75 | if [ "$location" != "China" ]; then 76 | URL="http://deb.debian.org/debian" 77 | else 78 | # Use mirrors.aliyun.com sources list if IP is in China 79 | URL="http://mirrors.aliyun.com/debian" 80 | fi 81 | 82 | # Set Debian release based on Debian version 83 | case $DEBIAN_VERSION in 84 | 6*) DEBIAN_RELEASE="squeeze" ;; 85 | 7*) DEBIAN_RELEASE="wheezy" ;; 86 | 8*) DEBIAN_RELEASE="jessie" ;; 87 | 9*) DEBIAN_RELEASE="stretch" ;; 88 | 10*) DEBIAN_RELEASE="buster" ;; 89 | 11*) DEBIAN_RELEASE="bullseye" ;; 90 | 12*) DEBIAN_RELEASE="bookworm" ;; 91 | *) echo "The system is not Debian 6/7/8/9/10/11/12 . No changes were made to the apt-get sources." && return 1 ;; 92 | esac 93 | 94 | # Write sources list in the desired format 95 | cat >/etc/apt/sources.list </etc/apt/sources.list </etc/apt/sources.list <&1) 226 | if echo $output | grep -q "NO_PUBKEY"; then 227 | echo "Some keys are missing, attempting to retrieve them now..." 228 | missing_keys=$(echo $output | grep "NO_PUBKEY" | awk -F' ' '{print $NF}') 229 | for key in $missing_keys; do 230 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $key 231 | done 232 | apt-get update 233 | else 234 | echo "All keys are present." 235 | fi 236 | fi 237 | } 238 | 239 | fix_sources() { 240 | # Update the package list 241 | rm -rf update_output.log 242 | apt-get update 2>&1 | tee update_output.log 243 | exit_code=$? 244 | 245 | # Check the update output for "does not have a Release file" error 246 | if grep -Eq "does not have a Release file|Malformed entry" update_output.log; then 247 | # Check if the system is Ubuntu or Debian 248 | if [ -f /etc/os-release ]; then 249 | # Get the value of the ID variable 250 | ID=$(lsb_release -i | awk '{print $3}') 251 | 252 | # If the ID is ubuntu, run the change_ubuntu_apt_sources script 253 | if [ "$ID" == "ubuntu" ]; then 254 | yellow "ubuntu" 255 | check_eol_and_switch_apt_source 256 | change_ubuntu_apt_sources 257 | fi 258 | 259 | # If the ID is debian, run the change_debian_apt_sources script 260 | if [ "$ID" == "debian" ]; then 261 | yellow "debian" 262 | change_debian_apt_sources 263 | fi 264 | fi 265 | else 266 | # If the update was successful and no errors were found, exit the script 267 | if [ $exit_code -eq 0 ]; then 268 | # Print a message indicating that the update was successful 269 | green "The apt-get update was successful." 270 | exit 0 271 | fi 272 | fi 273 | 274 | # Update the package list 275 | rm -rf update_output.log 276 | apt-get update 2>&1 | tee update_output.log 277 | exit_code=$? 278 | 279 | # Check the exit status of the update command 280 | if [ $exit_code -ne 0 ] || grep -Eq "does not have a Release file|Malformed entry" update_output.log; then 281 | # Print a message indicating that the update failed 282 | yellow "The update failed. Attempting to replace the apt-get sources..." 283 | 284 | # Check if the system is Debian or Ubuntu 285 | if [ -f /etc/debian_version ]; then 286 | # Display prompt asking whether to proceed with updating 287 | reading "Do you want to proceed with updating? [y/n] " updating 288 | echo "" 289 | 290 | # Check user's input and exit if they do not want to proceed 291 | if [ "$updating" != "y" ]; then 292 | exit 0 293 | else 294 | change_debian_apt_sources 295 | fi 296 | elif [ -f /etc/lsb-release ]; then 297 | # Display prompt asking whether to proceed with updating 298 | reading "Do you want to proceed with updating? [y/n] " updating 299 | echo "" 300 | 301 | # Check user's input and exit if they do not want to proceed 302 | if [ "$updating" != "y" ]; then 303 | exit 0 304 | else 305 | check_eol_and_switch_apt_source 306 | change_ubuntu_apt_sources 307 | fi 308 | else 309 | # Print a message indicating that the system is not supported 310 | red "This system is not supported. The apt-get sources will not be modified." 311 | fi 312 | fi 313 | } 314 | 315 | fix_install() { 316 | # ps aux | grep apt 317 | sudo pkill apt 318 | 319 | if lsof /var/lib/dpkg/lock >/dev/null 2>&1; then 320 | sudo kill $(sudo lsof /var/lib/dpkg/lock | awk '{print $2}') 321 | sudo rm /var/lib/dpkg/lock 322 | fi 323 | 324 | if lsof /var/cache/apt/archives/lock >/dev/null 2>&1; then 325 | sudo kill $(sudo lsof /var/cache/apt/archives/lock | awk '{print $2}') 326 | sudo rm -rf /var/cache/apt/archives/lock 327 | fi 328 | 329 | if sudo lsof /var/lib/apt/lists/lock >/dev/null 2>&1; then 330 | sudo kill $(sudo lsof /var/lib/apt/lists/lock | awk '{print $2}') 331 | sudo rm /var/lib/apt/lists/lock 332 | fi 333 | 334 | sudo apt-get clean 335 | sudo apt-get update 336 | sudo dpkg --configure -a 337 | } 338 | 339 | check_again() { 340 | # Update the package list again to pick up the new sources 341 | apt_update_output=$(apt-get update 2>&1) 342 | echo "$apt_update_output" >"$temp_file_apt_fix" 343 | if grep -q 'NO_PUBKEY' "$temp_file_apt_fix"; then 344 | public_keys=$(grep -oE 'NO_PUBKEY [0-9A-F]+' "$temp_file_apt_fix" | awk '{ print $2 }') 345 | joined_keys=$(echo "$public_keys" | paste -sd " ") 346 | yellow "No Public Keys: ${joined_keys}" 347 | apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ${joined_keys} 348 | apt-get update 349 | fi 350 | rm "$temp_file_apt_fix" 351 | 352 | sudo apt-get update 353 | 354 | # Check the exit status of the update command 355 | if [ $? -eq 0 ]; then 356 | # Print a message indicating that the update was successful 357 | green "The apt-get update was successful." 358 | else 359 | # Print a message indicating that the update failed and suggest other error resolution methods 360 | red "The update failed. You may want to try the following error resolution methods: 361 | - Check your internet connection 362 | - Check the sources list for errors 363 | - Check for package dependencies 364 | - Check for disk space issues" 365 | fi 366 | } 367 | 368 | ############################################################################################################################################## 369 | 370 | head 371 | fix_install 372 | sleep 1 373 | fix_broken 374 | sleep 1 375 | fix_locked 376 | sleep 1 377 | fix_sources 378 | sleep 1 379 | fix_install 380 | sleep 1 381 | check_again 382 | -------------------------------------------------------------------------------- /repair_scripts/resize_journal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #by spiritlhl 3 | #from https://github.com/spiritLHLS/one-click-installation-script 4 | #version: 2023.11.24 5 | 6 | utf8_locale=$(locale -a 2>/dev/null | grep -i -m 1 -E "UTF-8|utf8") 7 | if [[ -z "$utf8_locale" ]]; then 8 | echo "No UTF-8 locale found" 9 | else 10 | export LC_ALL="$utf8_locale" 11 | export LANG="$utf8_locale" 12 | export LANGUAGE="$utf8_locale" 13 | echo "Locale set to $utf8_locale" 14 | fi 15 | 16 | red() { echo -e "\033[31m\033[01m$1$2\033[0m"; } 17 | green() { echo -e "\033[32m\033[01m$1$2\033[0m"; } 18 | yellow() { echo -e "\033[33m\033[01m$1$2\033[0m"; } 19 | reading() { read -rp "$(green "$1")" "$2"; } 20 | 21 | head() { 22 | # 支持系统:Ubuntu 12+,Debian 6+ 23 | ver="2023.05.22" 24 | changeLog="一键修改journal日志记录大小,释放系统盘空间" 25 | clear 26 | echo "#######################################################################" 27 | echo "# ${YELLOW}一键修改journal大小脚本${PLAIN} #" 28 | echo "# 版本:$ver #" 29 | echo "# 更新日志:$changeLog #" 30 | echo "# ${GREEN}作者${PLAIN}: spiritlhl #" 31 | echo "# ${GREEN}仓库${PLAIN}: https://github.com/spiritLHLS/one-click-installation-script #" 32 | echo "#######################################################################" 33 | echo "支持系统:Ubuntu 18+,Debian 8+,centos 7+,Fedora,Almalinux 8.5+" 34 | echo "1.自定义修改大小,单位为MB,一般500或者1000即可,有的系统日志默认给了5000甚至更多,不是做站啥的没必要" 35 | echo "请注意,修改journal目录大小会影响系统日志的记录,因此,在修改journal目录大小之前如果需要之前的日志,建议先备份系统日志到本地" 36 | echo "2.自定义修改设置系统日志保留日期时长,超过日期时长的日志将被清除" 37 | echo "3.默认修改日志只记录warning等级(无法自定义)" 38 | echo "4.以后日志的产生将受到日志文件大小,日志保留时间,日志保留等级的限制" 39 | # Display prompt asking whether to proceed with changing 40 | reading "Do you want to proceed with changing? [y/n] " confirm 41 | echo "" 42 | 43 | # Check user's input and exit if they do not want to proceed 44 | if [ "$confirm" != "y" ]; then 45 | exit 0 46 | fi 47 | reading "Enter the desired day of the journal retention days (eg: 7): " retention_days 48 | reading "Enter the desired size of the journal directory in MB (eg: 500): " size 49 | } 50 | 51 | main() { 52 | # Set default value for size 53 | size="$size"M 54 | 55 | temp_file=$(mktemp) 56 | backup_file="/etc/systemd/journald.conf-$(date +%Y%m%d%H%M%S).bak" 57 | sudo cp /etc/systemd/journald.conf "$backup_file" 58 | yellow "Backed up /etc/systemd/journald.conf to $backup_file" 59 | awk -v size="$size" '{ if ($1 == "SystemMaxUse=") { print "SystemMaxUse=" size } else { print $0 } }' /etc/systemd/journald.conf >"$temp_file" 60 | sudo cp "$temp_file" /etc/systemd/journald.conf 61 | rm -rf "$temp_file" 62 | conf_file="/etc/systemd/journald.conf" 63 | variable1="SystemMaxFileSize" 64 | variable2="ForwardToSyslog" 65 | new_value1="128M" 66 | new_value2="no" 67 | if [[ ! -f "$conf_file" ]]; then 68 | exit 1 69 | fi 70 | if grep -q "^$variable1=" "$conf_file"; then 71 | sed -i "s/^$variable1=.*/$variable1=$new_value1/" "$conf_file" 72 | else 73 | echo "$variable1=$new_value1" >>"$conf_file" 74 | fi 75 | if grep -q "^$variable2=" "$conf_file"; then 76 | sed -i "s/^$variable2=.*/$variable2=$new_value2/" "$conf_file" 77 | else 78 | echo "$variable2=$new_value2" >>"$conf_file" 79 | fi 80 | systemctl restart systemd-journald 81 | 82 | green "change /etc/systemd/journald.conf successfully" 83 | } 84 | 85 | level() { 86 | # Set default values for variables 87 | log_level=warning 88 | journald_log_dir="/var/log/journal" 89 | 90 | # Check if log directory exists 91 | if [ ! -d "$journald_log_dir" ]; then 92 | yellow "Log directory not found, so no delete" >&2 93 | else 94 | # Set log retention period 95 | # find "$journald_log_dir" -mtime +$retention_days -exec rm {} \; 96 | rm -rf "$journald_log_dir"/* 97 | green "change $journald_log_dir successfully" 98 | fi 99 | 100 | # Check if config file exists 101 | if [ ! -f /etc/rsyslog.conf ]; then 102 | red "Config file (/etc/rsyslog.conf) not found, so not modify" >&2 103 | else 104 | # Set log level 105 | temp_file=$(mktemp) 106 | backup_file="/etc/rsyslog.conf-$(date +%Y%m%d%H%M%S).bak" 107 | sudo cp /etc/rsyslog.conf "$backup_file" 108 | yellow "Backed up /etc/rsyslog.conf to $backup_file" 109 | if grep -q "loglevel" /etc/rsyslog.conf; then 110 | awk -v log_level="$log_level" '{ if ($1 == "loglevel") { print "loglevel = " log_level } else { print $0 } }' /etc/rsyslog.conf >"$temp_file" 111 | else 112 | cat /etc/rsyslog.conf >"$temp_file" 113 | echo "loglevel = $log_level" >>"$temp_file" 114 | fi 115 | sudo cp "$temp_file" /etc/rsyslog.conf 116 | rm "$temp_file" 117 | green "change /etc/rsyslog.conf successfully" 118 | fi 119 | 120 | } 121 | 122 | check_again() { 123 | # Loop for 5 seconds, printing journald disk usage every second 124 | count=0 125 | while [ $count -lt 5 ]; do 126 | journalctl --disk-usage 127 | count=$((count + 1)) 128 | sleep 1 129 | done 130 | 131 | } 132 | 133 | head 134 | main 135 | level 136 | check_again 137 | -------------------------------------------------------------------------------- /repair_scripts/unlimit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #by spiritlhl 3 | #from https://github.com/spiritLHLS/one-click-installation-script 4 | #version: 2024.06.20 5 | 6 | # 更新 /etc/security/limits.conf 文件 7 | echo "更新 /etc/security/limits.conf 文件..." 8 | sed -i '/^root soft nofile /d' /etc/security/limits.conf 9 | sed -i '/^root hard nofile /d' /etc/security/limits.conf 10 | sed -i '/^\* soft nofile /d' /etc/security/limits.conf 11 | sed -i '/^\* hard nofile /d' /etc/security/limits.conf 12 | echo "root soft nofile 1000000" >> /etc/security/limits.conf 13 | echo "root hard nofile 1000000" >> /etc/security/limits.conf 14 | echo "* soft nofile 1000000" >> /etc/security/limits.conf 15 | echo "* hard nofile 1000000" >> /etc/security/limits.conf 16 | 17 | # 更新 /etc/pam.d/common-session 文件 18 | echo "更新 /etc/pam.d/common-session 文件..." 19 | if ! grep -q "session required pam_limits.so" /etc/pam.d/common-session; then 20 | echo "session required pam_limits.so" >> /etc/pam.d/common-session 21 | fi 22 | 23 | # 更新 /etc/pam.d/common-session-noninteractive 文件 24 | echo "更新 /etc/pam.d/common-session-noninteractive 文件..." 25 | if ! grep -q "session required pam_limits.so" /etc/pam.d/common-session-noninteractive; then 26 | echo "session required pam_limits.so" >> /etc/pam.d/common-session-noninteractive 27 | fi 28 | 29 | # 更新 /etc/systemd/system.conf 文件 30 | echo "更新 /etc/systemd/system.conf 文件..." 31 | sed -i '/^DefaultLimitNOFILE=/d' /etc/systemd/system.conf 32 | echo "DefaultLimitNOFILE=1000000" >> /etc/systemd/system.conf 33 | 34 | # 更新 /etc/systemd/user.conf 文件 35 | echo "更新 /etc/systemd/user.conf 文件..." 36 | sed -i '/^DefaultLimitNOFILE=/d' /etc/systemd/user.conf 37 | echo "DefaultLimitNOFILE=1000000" >> /etc/systemd/user.conf 38 | 39 | sleep 1 40 | 41 | systemctl daemon-reload 42 | echo "请重启服务器使得修改生效" 43 | --------------------------------------------------------------------------------