跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
最近更改
随机页面
分类入口
MediaWiki帮助
教程大纲
安装教程
配置教程
使用教程
知识库
出站链接
UbuntuStudioCN
搜索
搜索
中文(中国大陆)
外观
创建账号
登录
个人工具
创建账号
登录
查看“︁Ubuntu/quick-setup.sh”︁的源代码
页面
讨论
大陆简体
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
特殊页面
页面信息
外观
移至侧栏
隐藏
←
Ubuntu/quick-setup.sh
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
#!/bin/bash echo "--- Initial Setup Script ---" # 1. Read OS_VERSION from /etc/os-release if [ -f "/etc/os-release" ]; then source /etc/os-release if [ -n "$UBUNTU_CODENAME" ]; then OS_VERSION="$UBUNTU_CODENAME" echo "Detected Ubuntu codename: $OS_VERSION" else echo "Error: UBUNTU_CODENAME not found in /etc/os-release. Cannot determine OS version." exit 1 fi else echo "Error: /etc/os-release not found. Cannot determine OS version." exit 1 fi # 2. Create /etc/apt/apt.conf.d/99proxy echo "Creating /etc/apt/apt.conf.d/99proxy with proxy settings..." sudo bash -c 'cat <<EOF > /etc/apt/apt.conf.d/99proxy // Acquire::http::proxy "http://proxy.company.com:80/"; // Acquire::https::proxy "https://proxy.company.com:80/"; EOF' echo "Proxy configuration created. Lines are commented out by default." # 3. Backup existing sources.list and sources.list.d echo "Backing up existing /etc/apt/sources.list and /etc/apt/sources.list.d/*..." if [ -f "/etc/apt/sources.list" ]; then sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak echo "Backed up /etc/apt/sources.list to /etc/apt/sources.list.bak" fi if [ -d "/etc/apt/sources.list.d" ]; then for f in /etc/apt/sources.list.d/*; do if [ -f "$f" ]; then sudo mv "$f" "${f}.bak" echo "Backed up $f to ${f}.bak" fi done fi echo "Existing APT source configurations backed up." # 4. Create /etc/apt/sources.list.d/tuna.sources echo "Creating /etc/apt/sources.list.d/tuna.sources with Tsinghua TUNA mirror for $OS_VERSION..." sudo bash -c "cat <<EOF > /etc/apt/sources.list.d/tuna.sources Types: deb URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu Suites: ${OS_VERSION} ${OS_VERSION}-updates ${OS_VERSION}-backports Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 # Types: deb-src # URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu # Suites: ${OS_VERSION} ${OS_VERSION}-updates ${OS_VERSION}-backports # Components: main restricted universe multiverse # Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg # 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换 Types: deb URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu Suites: ${OS_VERSION}-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg # Types: deb-src # URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu # Suites: ${OS_VERSION}-security # Components: main restricted universe multiverse # Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg # 预发布软件源,不建议启用 # Types: deb # URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu # Suites: ${OS_VERSION}-proposed # Components: main restricted universe multiverse # Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg # # Types: deb-src # # URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu # # Suites: ${OS_VERSION}-proposed # # Components: main restricted universe multiverse # # Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg EOF" echo "Tsinghua TUNA mirror configuration added to /etc/apt/sources.list.d/tuna.sources" echo "--- Setup complete. It is recommended to run 'sudo apt update' now. ---"
返回
Ubuntu/quick-setup.sh
。