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