Last active 6 months ago

Revision c30502ef30c3b9662864c43b8c475f78562cb923

install-rpm.sh Raw
1#!/bin/bash
2
3# 定义安装命令的函数,接收 user 和 repo 作为参数
4case "$(uname -m)" in
5 x86_64)
6 arch="amd64"
7 ;;
8 aarch64)
9 arch="arm64"
10 ;;
11 *)
12 echo "Unsupported architecture: $(uname -m)"
13 exit 1
14 ;;
15esac
16
17if [ "$2" = "-U" ]; then
18 case "$1" in
19 "helm" | "k9s" | "govc" | "nerdctl" | "fzf" | "terraform" | "packer" )
20 rm -rf /usr/local/bin/"$1" "${fpath[0]}"/_"$1" /etc/bash_completion.d/"$1"
21 echo
22 echo "-------------------------------------------"
23 echo "$1 installation complete!"
24 echo
25 echo "-------------------------------------------"
26 echo
27 ;;
28 "trzsz" )
29 rm -rf /usr/local/bin/"trzsz" /usr/local/bin/"trz" /usr/local/bin/"tsz" "${fpath[0]}"/_"$1" /etc/bash_completion.d/"trzsz"
30 echo
31 echo "-------------------------------------------"
32 echo "$1 installation complete!"
33 echo
34 echo "-------------------------------------------"
35 echo
36 ;;
37 *)
38 echo "Unsupported package: $1"
39 exit 1
40 ;;
41 esac
42 exit 0
43else
44 case "$1" in
45 "helm")
46 # helm
47 echo
48 echo "Installing helm..."
49 version=$(curl -s https://get.helm.sh/helm-latest-version)
50 curl -s -L -o - "https://get.helm.sh/helm-${version}-linux-${arch}.tar.gz" | tar --strip-components=1 -C /usr/local/bin -xzf - linux-amd64/helm
51 helm completion zsh > "${fpath[1]}/_helm" || true
52 helm completion bash > /etc/bash_completion.d/helm
53 # Displaying post-installation instructions
54 echo
55 echo "-------------------------------------------"
56 echo "helm installation complete!"
57 echo
58 # Displaying version
59 helm version
60 echo
61 echo "-------------------------------------------"
62 echo
63 ;;
64 "k9s")
65 # derailed k9s
66 echo
67 echo "Installing k9s..."
68 curl -s -L -o - "https://github.com/derailed/k9s/releases/latest/download/k9s_Linux_${arch}.tar.gz" | tar -C /usr/local/bin -xzf - k9s
69 # Displaying post-installation instructions
70 echo
71 echo "-------------------------------------------"
72 echo "k9s installation complete!"
73 echo
74 # Displaying version
75 k9s version
76 echo
77 echo "-------------------------------------------"
78 echo
79 ;;
80 "govc")
81 # vmware govmomi
82 echo
83 echo "Installing govmomi..."
84 curl -s -L -o - "https://github.com/vmware/govmomi/releases/latest/download/govc_$(uname -s)_$(uname -m).tar.gz" | tar -C /usr/local/bin -xvzf - govc
85 # Displaying post-installation instructions
86 echo
87 echo "-------------------------------------------"
88 echo "nerdctl installation complete!"
89 echo
90 # Displaying version
91 govc version
92 echo
93 echo "To initialize the environment, please run:"
94 echo " export GOVC_URL=\"https://administrator@vsphere.local:password@vcip\""
95 echo " export GOVC_INSECURE=true"
96 echo "-------------------------------------------"
97 echo
98 ;;
99 "nerdctl")
100 # vmware nerdctl
101 echo
102 echo "Installing nerdctl..."
103 VERSION=$(curl -s https://api.github.com/repos/containerd/nerdctl/releases/latest | jq -r '.tag_name' | awk -F"v" '{print $NF}')
104 curl -s -L -o - "https://github.com/containerd/nerdctl/releases/latest/download/nerdctl-${VERSION}-linux-${arch}.tar.gz" | tar -C /usr/local/bin -xvzf - nerdctl
105 nerdctl completion zsh > "${fpath[1]}/_nerdctl" || true
106 nerdctl completion bash > /etc/bash_completion.d/nerdctl
107 # Displaying post-installation instructions
108 echo
109 echo "-------------------------------------------"
110 echo "nerdctl installation complete!"
111 echo
112 # Displaying version
113 nerdctl version
114 echo
115 echo "-------------------------------------------"
116 echo
117 ;;
118 "fzf")
119 # fzf
120 echo
121 echo "Installing fzf..."
122 VERSION=$(curl -s https://api.github.com/repos/junegunn/fzf/releases/latest | jq -r '.tag_name' | awk -F"v" '{print $NF}')
123 curl -s -L -o - "https://github.com/junegunn/fzf/releases/latest/download/fzf-${VERSION}-linux_${arch}.tar.gz" | tar -C /usr/local/bin -xvzf - fzf
124 fzf --zsh > "${fpath[1]}/_fzf" || true
125 fzf --bash > /etc/bash_completion.d/fzf
126 # Displaying post-installation instructions
127 echo
128 echo "-------------------------------------------"
129 echo "fzf installation complete!"
130 echo
131 # Displaying version
132 fzf --version
133 echo
134 echo "-------------------------------------------"
135 echo
136 ;;
137 "terraform")
138 # terraform
139 echo
140 echo "Installing Terraform..."
141 # Fetching the latest version of Terraform
142 VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M '.current_version')
143 curl -s -L -o "terraform_${VERSION}_linux_${arch}.zip" "https://releases.hashicorp.com/terraform/${VERSION}/terraform_${VERSION}_linux_${arch}.zip"
144 # Unzipping and installing Terraform
145 unzip -qq -o "terraform_${VERSION}_linux_${arch}.zip" terraform -d /usr/local/bin && rm -f "terraform_${VERSION}_linux_${arch}.zip"
146 # Displaying post-installation instructions
147 echo
148 echo "-------------------------------------------"
149 echo "Terraform installation complete!"
150 echo
151 # Displaying terraform version
152 terraform --version
153 echo
154 echo "To enable CLI auto-completion, please run:"
155 echo " terraform -install-autocomplete"
156 echo "-------------------------------------------"
157 echo
158 ;;
159 "packer")
160 # packer
161 echo
162 echo "Installing Packer..."
163 # Fetching the latest version of packer
164 VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/packer | jq -r -M '.current_version')
165 curl -s -L -o "packer_${VERSION}_linux_${arch}.zip" "https://releases.hashicorp.com/packer/${VERSION}/packer_${VERSION}_linux_${arch}.zip"
166 # Unzipping and installing packer
167 unzip -qq -o "packer_${VERSION}_linux_${arch}.zip" packer -d /usr/local/bin && rm -rf "packer_${VERSION}_linux_${arch}.zip" /usr/sbin/packer
168 # Displaying post-installation instructions
169 echo
170 echo "-------------------------------------------"
171 echo "Packer installation complete!"
172 echo
173 # Displaying packer version
174 packer --version
175 echo
176 echo "To enable CLI auto-completion, please run:"
177 echo " packer -autocomplete-install"
178 echo "-------------------------------------------"
179 echo
180 ;;
181 "trzsz")
182 # trzsz
183 echo
184 echo "Installing trzsz..."
185 curl -s -L -o - "https://github.com/trzsz/trzsz-go/releases/download/v1.1.8/trzsz_1.1.8_linux_$(uname -m).tar.gz" | tar --strip-components=1 -C /usr/local/bin -xvzf -
186 # Displaying post-installation instructions
187 echo
188 echo "-------------------------------------------"
189 echo "trzsz installation complete!"
190 echo
191 # Displaying version
192 /usr/local/bin/trzsz version
193 echo
194 ;;
195 *)
196 echo
197 echo "helm k9s govc nerdctl fzf terraform packer trzsz"
198 exit 1
199 ;;
200 esac
201 exit 0
202fi
install_ohmyzsh.sh Raw
1#!/bin/bash
2
3yum install git zsh bash-completion wget unzip tree tmux vim sysstat -y -q &> /dev/null || true
4
5# install oh-my-zsh
6git clone https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git
7REMOTE=https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git sh ohmyzsh/tools/install.sh && rm -rf ohmyzsh
8
9ZSH=$HOME/.oh-my-zsh
10# install zsh-syntax-highlighting
11# git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
12git clone https://mirrors.nju.edu.cn/git/zsh-syntax-highlighting.git $ZSH/custom/plugins/zsh-syntax-highlighting
13# echo "source $ZSH_CUSTOM/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
14
15# install zsh-autosuggestions
16# git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
17git clone https://mirrors.nju.edu.cn/git/zsh-autosuggestions.git $ZSH/custom/plugins/zsh-autosuggestions
18# echo "source $ZSH_CUSTOM/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
19
20# replace plugins and theme
21cp $HOME/.zshrc $HOME/.zshrc.bak
22zsh -c 'source ~/.zshrc && omz plugin enable zsh-autosuggestions zsh-syntax-highlighting sudo'
23zsh -c 'source ~/.zshrc && omz theme set ys'
24# sed -i 's/(git/(git zsh-syntax-highlighting zsh-autosuggestions sudo/g' ~/.zshrc
25# sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="ys"/g' ~/.zshrc
26
27cat >> ~/.zshrc <<UK
28
29## add
30zstyle ':omz:update' mode disabled
31HIST_STAMPS="yyyy-mm-dd"
32alias vi="vim"
33UK