Compare commits

..

1 Commits

Author SHA1 Message Date
elvin-henry
652fab3cf8 update 2018-11-02 23:49:09 +08:00
9 changed files with 30 additions and 182 deletions

1
.gitignore vendored
View File

@ -2,4 +2,3 @@
*.box
.vagrant
vm_share
*.log

View File

@ -10,35 +10,24 @@
```sh
➜ cd base
➜ wget https://www.dropbox.com/s/570sb9j9k6b9rpp/centos-7.5-ehlxr.box?dl=0 -O centos-7.5-ehlxr.box
➜ wget https://www.dropbox.com/s/nuz6ts1hlx4vy27/vagrant-centos-7.2.box\?dl\=0 -O vagrant-centos-7.2.box
➜ vagrant box add -f centos-7.5-ehlxr centos-7.5-ehlxr.box
➜ vagrant box add -f centos-7.2 vagrant-centos-7.2.box
➜ vagrant up # 执行 init.sh 脚本时,最好保证能够 fq
➜ vagrant package --output centos-7.5-ehlxr.box
➜ vagrant package --output centos-7.2-ehlxr.box
➜ vagrant box add -f centos-7.5-ehlxr centos-7.5-ehlxr.box
➜ vagrant box add -f centos-7.2-ehlxr centos-7.2-ehlxr.box
```
```sh
# onedrive.live.com、drive.google.com、pan.baidu.com 下载 centos-7.5-ehlxr
# onedrive.live.com、drive.google.com、pan.baidu.com 下载 centos-7.2-ehlxr.box
➜ vagrant box add -f centos-7.5-ehlxr centos-7.5-ehlxr.box
➜ vagrant box add -f centos-7.2-ehlxr centos-7.2-ehlxr.box
# vagrant package --base vghost1 --output centos-ehlxr.box
➜ vagrant up # 执行 init.sh 脚本时,最好保证能够 fq
```
## vagrant plugin install 超时解决方法
```sh
➜ gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
➜ gem sources -l
# 确保只有 gems.ruby-china.com
➜ vagrant plugin install vagrant-vbguest --plugin-clean-sources --plugin-source https://gems.ruby-china.com/
```

33
Vagrantfile vendored
View File

@ -2,16 +2,14 @@ Vagrant.configure("2") do |config|
# 定义虚拟机数量
vms = Array(1..5)
vms.each do |i|
config.vm.define "vm#{i}" do |cfg|
config.vm.define "vg#{i}" do |cfg|
# 设置虚拟机的 Box
# cfg.vm.box = "centos-7.5-ehlxr"
cfg.vm.box = "ubuntu-focal"
cfg.vm.box_url = "https://mirrors.ustc.edu.cn/ubuntu-cloud-images/focal/current/focal-server-cloudimg-amd64-vagrant.box"
cfg.vm.box = "centos-7.2-ehlxr"
# 不检查 box 更新
cfg.vm.box_check_update = false
# 设置虚拟机的主机名
cfg.vm.hostname="vm.node#{i}"
cfg.vm.hostname="vg#{i}.node"
# cfg.vm.network "forwarded_port", guest: 80, host: 8080
# hostonly
@ -29,41 +27,36 @@ Vagrant.configure("2") do |config|
vb.cpus = 1
# 名称指的是在 VirtualBox 中显示的名称
vb.name = "vmhost#{i}"
vb.name = "vghost#{i}"
end
# 增加各节点 host 配置插件安装vagrant plugin install vagrant-hosts
cfg.vm.provision :hosts do |provisioner|
vms.each do |x|
provisioner.add_host "192.168.3.10#{x}", ["vm.node#{x}"]
provisioner.add_host "192.168.3.10#{x}", ["vg#{x}.node"]
end
end
# 默认 root 登陆
# cfg.ssh.username = "root"
# cfg.ssh.password = "vagrant"
# cfg.ssh.insert_key = "true"
cfg.ssh.username = "root"
cfg.ssh.password = "vagrant"
cfg.ssh.insert_key = "true"
# do NOT check the correct additions version when booting this machine插件安装vagrant plugin install vagrant-vbguest
cfg.vbguest.auto_update = false
# cfg.vm.synced_folder "./", "/root/", type: "virtualbox"
# cfg.vm.synced_folder "./", "/vagrant", disabled: true
# cfg.vm.synced_folder "./", "/root/share", type: "virtualbox"
cfg.vm.synced_folder "E:\\ehlxr\\Vagrant", "/vagrant", disabled: true
cfg.vm.synced_folder "E:\\ehlxr\\Vagrant\\vm_share", "/root"
# 开机运行命令
cfg.vm.provision "shell", run: "always", inline: <<-SHELL
echo -e "\033[1;33mConfig ssh...\033[0m"
mkdir -p ~/.ssh && cat /vagrant/config/authorized.key >> ~/.ssh/authorized_keys
mkdir -p ~/.ssh && cat /root/config/authorized.key >> ~/.ssh/authorized_keys
sed -i 's/^#RSAAuthentication.*/RSAAuthentication\ yes/g' /etc/ssh/sshd_config
sed -i 's/^#PubkeyAuthentication.*/PubkeyAuthentication\ yes/g' /etc/ssh/sshd_config
sed -i 's/^PasswordAuthentication.*/PasswordAuthentication\ yes/g' /etc/ssh/sshd_config
# echo -e "\033[1;33mConfig dns...\033[0m"
# cp /vagrant/config/resolv.conf /etc/
# echo -e "\033[1;33mConfig oh-my-zsh...\033[0m"
# cp -f /vagrant/config/zshrc ~/.zshrc
# cp -f /vagrant/config/my.zsh ~/.oh-my-zsh/custom/
# cp -f /vagrant/config/ehlxr2.zsh-theme ~/.oh-my-zsh/custom/themes/
echo -e "\033[1;33mConfig dns...\033[0m"
cp /root/config/resolv.conf /etc/
SHELL
# 自定义初始化执行脚本

16
base/Vagrantfile vendored
View File

@ -2,22 +2,8 @@
Vagrant.configure("2") do |config|
config.vm.box = "centos-7.2"
config.vm.network "private_network", ip: "192.168.3.3"
config.vm.hostname="vm.node"
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = false
# Customize the amount of memory on the VM:
vb.memory = "1024"
vb.cpus = 1
# 名称指的是在 VirtualBox 中显示的名称
vb.name = "vmhost-base"
end
config.vbguest.auto_update = false
config.vm.synced_folder "/Users/ehlxr/works/Vagrant", "/vagrant", type: "virtualbox"
cfg.vm.synced_folder "E:\\ehlxr\\Vagrant", "/vagrant"
# 自定义初始化执行脚本
config.vm.provision "shell", path: "../config/init.sh"

View File

@ -1,15 +1,5 @@
{
"experimental": false,
"debug": true,
"registry-mirrors": [
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com",
"https://g24agb7f.mirror.aliyuncs.com",
"https://docker.mirrors.ustc.edu.cn",
"https://mirror.ccs.tencentyun.com",
"https://dockerhub.azk8s.cn",
"https://hub-mirror.c.163.com",
"https://docker.pkg.github.com/",
"https://registry.enncloud.cn/"
"https://registry.docker-cn.com"
]
}

View File

@ -1,51 +0,0 @@
# VCS
YS_VCS_PROMPT_PREFIX1="%{$fg[white]%}(%{$reset_color%}"
YS_VCS_PROMPT_PREFIX2="%{$fg[cyan]%}"
YS_VCS_PROMPT_SUFFIX="%{$reset_color%}"
YS_VCS_PROMPT_DIRTY=" %{$fg[red]%}x"
YS_VCS_PROMPT_CLEAN=" %{$fg[green]%}o"
YS_VCS_PROMPT_CLOSE="%{$fg[white]%}) %{$reset_color%}"
# Git info.
local git_info='$(git_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="${YS_VCS_PROMPT_PREFIX1}${YS_VCS_PROMPT_PREFIX2}"
ZSH_THEME_GIT_PROMPT_SUFFIX="$YS_VCS_PROMPT_SUFFIX"
ZSH_THEME_GIT_PROMPT_DIRTY="${YS_VCS_PROMPT_DIRTY}${YS_VCS_PROMPT_CLOSE}"
ZSH_THEME_GIT_PROMPT_CLEAN="${YS_VCS_PROMPT_CLEAN}${YS_VCS_PROMPT_CLOSE}"
# root user
local root_symbols
[[ $UID -eq 0 ]] && root_symbols+=" %{%F{yellow}%}*"
# background jobs
local bg_symbols='$(prompt_background_jobs)'
prompt_background_jobs() {
local background_jobs_number=${$(jobs -l | wc -l)// /}
if [[ background_jobs_number -gt 0 ]]; then
echo " %{%F{cyan}%}&"
fi
}
local exit_code="%(?,, C:%{$fg[red]%}%?%{$reset_color%})"
# PROMPT="
# %{$terminfo[bold]$fg[blue]%}⌘%{$reset_color%} \
# %{$terminfo[bold]$fg[yellow]%}%~ %{$reset_color%}\
# ${git_info}\
# %{$fg[white]%}[%*]\
# ${root_symbols}${bg_symbols}\
# $exit_code
# %{%F{green}%}➜ %{$reset_color%}"
PROMPT="
%{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \
%{$fg[cyan]%}%n \
%{$fg[white]%}in \
%{$terminfo[bold]$fg[yellow]%}%~ %{$reset_color%}\
${git_info}\
%{$fg[white]%}[%*]\
${root_symbols}${bg_symbols}\
%(?,%{$fg[green]%}, %{$fg[red]%})
➜ %{$reset_color%}"

View File

@ -1,53 +0,0 @@
# Based on gnzh theme
setopt prompt_subst
() {
local PR_USER PR_USER_OP PR_PROMPT PR_HOST
# Check the UID
if [[ $UID -ne 0 ]]; then # normal user
PR_USER='%F{green}%n%f'
PR_USER_OP='%F{green}%#%f'
else # root
PR_USER='%F{red}%n%f'
PR_USER_OP='%F{red}%#%f'
fi
# PR_PROMPT='%f> %f'
PR_PROMPT='%(?,%{$fg[green]%},%{$fg[red]%})> %{$reset_color%}'
# Check if we are on SSH or not
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
PR_HOST='%F{yellow}%M%f' # SSH
else
PR_HOST='%F{cyan}%M%f' # no SSH
fi
local return_code="%(?..%F{red}%? ↵%f)"
local user_host="${PR_USER}%F{white}@${PR_HOST}"
local current_dir="%B%F{blue}%~%f%b"
local rvm_ruby=''
if ${HOME}/.rvm/bin/rvm-prompt &> /dev/null; then # detect user-local rvm installation
rvm_ruby='%F{red}$(${HOME}/.rvm/bin/rvm-prompt i v g s)%f'
elif which rvm-prompt &> /dev/null; then # detect system-wide rvm installation
rvm_ruby='%F{red}$(rvm-prompt i v g s)%f'
elif which rbenv &> /dev/null; then # detect Simple Ruby Version Management
rvm_ruby='%F{red}$(rbenv version | sed -e "s/ (set.*$//")%f'
fi
local git_branch='$(git_prompt_info)'
PROMPT="%F{white}╭─ ${user_host} ${current_dir} ${git_branch} ${rvm_ruby}
%F{white}╰─$PR_PROMPT"
RPROMPT="${return_code} [%D{%H:%M:%S}]"
ZSH_THEME_GIT_PROMPT_PREFIX="%F{green}("
#ZSH_THEME_GIT_PROMPT_PREFIX="%F{yellow}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%F{green})"
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}x"
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}o"
}

View File

@ -28,7 +28,6 @@ git clone https://github.com/zsh-users/zsh-history-substring-search.git /root/.o
echo -e "\033[1;33mConfig oh-my-zsh...\033[0m"
cp -f /vagrant/config/zshrc ~/.zshrc
cp -f /vagrant/config/my.zsh ~/.oh-my-zsh/custom/
cp -f /vagrant/config/ehlxr2.zsh-theme ~/.oh-my-zsh/custom/themes/
echo -e "\033[1;33mConfig ssh...\033[0m"
mkdir -p ~/.ssh && cat /vagrant/config/authorized.key >> ~/.ssh/authorized_keys
@ -39,11 +38,11 @@ sed -i 's/^PasswordAuthentication.*/PasswordAuthentication\ yes/g' /etc/ssh/sshd
echo -e "\033[1;33mConfig dns...\033[0m"
cp /vagrant/config/resolv.conf /etc/
echo -e "\033[1;33mUpdating kernel...\033[0m"
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
yum --enablerepo=elrepo-kernel install kernel-ml-devel kernel-ml -y
grub2-set-default 0
# echo -e "\033[1;33mUpdating kernel...\033[0m"
# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
# yum --enablerepo=elrepo-kernel install kernel-ml-devel kernel-ml -y
# grub2-set-default 0
echo -e "\033[1;33mInstall docker...\033[0m"
wget -qO- https://get.docker.com | sh

View File

@ -1,13 +1,9 @@
export ZSH=~/.oh-my-zsh
ZSH_THEME="ehlxr2"
ZSH_THEME="robbyrussell"
plugins=(git wd sudo zsh-syntax-highlighting zsh-autosuggestions extract history-substring-search docker docker-compose)
plugins=(git wd sudo zsh-syntax-highlighting zsh-autosuggestions extract history-substring-search)
source $ZSH/oh-my-zsh.sh
# source ~/.bash_profile
alias di='docker images'
alias dp='docker ps -a'
alias ds='docker stats'