From 28edd2bdf91ac6383a2a50777e5cc9304390a2cd Mon Sep 17 00:00:00 2001 From: ehlxr Date: Fri, 2 Nov 2018 10:42:27 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=99=E7=82=B9=E6=9B=B4=E6=96=B0=EF=BC=9A20?= =?UTF-8?q?18-11-02=2010:42:27?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Vagrantfile | 17 +++++++++-------- config/init.sh | 3 +++ config/resolv.conf | 4 ++++ 3 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 config/resolv.conf diff --git a/Vagrantfile b/Vagrantfile index 4c6a2e1..363bffd 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -49,14 +49,15 @@ Vagrant.configure("2") do |config| cfg.vm.synced_folder "/Users/ehlxr/works/Vagrant", "/vagrant" # 开机运行命令 - # cfg.vm.provision "shell", run: "always", inline: <<-SHELL - # echo -e "\033[1;33mInit cmd...\033[0m" - # echo -e "\033[1;33mConfig ssh...\033[0m" - # mkdir -p ~/.ssh && cat /vagrant/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 - # SHELL + cfg.vm.provision "shell", run: "always", inline: <<-SHELL + echo -e "\033[1;33mConfig ssh...\033[0m" + mkdir -p ~/.ssh && cat /share/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 /share/config/resolv.conf /etc/ + SHELL # 自定义初始化执行脚本 # cfg.vm.provision "shell", path: "config/init.sh" diff --git a/config/init.sh b/config/init.sh index 9080bb3..47f2f51 100755 --- a/config/init.sh +++ b/config/init.sh @@ -35,6 +35,9 @@ 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;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 diff --git a/config/resolv.conf b/config/resolv.conf new file mode 100644 index 0000000..af2506a --- /dev/null +++ b/config/resolv.conf @@ -0,0 +1,4 @@ +# Generated by NetworkManager + +nameserver 114.114.114.114 +nameserver 8.8.8.8