Skip to content

Commit

Permalink
:feat: fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
marcho committed Jan 28, 2024
1 parent d0a8261 commit aef6958
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 23 deletions.
2 changes: 1 addition & 1 deletion debian/docker
Original file line number Diff line number Diff line change
@@ -1 +1 @@
deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://host/docker-ce/linux/debian version stable
deb [signed-by=/etc/apt/keyrings/docker.gpg] https://host/docker-ce/linux/debian version stable
6 changes: 3 additions & 3 deletions host.mirrors
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
tencent|mirrors.cloud.tencent.com|腾讯软件源|https://mirrors.cloud.tencent.com|ubuntu,debian,docker,centos,maven,pypi
163|mirrors.163.com|网易开源镜像站|https://mirrors.163.com|ubuntu,debian,centos,docker,maven,pypi
tencent|mirrors.cloud.tencent.com|腾讯软件源|https://mirrors.cloud.tencent.com|ubuntu,debian,centos,maven,pypi
tsinghua|mirrors.tuna.tsinghua.edu.cn|清华大学开源软件镜像站|https://mirrors.tuna.tsinghua.edu.cn|ubuntu,debian,docker,centos-stream
ustc|mirrors.ustc.edu.cn|中国科学技术大学开源软件镜像|https://mirrors.ustc.edu.cn|ubuntu,debian,docker,centos-stream
163|mirrors.163.com|网易开源镜像站|https://mirrors.163.com|ubuntu,debian,centos,docker,maven,pypi
aliyun|mirrors.aliyun.com|阿里云镜像站|https://mirrors.aliyun.com|ubuntu,debian,docker,centos,centos-stream,maven,pypi
tsinghua|mirrors.tuna.tsinghua.edu.cn|清华大学开源软件镜像站|https://mirrors.tuna.tsinghua.edu.cn|ubuntu,debian,docker,centos-stream
nju|mirror.nju.edu.cn|南京大学开源镜像站|https://mirror.nju.edu.cn|ubuntu,debian
sjtu|mirror.sjtu.edu.cn|上海交通大学开源镜像站|https://mirror.sjtu.edu.cn|ubuntu,debian,docker
lzu|mirror.lzu.edu.cn|兰州大学开源镜像站|https://mirror.lzu.edu.cn|ubuntu,debian
4 changes: 3 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env bash

curl -s -o tiny-shell.sh https://tiny-shell.chaobei.xyz/tiny-shell.sh
BUCKET="https://tiny-shell.chaobei.xyz"
curl -s -o tiny-shell.sh ${BUCKET}/tiny-shell.sh

sed 's/file:${pwd}/https:\/\/tiny-shell.chaobei.xyz/g' tiny-shell.sh
chmod +x tiny-shell.sh

./tiny-shell.sh
67 changes: 50 additions & 17 deletions tiny-shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ green='\033[0;32m'
yellow='\033[0;33m'
plain='\033[0m'

BUCKET="https://tiny-shell.chaobei.xyz"
pwd=$(pwd)
BUCKET="file:${pwd}"
WORKDIR=".tiny-shell"

mkdir -p ${WORKDIR}

info() {
date=$(date +"%Y-%m-%d %H:%M:%S")
echo -e "${date} INFO ${1}"
Expand Down Expand Up @@ -67,32 +66,41 @@ elif [[ -f /etc/redhat-release ]]; then
elif cat /etc/issue | grep -Eqi "debian"; then
release="debian"
version=$(cat /etc/os-release | grep "VERSION_CODENAME" | cut -d '=' -f 2)
architecture=$(dpkg --print-architecture)
elif cat /etc/issue | grep -Eqi "ubuntu"; then
release="ubuntu"
version=$(cat /etc/os-release | grep "VERSION_CODENAME" | cut -d '=' -f 2)
architecture=$(dpkg --print-architecture)
elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then
release="centos"
version=$(cat /etc/os-release | grep "VERSION_ID" | grep -Eo "[0-9]")
elif cat /proc/version | grep -Eqi "debian"; then
release="debian"
version=$(cat /etc/os-release | grep "VERSION_CODENAME" | cut -d '=' -f 2)
architecture=$(dpkg --print-architecture)
elif cat /proc/version | grep -Eqi "ubuntu"; then
release="ubuntu"
version=$(cat /etc/os-release | grep "VERSION_CODENAME" | cut -d '=' -f 2)
architecture=$(dpkg --print-architecture)
elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then
release="centos"
else
error "The script does't support your system. Please commit your request! \n" && exit 1
fi

yum(){
echo ""
}

apt(){
host="\/\/mirrors.tencent.com\/"
sed -E "s/\/\/[a-zA-Z.0-9]+\//${host}/g" /etc/apt/sources.list
}
# init.
if [[ ! -e ${WORKDIR} ]]; then

info "init package."
if [[ ${release} = "ubuntu" ]];then
apt-get -y install apt-transport-https ca-certificates curl wget gnupg > /dev/null
fi

fi

mkdir -p ${WORKDIR}


mirrors_check(){

Expand Down Expand Up @@ -193,8 +201,27 @@ system(){

}

docker(){
infomation() {

clear
echo -e ""
echo -e "${green}tiny-shell ${plain}System Infomations"
echo -e ${line}
echo -e ""

info "OS - ${release}"
info "Version - ${version}"
info "Bucket - ${BUCKET}"
info "arch - ${architecture}"
}

dockerce(){

if command -v docker > /dev/null ; then
warn "You have installed Docker. Script exit."
return
fi

clear
echo -e ""
echo -e "${green}tiny-shell ${plain}Docker-ce Install"
Expand Down Expand Up @@ -231,18 +258,20 @@ docker(){

cat "${WORKDIR}/.target" > ${destination}

# download grp
# download grp
# /etc/apt/keyrings/docker.asc
mkdir -p /etc/apt/keyrings
curl -fsSL "http://${host}/docker-ce/linux/${release}/gpg" | gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg

wget -q -O .docker.gpg "http://${host}/docker-ce/linux/${release}/gpg"
gpg --dearmor -o /etc/apt/keyrings/docker.gpg .docker.gpg

sed -i "s/host/${host}/g" "${WORKDIR}/.target"
sed -i "s/version/${version}/g" "${WORKDIR}/.target"

cat "${WORKDIR}/.target" > ${destination}

print_info

apt-get update > /dev/null && apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin > /dev/null
docker run hello-world
}


Expand All @@ -254,6 +283,7 @@ menu(){
echo -e ""
echo -e "./tiny-shell - Help"
echo -e "./tiny-shell system - Check System Mirrors"
echo -e "./tiny-shell info - Check Your System Infomations."
echo -e "./tiny-shell docker - Install Docker Environment"
echo -e "./tiny-shell pypi - Configuating Python Package Manager's Mirrors"
echo -e "./tiny-shell maven - Maven's Mirrors Check"
Expand All @@ -266,11 +296,14 @@ if [[ $# > 0 ]]; then
root_check && system
;;
"docker")
root_check && docker
root_check && dockerce
;;
"info")
infomation
;;
"pypi")
pypi
;;
;;
"maven")
maven
;;
Expand Down
2 changes: 1 addition & 1 deletion ubuntu/docker
Original file line number Diff line number Diff line change
@@ -1 +1 @@
deb [signed-by=/etc/apt/keyring/docker.gpg] http://host/docker-ce/linux/ubuntu version stable
deb [signed-by=/etc/apt/keyrings/docker.gpg] http://host/docker-ce/linux/ubuntu version stable

0 comments on commit aef6958

Please sign in to comment.