├── .github └── workflows │ ├── tagged-release.yml │ └── upload.yml ├── .gitignore ├── .gitpod.yml ├── README.md ├── centos-stream ├── default-AppStream.repo ├── default-BaseOS.repo └── stream-8-Extras.repo ├── centos ├── default-AppStream.repo ├── default-BaseOS.repo └── default-CentOS-Stream-Extras.repo ├── debian ├── bullseye ├── buster ├── default ├── docker └── stretch ├── doc ├── Centos.8.release ├── Centos.9.release └── Ubuntu.focal.release ├── docker.destination ├── host.mirrors ├── icons ├── centos.png ├── debian.png └── ubuntu.png ├── install.sh ├── maven ├── 163.xml ├── aliyun.xml └── tencent.xml ├── old.sh ├── pip.conf ├── system.destination ├── tiny-shell.sh ├── ubuntu ├── default └── docker └── upload.sh /.github/workflows/tagged-release.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | # Sequence of patterns matched against refs/tags 4 | tags: 5 | - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 6 | 7 | name: Create Release 8 | 9 | jobs: 10 | build: 11 | name: Upload Release Asset 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout code 15 | uses: actions/checkout@v2 16 | - name: Build project 17 | run: | 18 | tar --exclude-ignore=tar.exclude -cf tiny-shell.tar . 19 | - name: Create Release 20 | id: create_release 21 | uses: actions/create-release@v1 22 | env: 23 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 24 | with: 25 | tag_name: ${{ github.ref }} 26 | release_name: Release ${{ github.ref }} 27 | draft: false 28 | prerelease: false 29 | - name: Upload Release Asset 30 | id: upload-release-asset 31 | uses: actions/upload-release-asset@v1 32 | env: 33 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 34 | with: 35 | upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps 36 | asset_path: ./tiny-shell.tar 37 | asset_name: tiny-shell.tar 38 | asset_content_type: application/tar 39 | -------------------------------------------------------------------------------- /.github/workflows/upload.yml: -------------------------------------------------------------------------------- 1 | name: upload 2 | on: 3 | push: 4 | branches: [master] 5 | jobs: 6 | upload-to-qiniu: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - name: Checkout code 10 | uses: actions/checkout@v2 11 | - name: Install Qshell 12 | env: 13 | QI_NIU_AK: ${{secrets.QI_NIU_AK}} 14 | QI_NIU_SK: ${{secrets.QI_NIU_SK}} 15 | run: | 16 | wget https://github.com/qiniu/qshell/releases/download/v2.9.2/qshell-v2.9.2-linux-amd64.tar.gz && \ 17 | tar -xf qshell-v2.9.2-linux-amd64.tar.gz && \ 18 | chmod +x qshell && \ 19 | mv qshell /usr/local/bin/ && \ 20 | rm qshell-v2.9.2-linux-amd64.tar.gz && \ 21 | qshell account ${QI_NIU_AK} ${QI_NIU_SK} github 22 | - name: Upload 23 | run: | 24 | chmod +x upload.sh && ./upload.sh 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.backup 3 | .tiny-shell/ 4 | .tiny-shell.log 5 | test.sh -------------------------------------------------------------------------------- /.gitpod.yml: -------------------------------------------------------------------------------- 1 | tasks: 2 | - init: | 3 | echo 'TODO: build project' 4 | command: | 5 | echo 'TODO: start app' -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Tiny-Shell 2 | 3 | 4 | 5 | > 帮助你解决镜像加速问题,如果有帮助到你,不妨点一个Star :star: 吧~~ 6 | 7 | 8 | 9 | ### :triangular_flag_on_post: 支持的操作系统 10 | 11 | ![](./icons/debian.png)![](./icons/ubuntu.png)![](./icons/centos.png) 12 | 13 | 14 | 15 | ### tiny-shell 功能概览 16 | 17 | 18 | 19 | - 快速切换、配置系统镜像源 20 | 21 | - 配置Docker镜像源,快速安装Docker环境 22 | 23 | - 快速配置PiP国内加速 24 | 25 | - 快速配置Maven国内加速 26 | 27 | 28 | 29 | ### :zap: 快速开始 30 | 31 | 32 | 33 | ```bash 34 | 35 | curl -s https://tiny-shell.chaobei.xyz/install.sh | bash 36 | 37 | ``` 38 | 39 | 40 | 41 | ### :globe_with_meridians: 涵盖的镜像站 42 | 43 | 支持快速换源的镜像站如下: 44 | 45 | 1. [阿里云镜像站](https://mirrors.aliyun.com) 46 | 47 | 2. [网易开源镜像站](https://mirrors.163.com) 48 | 49 | 3. [中国科学技术大学开源软件镜像](https://mirrors.ustc.edu.cn) 50 | 51 | 4. [清华大学开源软件镜像站](https://mirrors.tuna.tsinghua.edu.cn) 52 | 53 | 5. [南京大学开源镜像站](https://mirror.nju.edu.cn) 54 | 55 | 6. [上海交通大学开源镜像站](https://mirror.sjtu.edu.cn) 56 | 57 | 7. [兰州大学开源镜像站](https://mirror.lzu.edu.cn) 58 | 59 | 8. ... 60 | 61 | 62 | 63 | ### :test_tube: 测试结果 64 | 65 | 66 | 67 | | :strawberry: 系统| :package: 版本 | :hammer: 支持 | 68 | |--|--|--| 69 | | Ubuntu | 22.04 TLS (jammy) | :white_check_mark: | 70 | | Ubuntu | 20.04 TLS (focal) | :white_check_mark: | 71 | | Ubuntu | 18.04 TLS (bionic) | :white_check_mark: | 72 | | Debian | 12 (bookworm) | :white_check_mark: | 73 | | Debian | 11 (bullseye) | :white_check_mark: | 74 | | Debian | 10 (buster) | :white_check_mark: | 75 | 76 | 77 | ### :hourglass_flowing_sand: Update Logs 78 | 79 | 80 | 81 | - 22-08-22 支持Centos-Stream-8/9 82 | 83 | - 22-08-06 发布`v1.0` 84 | 85 | - 22-08-04 按配置文件动态更新源 86 | 87 | - 添加默认源地址 88 | 89 | - 处理程序错误 90 | 91 | - 22-08-02 添加Docker安装脚本 92 | 93 | - 22-07-31 添加Debian更新源 94 | 95 | 96 | 97 | ### :grey_question: Issues 98 | 99 | 100 | 101 | 如果没有你想要的镜像站,请提`ISSUE` 或者`PR` 进行添加. 102 | 103 | 104 | 105 | ### :link: References 106 | 107 | 108 | 109 | [Maven Setting](https://maven.apache.org/settings.html) 110 | 111 | 112 | 113 | [Install Docker Engine on Debian | Docker Documentation](https://docs.docker.com/engine/install/debian/) 114 | 115 | 116 | 117 | [DebianRepository/UseThirdParty - Debian Wiki](https://wiki.debian.org/DebianRepository/UseThirdParty) 118 | 119 | 120 | 121 | [https://mirrors.ustc.edu.cn/repogen/](https://mirrors.ustc.edu.cn/repogen/) 122 | 123 | 124 | 125 | [mirror](https://www.debian.org/mirror/sponsors.zh-cn.html) 126 | 127 | 128 | 129 | [Debian -- Debian 发行版本](https://www.debian.org/releases/) 130 | 131 | 132 | 133 | [Releases - Ubuntu Wiki](https://wiki.ubuntu.com/Releases) 134 | 135 | 136 | 137 | ### :partying_face: Icons 138 | 139 | 140 | 141 | [Ubuntu icon](https://www.shareicon.net/ubuntu-194940) 142 | 143 | 144 | 145 | [Debian icon](https://www.shareicon.net/debian-101872) 146 | 147 | 148 | 149 | https://seeklogo.com/vector-logo/272958/centos -------------------------------------------------------------------------------- /centos-stream/default-AppStream.repo: -------------------------------------------------------------------------------- 1 | [appstream] 2 | name=host $releasever - AppStream 3 | baseurl=http://host/$contentdir/$stream/AppStream/$basearch/os/ 4 | gpgcheck=1 5 | enabled=1 6 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial -------------------------------------------------------------------------------- /centos-stream/default-BaseOS.repo: -------------------------------------------------------------------------------- 1 | [baseos] 2 | name=host $releasever - BaseOS 3 | baseurl=http://host/$contentdir/$stream/BaseOS/$basearch/os/ 4 | gpgcheck=1 5 | enabled=1 6 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial -------------------------------------------------------------------------------- /centos-stream/stream-8-Extras.repo: -------------------------------------------------------------------------------- 1 | [extras] 2 | name=host $releasever - Extras 3 | baseurl=http://host/$contentdir/$stream/extras/$basearch/os/ 4 | gpgcheck=1 5 | enabled=1 6 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial -------------------------------------------------------------------------------- /centos/default-AppStream.repo: -------------------------------------------------------------------------------- 1 | [appstream] 2 | name=host $releasever - AppStream 3 | baseurl=http://host/$contentdir/$releasever/AppStream/$basearch/os/ 4 | gpgcheck=1 5 | enabled=1 6 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial -------------------------------------------------------------------------------- /centos/default-BaseOS.repo: -------------------------------------------------------------------------------- 1 | [baseos] 2 | name=host $releasever - BaseOS 3 | baseurl=http://host/$contentdir/$releasever/BaseOS/$basearch/os/ 4 | gpgcheck=1 5 | enabled=1 6 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial -------------------------------------------------------------------------------- /centos/default-CentOS-Stream-Extras.repo: -------------------------------------------------------------------------------- 1 | [extras] 2 | name=host $releasever - Extras 3 | baseurl=http://host/$contentdir/$releasever/extras/$basearch/os/ 4 | gpgcheck=1 5 | enabled=1 6 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial -------------------------------------------------------------------------------- /debian/bullseye: -------------------------------------------------------------------------------- 1 | deb https://host/debian/ bullseye main contrib non-free 2 | #deb-src https://host/debian/ bullseye main contrib non-free 3 | 4 | deb https://host/debian/ bullseye-updates main contrib non-free 5 | #deb-src https://host/debian/ bullseye-updates main contrib non-free 6 | 7 | deb https://host/debian/ bullseye-backports main contrib non-free 8 | #deb-src https://host/debian/ bullseye-backports main contrib non-free 9 | 10 | deb https://host/debian-security/ bullseye-security main contrib non-free 11 | #deb-src https://host/debian-security/ bullseye-security main contrib non-free -------------------------------------------------------------------------------- /debian/buster: -------------------------------------------------------------------------------- 1 | deb https://host/debian/ buster main contrib non-free 2 | #deb-src https://host/debian/ buster main contrib non-free 3 | 4 | deb https://host/debian/ buster-updates main contrib non-free 5 | #deb-src https://host/debian/ buster-updates main contrib non-free 6 | 7 | deb https://host/debian/ buster-backports main contrib non-free 8 | #deb-src https://host/debian/ buster-backports main contrib non-free 9 | 10 | deb https://host/debian-security/ buster/updates main contrib non-free 11 | #deb-src https://host/debian-security/ buster/updates main contrib non-free -------------------------------------------------------------------------------- /debian/default: -------------------------------------------------------------------------------- 1 | deb https://host/debian/ version main contrib non-free 2 | #deb-src https://host/debian/ version main contrib non-free 3 | 4 | deb https://host/debian/ version-updates main contrib non-free 5 | #deb-src https://host/debian/ version-updates main contrib non-free 6 | 7 | deb https://host/debian/ version-backports main contrib non-free 8 | #deb-src https://host/debian/ version-backports main contrib non-free 9 | 10 | deb https://host/debian-security/ version-security main contrib non-free 11 | #deb-src https://host/debian-security/ version-security main contrib non-free -------------------------------------------------------------------------------- /debian/docker: -------------------------------------------------------------------------------- 1 | deb [signed-by=/etc/apt/keyrings/gpg] https://host/docker-ce/linux/debian version stable 2 | -------------------------------------------------------------------------------- /debian/stretch: -------------------------------------------------------------------------------- 1 | deb http://host/debian/ stretch main contrib non-free 2 | #deb-src http://host/debian/ stretch main contrib non-free 3 | 4 | deb http://host/debian/ stretch-updates main contrib non-free 5 | #deb-src http://host/debian/ stretch-updates main contrib non-free 6 | 7 | deb http://host/debian/ stretch-backports main contrib non-free 8 | #deb-src http://host/debian/ stretch-backports main contrib non-free 9 | 10 | deb http://host/debian-security/ stretch/updates main contrib non-free 11 | #deb-src http://host/debian-security/ stretch/updates main contrib non-free -------------------------------------------------------------------------------- /doc/Centos.8.release: -------------------------------------------------------------------------------- 1 | NAME="CentOS Stream" 2 | VERSION="8" 3 | ID="centos" 4 | ID_LIKE="rhel fedora" 5 | VERSION_ID="8" 6 | PLATFORM_ID="platform:el8" 7 | PRETTY_NAME="CentOS Stream 8" 8 | ANSI_COLOR="0;31" 9 | CPE_NAME="cpe:/o:centos:centos:8" 10 | HOME_URL="https://centos.org/" 11 | BUG_REPORT_URL="https://bugzilla.redhat.com/" 12 | REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 8" 13 | REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream" -------------------------------------------------------------------------------- /doc/Centos.9.release: -------------------------------------------------------------------------------- 1 | NAME="CentOS Stream" 2 | VERSION="9" 3 | ID="centos" 4 | ID_LIKE="rhel fedora" 5 | VERSION_ID="9" 6 | PLATFORM_ID="platform:el9" 7 | PRETTY_NAME="CentOS Stream 9" 8 | ANSI_COLOR="0;31" 9 | LOGO="fedora-logo-icon" 10 | CPE_NAME="cpe:/o:centos:centos:9" 11 | HOME_URL="https://centos.org/" 12 | BUG_REPORT_URL="https://bugzilla.redhat.com/" 13 | REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 9" 14 | REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream" -------------------------------------------------------------------------------- /doc/Ubuntu.focal.release: -------------------------------------------------------------------------------- 1 | NAME="Ubuntu" 2 | VERSION="20.04.4 LTS (Focal Fossa)" 3 | ID=ubuntu 4 | ID_LIKE=debian 5 | PRETTY_NAME="Ubuntu 20.04.4 LTS" 6 | VERSION_ID="20.04" 7 | HOME_URL="https://www.ubuntu.com/" 8 | SUPPORT_URL="https://help.ubuntu.com/" 9 | BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" 10 | PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" 11 | VERSION_CODENAME=focal 12 | UBUNTU_CODENAME=focal -------------------------------------------------------------------------------- /docker.destination: -------------------------------------------------------------------------------- 1 | #系统 #源文件 #目标文件 2 | ubuntu-default|docker|/etc/apt/sources.list.d/docker.list 3 | debian-default|docker|/etc/apt/sources.list.d/docker.list -------------------------------------------------------------------------------- /host.mirrors: -------------------------------------------------------------------------------- 1 | tencent|mirrors.cloud.tencent.com|腾讯软件源|https://mirrors.cloud.tencent.com|ubuntu,debian,centos,maven,pypi 2 | tsinghua|mirrors.tuna.tsinghua.edu.cn|清华大学开源软件镜像站|https://mirrors.tuna.tsinghua.edu.cn|ubuntu,debian,docker,centos-stream 3 | ustc|mirrors.ustc.edu.cn|中国科学技术大学开源软件镜像|https://mirrors.ustc.edu.cn|ubuntu,debian,docker,centos-stream 4 | 163|mirrors.163.com|网易开源镜像站|https://mirrors.163.com|ubuntu,debian,centos,docker,maven,pypi 5 | aliyun|mirrors.aliyun.com|阿里云镜像站|https://mirrors.aliyun.com|ubuntu,debian,docker,centos,centos-stream,maven,pypi 6 | nju|mirror.nju.edu.cn|南京大学开源镜像站|https://mirror.nju.edu.cn|ubuntu,debian 7 | sjtu|mirror.sjtu.edu.cn|上海交通大学开源镜像站|https://mirror.sjtu.edu.cn|ubuntu,debian,docker 8 | lzu|mirror.lzu.edu.cn|兰州大学开源镜像站|https://mirror.lzu.edu.cn|ubuntu,debian -------------------------------------------------------------------------------- /icons/centos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marchocode/tiny-shell/7223de4807cc88f2442a2efe6ec466236916be25/icons/centos.png -------------------------------------------------------------------------------- /icons/debian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marchocode/tiny-shell/7223de4807cc88f2442a2efe6ec466236916be25/icons/debian.png -------------------------------------------------------------------------------- /icons/ubuntu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marchocode/tiny-shell/7223de4807cc88f2442a2efe6ec466236916be25/icons/ubuntu.png -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | BUCKET="https://tiny-shell.chaobei.xyz" 4 | curl -s -o tiny-shell.sh ${BUCKET}/tiny-shell.sh 5 | 6 | sed -i 's/file:${pwd}/https:\/\/tiny-shell.chaobei.xyz/g' tiny-shell.sh 7 | chmod +x tiny-shell.sh 8 | 9 | ./tiny-shell.sh -------------------------------------------------------------------------------- /maven/163.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 163 6 | 163 7 | http://mirrors.163.com/maven/repository/maven-public/ 8 | central 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /maven/aliyun.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | aliyun 6 | aliyun 7 | http://maven.aliyun.com/repository/public/ 8 | central 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /maven/tencent.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | tencent 6 | tencent 7 | http://mirrors.cloud.tencent.com/nexus/repository/maven-public 8 | central 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /old.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | red='\033[0;31m' 4 | green='\033[0;32m' 5 | yellow='\033[0;33m' 6 | plain='\033[0m' 7 | line="----------------------------------------------" 8 | backup_dir=".backup" 9 | 10 | mkdir -p ${backup_dir} 11 | 12 | # check os 13 | # check code 14 | 15 | if test -e /etc/redhat-release && grep -Eqi "stream" /etc/redhat-release; then 16 | release="centos-stream" 17 | version=$(cat /etc/os-release | grep "VERSION_ID" | grep -Eo "[0-9]") 18 | elif [[ -f /etc/redhat-release ]]; then 19 | release="centos" 20 | version=$(cat /etc/os-release | grep "VERSION_ID" | grep -Eo "[0-9]") 21 | elif cat /etc/issue | grep -Eqi "debian"; then 22 | release="debian" 23 | version=$(cat /etc/os-release | grep "VERSION_CODENAME" | cut -d '=' -f 2) 24 | elif cat /etc/issue | grep -Eqi "ubuntu"; then 25 | release="ubuntu" 26 | version=$(cat /etc/os-release | grep "VERSION_CODENAME" | cut -d '=' -f 2) 27 | elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then 28 | release="centos" 29 | version=$(cat /etc/os-release | grep "VERSION_ID" | grep -Eo "[0-9]") 30 | elif cat /proc/version | grep -Eqi "debian"; then 31 | release="debian" 32 | version=$(cat /etc/os-release | grep "VERSION_CODENAME" | cut -d '=' -f 2) 33 | elif cat /proc/version | grep -Eqi "ubuntu"; then 34 | release="ubuntu" 35 | version=$(cat /etc/os-release | grep "VERSION_CODENAME" | cut -d '=' -f 2) 36 | elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then 37 | release="centos" 38 | else 39 | echo -e "${red}未检测到系统版本,请联系脚本作者!${plain}\n" && exit 1 40 | fi 41 | 42 | # clean log 43 | cat /dev/null > .tiny-shell.log 44 | 45 | log() { 46 | echo "$1" >> .tiny-shell.log 47 | } 48 | 49 | root_check() { 50 | 51 | log "root_check user=${USER}" 52 | 53 | if [[ $USER != "root" ]] 54 | then 55 | echo -e "${red}错误:${plain} 必须使用root用户运行此脚本!\n" && exit 1 56 | fi 57 | } 58 | 59 | # 选择镜像源 60 | mirrors_check(){ 61 | 62 | log "mirrors_check param=${1}" 63 | 64 | q=$1 65 | # centos-stream-8 作为centos去搜索 66 | if [[ ${q} = "centos-stream" && ${version} = "8" ]];then 67 | q="centos" 68 | fi 69 | 70 | mirrors_list=($(cat host.mirrors | grep ${q})) 71 | mirrors_length=$(expr ${#mirrors_list[@]} - 1) 72 | 73 | for (( i=0; i<${#mirrors_list[@]}; i++ )); 74 | do 75 | host=$(echo ${mirrors_list[$i]} | cut -d "|" -f 1) 76 | name=$(echo ${mirrors_list[$i]}| cut -d "|" -f 2) 77 | 78 | echo -e "${i}. ${green}${host}${plain}(${name})" 79 | log "${i}. ${green}${host}${plain}(${name})" 80 | done 81 | 82 | echo -e "" 83 | echo -e ${line} 84 | 85 | read -p "请输入选择 [0-${mirrors_length}](默认0): " CHOISE 86 | 87 | log "user choice=${CHOISE}" 88 | 89 | if [[ -z $CHOISE ]]; then 90 | CHOISE="0" 91 | fi 92 | 93 | if [[ ! ${CHOISE} =~ ^[0-9]+$ || ${CHOISE} < 0 || ${CHOISE} > ${mirrors_length} ]]; then 94 | echo -e "${red}错误,请重试!${plain}" && exit 1 95 | fi 96 | 97 | check_host=${mirrors_list[${CHOISE}]} 98 | log "check_host=${check_host}" 99 | 100 | id=$(echo ${check_host} | cut -d "|" -f 1) 101 | host=$(echo ${check_host} | cut -d "|" -f 2) 102 | name=$(echo ${check_host} | cut -d "|" -f 3) 103 | host_url=$(echo ${check_host} | cut -d "|" -f 4) 104 | 105 | return 0 106 | } 107 | 108 | print_info(){ 109 | 110 | echo -e "" 111 | echo -e "OS - ${release}" 112 | echo -e "Version - ${version}" 113 | echo -e "Mirror - ${name}|${host_url}" 114 | echo -e "Destination - ${destination}" 115 | echo -e ${line} 116 | 117 | echo -e "" 118 | echo -e "${red}感谢您的使用,相关文件已经被替换${plain}" 119 | } 120 | 121 | system(){ 122 | clear 123 | echo -e "" 124 | echo -e "${green}tiny-shell ${plain}系统更新源快速切换" 125 | echo -e ${line} 126 | echo -e "" 127 | 128 | mirrors_check ${release} 129 | 130 | destinations=($(cat system.destination | grep "${release}-${version}")) 131 | log "system-destinations=${destinations}" 132 | 133 | if [[ ${#destinations[@]} -eq 0 ]]; then 134 | destinations=($(cat system.destination | grep "${release}-default")) 135 | log "system-destinations=${destinations}" 136 | fi 137 | 138 | backup=".sources.list.backup" 139 | 140 | 141 | for (( i=0; i<${#destinations[@]}; i++ )); 142 | do 143 | 144 | destination=$(echo ${destinations[$i]} | cut -d "|" -f 3) 145 | config="${release}/"$(echo ${destinations[$i]} | cut -d "|" -f 2) 146 | 147 | log "system-destination=${destination}" 148 | log "system-config=${config}" 149 | 150 | backup="${backup_dir}/"$(basename ${destination}) 151 | 152 | # file backup 153 | cp ${destination} ${backup} 154 | 155 | cat ${config} > .target 156 | 157 | sed -i "s/host/${host}/g" .target 158 | sed -i "s/version/${version}/g" .target 159 | 160 | cat .target > ${destination} 161 | rm .target 162 | 163 | done 164 | 165 | print_info 166 | 167 | } 168 | 169 | docker(){ 170 | clear 171 | echo -e "" 172 | echo -e "${green}tiny-shell ${plain}Docker-ce Install" 173 | echo -e ${line} 174 | echo -e "" 175 | 176 | mirrors_check docker 177 | 178 | repo_config="./${release}/docker" 179 | destination=$(cat docker.destination | grep ${release} | cut -d '|' -f 3) 180 | 181 | print_info 182 | backup=".docker.list.backup" 183 | 184 | # file backup 185 | if [[ -e ${destination} ]];then 186 | cp ${destination} ${backup} 187 | fi 188 | 189 | cat ${repo_config} > .target 190 | 191 | # download grp 192 | mkdir -p /etc/apt/keyring 193 | 194 | wget -q -O .docker.gpg "http://${host}/docker-ce/linux/${release}/gpg" 195 | gpg --dearmor -o /etc/apt/keyring/docker.gpg .docker.gpg 196 | 197 | sed -i "s/host/${host}/g" .target 198 | sed -i "s/version/${version}/g" .target 199 | 200 | cat .target > ${destination} 201 | 202 | rm .target 203 | rm .docker.gpg 204 | } 205 | 206 | 207 | maven(){ 208 | clear 209 | echo -e "" 210 | echo -e "${green}tiny-shell ${plain}Maven Setting" 211 | echo -e ${line} 212 | echo -e "" 213 | 214 | mirrors_check maven 215 | 216 | repo_config="./maven/${id}.xml" 217 | destination="${HOME}/.m2/settings.xml" 218 | 219 | print_info 220 | backup=".setting.xml" 221 | 222 | # file backup 223 | if [[ -e ${destination} ]];then 224 | cp ${destination} ${backup_dir}"/"${backup} 225 | fi 226 | 227 | mkdir -p "${HOME}/.m2" 228 | 229 | cat ${repo_config} > ${destination} 230 | } 231 | 232 | pypi(){ 233 | 234 | clear 235 | echo -e "" 236 | echo -e "${green}tiny-shell ${plain}Pip Setting" 237 | echo -e ${line} 238 | echo -e "" 239 | 240 | mirrors_check pypi 241 | 242 | repo_config="./pip.conf" 243 | destination="$HOME/.pip/pip.conf" 244 | 245 | print_info 246 | mkdir -p $(dirname ${destination}) 247 | 248 | cat ${repo_config} > .target 249 | 250 | sed -i "s/HOST/${host}/g" .target 251 | 252 | cat .target > ${destination} 253 | 254 | rm .target 255 | } 256 | 257 | 258 | menu(){ 259 | clear 260 | echo -e "" 261 | echo -e "${green}tiny-shell ${plain}" 262 | 263 | echo -e ${line} 264 | echo -e "一个帮助你节省一堆时间的shell脚本" 265 | echo -e "" 266 | echo -e "tiny-shell - 显示帮助菜单" 267 | echo -e "tiny-shell system - 切换国内系统镜像源(阿里云/网易/清华大学)众多镜像站收录" 268 | echo -e "tiny-shell docker - 快速安装docker" 269 | echo -e "tiny-shell pypi - 快速配置pip加速镜像" 270 | echo -e "tiny-shell maven - 快速配置maven加速镜像" 271 | echo -e ${line} 272 | echo -e "" 273 | } 274 | 275 | log "os: ${release}" 276 | log "version: ${version}" 277 | 278 | if [[ $# > 0 ]]; then 279 | case $1 in 280 | "system") 281 | root_check && system 282 | ;; 283 | "docker") 284 | root_check && docker 285 | ;; 286 | "pypi") 287 | pypi 288 | ;; 289 | "maven") 290 | maven 291 | ;; 292 | *) menu 293 | ;; 294 | esac 295 | else 296 | menu 297 | fi -------------------------------------------------------------------------------- /pip.conf: -------------------------------------------------------------------------------- 1 | [global] 2 | index-url = https://HOST/pypi/simple/ 3 | 4 | [install] 5 | trusted-host=HOST 6 | -------------------------------------------------------------------------------- /system.destination: -------------------------------------------------------------------------------- 1 | #系统-版本 #源文件 #目标文件 2 | centos-8|default-CentOS-Stream-Extras.repo|/etc/yum.repos.d/CentOS-Linux-Extras.repo 3 | centos-8|default-AppStream.repo|/etc/yum.repos.d/CentOS-Linux-AppStream.repo 4 | centos-8|default-BaseOS.repo|/etc/yum.repos.d/CentOS-Linux-BaseOS.repo 5 | 6 | centos-stream-8|default-AppStream.repo|/etc/yum.repos.d/CentOS-Stream-AppStream.repo 7 | centos-stream-8|default-BaseOS.repo|/etc/yum.repos.d/CentOS-Stream-BaseOS.repo 8 | centos-stream-8|stream-8-Extras.repo|/etc/yum.repos.d/CentOS-Stream-Extras.repo 9 | 10 | centos-stream-default|default-AppStream.repo|/etc/yum.repos.d/CentOS-Stream-AppStream.repo 11 | centos-stream-default|default-BaseOS.repo|/etc/yum.repos.d/CentOS-Stream-BaseOS.repo 12 | 13 | debian-default|default|/etc/apt/sources.list 14 | ubuntu-default|default|/etc/apt/sources.list 15 | -------------------------------------------------------------------------------- /tiny-shell.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | red='\033[0;31m' 4 | green='\033[0;32m' 5 | yellow='\033[0;33m' 6 | plain='\033[0m' 7 | 8 | pwd=$(pwd) 9 | BUCKET="file:${pwd}" 10 | WORKDIR=".tiny-shell" 11 | 12 | info() { 13 | date=$(date +"%Y-%m-%d %H:%M:%S") 14 | echo -e "${date} INFO ${1}" 15 | } 16 | 17 | debug(){ 18 | date=$(date +"%Y-%m-%d %H:%M:%S") 19 | echo -e "${date} DEBUG ${1}" 20 | } 21 | 22 | warn(){ 23 | date=$(date +"%Y-%m-%d %H:%M:%S") 24 | echo -e "${date} ${yellow}WARN ${1}${plain}" 25 | } 26 | 27 | error(){ 28 | date=$(date +"%Y-%m-%d %H:%M:%S") 29 | echo -e "${date} ${red}ERROR ${1}${plain}" 30 | } 31 | 32 | backup(){ 33 | 34 | backup_target="${WORKDIR}/${2}" 35 | 36 | mkdir -p ${backup_target} 37 | info "Backup file ${1} to ${backup_target}" 38 | 39 | if [[ -e ${1} ]];then 40 | cp ${1} ${backup_target} 41 | else 42 | warn "Backup ignore.." 43 | fi 44 | } 45 | 46 | 47 | root_check() { 48 | 49 | info "Check Current User = ${USER}" 50 | 51 | if [[ $USER != "root" ]] 52 | then 53 | error "The Script needs Root Permission!" && exit 1 54 | fi 55 | } 56 | 57 | # check os 58 | # check code 59 | 60 | if test -e /etc/redhat-release && grep -Eqi "stream" /etc/redhat-release; then 61 | release="centos-stream" 62 | version=$(cat /etc/os-release | grep "VERSION_ID" | grep -Eo "[0-9]") 63 | elif [[ -f /etc/redhat-release ]]; then 64 | release="centos" 65 | version=$(cat /etc/os-release | grep "VERSION_ID" | grep -Eo "[0-9]") 66 | elif cat /etc/issue | grep -Eqi "debian"; then 67 | release="debian" 68 | version=$(cat /etc/os-release | grep "VERSION_CODENAME" | cut -d '=' -f 2) 69 | architecture=$(dpkg --print-architecture) 70 | elif cat /etc/issue | grep -Eqi "ubuntu"; then 71 | release="ubuntu" 72 | version=$(cat /etc/os-release | grep "VERSION_CODENAME" | cut -d '=' -f 2) 73 | architecture=$(dpkg --print-architecture) 74 | elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then 75 | release="centos" 76 | version=$(cat /etc/os-release | grep "VERSION_ID" | grep -Eo "[0-9]") 77 | elif cat /proc/version | grep -Eqi "debian"; then 78 | release="debian" 79 | version=$(cat /etc/os-release | grep "VERSION_CODENAME" | cut -d '=' -f 2) 80 | architecture=$(dpkg --print-architecture) 81 | elif cat /proc/version | grep -Eqi "ubuntu"; then 82 | release="ubuntu" 83 | version=$(cat /etc/os-release | grep "VERSION_CODENAME" | cut -d '=' -f 2) 84 | architecture=$(dpkg --print-architecture) 85 | elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then 86 | release="centos" 87 | else 88 | error "The script does't support your system. Please commit your request! \n" && exit 1 89 | fi 90 | 91 | 92 | # init. 93 | if [[ ! -e ${WORKDIR} ]]; then 94 | 95 | info "init package." 96 | if [[ ${release} = "ubuntu" ]];then 97 | apt update > /dev/null && apt-get -y install apt-transport-https ca-certificates curl wget gnupg > /dev/null 98 | elif [[ ${release} = "debian" ]];then 99 | apt update > /dev/null && apt-get -y install ca-certificates curl wget > /dev/null 100 | else 101 | info "Nothing to do." 102 | fi 103 | 104 | fi 105 | 106 | mkdir -p ${WORKDIR} 107 | 108 | 109 | mirrors_check(){ 110 | 111 | q=$1 112 | # centos-stream-8 作为centos去搜索 113 | if [[ ${q} = "centos-stream" && ${version} = "8" ]];then 114 | q="centos" 115 | fi 116 | 117 | info "Mirrors Downloading...\n" 118 | 119 | mirrors_list=($(curl -s ${BUCKET}/host.mirrors | grep ${q})) 120 | mirrors_length=$(expr ${#mirrors_list[@]} - 1) 121 | 122 | for (( i=0; i<${#mirrors_list[@]}; i++ )); 123 | do 124 | host=$(echo ${mirrors_list[$i]} | cut -d "|" -f 1) 125 | name=$(echo ${mirrors_list[$i]}| cut -d "|" -f 2) 126 | 127 | echo -e "${i}. ${green}${host}${plain}(${name})" 128 | done 129 | 130 | echo -e "" 131 | read -p "Please Type Your Choice [0-${mirrors_length}](Default 0): " CHOISE 132 | echo -e "" 133 | 134 | if [[ -z $CHOISE ]]; then 135 | CHOISE="0" 136 | fi 137 | 138 | if [[ ! ${CHOISE} =~ ^[0-9]+$ || ${CHOISE} < 0 || ${CHOISE} > ${mirrors_length} ]]; then 139 | echo -e "${red}Number Error...${plain} Try Again!" && exit 1 140 | fi 141 | 142 | check_host=${mirrors_list[${CHOISE}]} 143 | 144 | id=$(echo ${check_host} | cut -d "|" -f 1) 145 | host=$(echo ${check_host} | cut -d "|" -f 2) 146 | name=$(echo ${check_host} | cut -d "|" -f 3) 147 | host_url=$(echo ${check_host} | cut -d "|" -f 4) 148 | 149 | info "id=${id}" 150 | info "host=${host}" 151 | 152 | return 0 153 | } 154 | 155 | print_info(){ 156 | 157 | info "" 158 | info "OS - ${release}" 159 | info "Version - ${version}" 160 | info "Mirror - ${name}|${host_url}" 161 | info "Destination - ${destination}" 162 | 163 | } 164 | 165 | 166 | system(){ 167 | 168 | clear 169 | echo -e "" 170 | echo -e "${green}Tiny-Shell ${plain} System Mirrors Check..." 171 | echo -e "" 172 | 173 | mirrors_check ${release} 174 | system_tmp="${WORKDIR}/system.destination.tmp" 175 | 176 | info "System Configuation is loading..." 177 | curl -s ${BUCKET}/system.destination > ${system_tmp} 178 | 179 | destinations=($(cat ${system_tmp} | grep "${release}-${version}")) 180 | 181 | if [[ ${#destinations[@]} -eq 0 ]]; then 182 | destinations=($(cat ${system_tmp} | grep "${release}-default")) 183 | warn "Loading Default Configuation." 184 | fi 185 | 186 | for (( i=0; i<${#destinations[@]}; i++ )); 187 | do 188 | 189 | destination=$(echo ${destinations[$i]} | cut -d "|" -f 3) 190 | config="${release}/"$(echo ${destinations[$i]} | cut -d "|" -f 2) 191 | 192 | backup ${destination} "system" 193 | 194 | info "Downloading System Mirrors..." 195 | curl -s "${BUCKET}/${config}" > "${WORKDIR}/.target" 196 | 197 | sed -i "s/host/${host}/g" "${WORKDIR}/.target" 198 | sed -i "s/version/${version}/g" "${WORKDIR}/.target" 199 | 200 | cat "${WORKDIR}/.target" > ${destination} 201 | 202 | done 203 | 204 | print_info 205 | 206 | info "Success...You can use apt or yum command to update your system." 207 | } 208 | 209 | infomation() { 210 | 211 | clear 212 | echo -e "" 213 | echo -e "${green}tiny-shell ${plain}System Infomations" 214 | echo -e ${line} 215 | echo -e "" 216 | 217 | info "OS - ${release}" 218 | info "Version - ${version}" 219 | info "Bucket - ${BUCKET}" 220 | info "arch - ${architecture}" 221 | } 222 | 223 | dockerce(){ 224 | 225 | if command -v docker > /dev/null ; then 226 | warn "You have installed Docker. Script exit." 227 | return 228 | fi 229 | 230 | clear 231 | echo -e "" 232 | echo -e "${green}tiny-shell ${plain}Docker-ce Install" 233 | echo -e ${line} 234 | echo -e "" 235 | 236 | mirrors_check docker 237 | system_tmp="${WORKDIR}/docker.destination.tmp" 238 | 239 | info "System Configuation is loading..." 240 | curl -s ${BUCKET}/docker.destination > ${system_tmp} 241 | 242 | destinations=($(cat ${system_tmp} | grep "${release}-${version}")) 243 | 244 | if [[ ${#destinations[@]} -eq 0 ]]; then 245 | destinations=($(cat ${system_tmp} | grep "${release}-default")) 246 | warn "Loading Default Configuation." 247 | fi 248 | 249 | debug "${destinations}" 250 | destination=$(echo ${destinations} | cut -d "|" -f 3) 251 | config="${release}/"$(echo ${destinations} | cut -d "|" -f 2) 252 | 253 | debug "destination=${destination}" 254 | debug "config=${config}" 255 | backup ${destination} "docker" 256 | 257 | info "Downloading Docker Mirrors..." 258 | curl -s "${BUCKET}/${config}" > "${WORKDIR}/.target" 259 | debug "download url=${BUCKET}/${config}" 260 | 261 | sed -i "s/host/${host}/g" "${WORKDIR}/.target" 262 | sed -i "s/version/${version}/g" "${WORKDIR}/.target" 263 | 264 | cat "${WORKDIR}/.target" > ${destination} 265 | 266 | # download grp 267 | # /etc/apt/keyrings/docker.gpg 268 | mkdir -p /etc/apt/keyrings 269 | curl -fsSL -o /etc/apt/keyrings/gpg "http://${host}/docker-ce/linux/${release}/gpg" 270 | 271 | if [[ $release = "ubuntu" ]]; then 272 | gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg /etc/apt/keyrings/gpg 273 | fi 274 | 275 | sed -i "s/host/${host}/g" "${WORKDIR}/.target" 276 | sed -i "s/version/${version}/g" "${WORKDIR}/.target" 277 | 278 | cat "${WORKDIR}/.target" > ${destination} 279 | 280 | print_info 281 | 282 | info "Install Docker..." 283 | 284 | apt-get update > /dev/null && apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin > /dev/null 285 | docker version && info "Install Docker Success..." 286 | } 287 | 288 | 289 | menu(){ 290 | echo -e "" 291 | echo -e "${green}Tiny-Shell ${plain}" 292 | 293 | echo -e "A Simple Shell Script To Help You For Work" 294 | echo -e "" 295 | echo -e "./tiny-shell.sh - Help" 296 | echo -e "./tiny-shell.sh system - Check System Mirrors" 297 | echo -e "./tiny-shell.sh info - Check Your System Infomations." 298 | echo -e "./tiny-shell.sh docker - Install Docker Environment" 299 | echo -e "./tiny-shell.sh pypi - Configuating Python Package Manager's Mirrors" 300 | echo -e "./tiny-shell.sh maven - Maven's Mirrors Check" 301 | echo -e "" 302 | } 303 | 304 | if [[ $# > 0 ]]; then 305 | case $1 in 306 | "system") 307 | root_check && system 308 | ;; 309 | "docker") 310 | root_check && dockerce 311 | ;; 312 | "info") 313 | infomation 314 | ;; 315 | "pypi") 316 | pypi 317 | ;; 318 | "maven") 319 | maven 320 | ;; 321 | "reset") 322 | reset 323 | ;; 324 | *) menu 325 | ;; 326 | esac 327 | else 328 | menu 329 | fi -------------------------------------------------------------------------------- /ubuntu/default: -------------------------------------------------------------------------------- 1 | deb http://host/ubuntu/ version main restricted universe multiverse 2 | #deb-src http://host/ubuntu/ version main restricted universe multiverse 3 | 4 | deb http://host/ubuntu/ version-security main restricted universe multiverse 5 | #deb-src http://host/ubuntu/ version-security main restricted universe multiverse 6 | 7 | deb http://host/ubuntu/ version-updates main restricted universe multiverse 8 | #deb-src http://host/ubuntu/ version-updates main restricted universe multiverse 9 | 10 | deb http://host/ubuntu/ version-backports main restricted universe multiverse 11 | #deb-src http://host/ubuntu/ version-backports main restricted universe multiverse 12 | -------------------------------------------------------------------------------- /ubuntu/docker: -------------------------------------------------------------------------------- 1 | deb [signed-by=/etc/apt/keyrings/docker.gpg] http://host/docker-ce/linux/ubuntu version stable 2 | -------------------------------------------------------------------------------- /upload.sh: -------------------------------------------------------------------------------- 1 | 2 | # check qshell 3 | qshell -v 4 | 5 | if [[ $? != 0 ]];then 6 | echo "install qshell" 7 | fi 8 | 9 | qshell qupload2 --bucket tiny-shell \ 10 | --overwrite true \ 11 | --src-dir $(pwd) \ 12 | --skip-file-prefixes "upload" \ 13 | --skip-path-prefixes ".tiny-shell/,doc/,icons/" \ 14 | --skip-fixed-strings ".git,.gitignore" 15 | --------------------------------------------------------------------------------