您好我是流浪汉和打包者的新手,我正在尝试建立一个预先安装了apache2的流浪盒。每次我构建框添加它然后ssh到它没有安装apache。我的脚本如下:
#!/bin/bash
set -e
set -v
# http://superuser.com/questions/196848/how-do-i-create-an-administrator-user-on-ubuntu
# http://unix.stackexchange.com/questions/1416/redirecting-stdout-to-a-file-you-dont-have-write-permission-on
# This line assumes the user you created in the preseed directory is vagrant
echo "vagrant ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/init-users
sudo cat /etc/sudoers.d/init-users
# Installing vagrant keys
wget --no-check-certificate 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub'
sudo mkdir -p /home/vagrant/.ssh
sudo chown -R vagrant:vagrant /home/vagrant/.ssh
cat ./vagrant.pub >> /home/vagrant/.ssh/authorized_keys
apt-get install -y apache2
# Change apache to run as vagrant:vagrant
# https://github.com/ChiperSoft/Packer-Vagrant-Example/blob/master/packer/scripts/packages.sh
sed -i s/www-data/vagrant/ /etc/apache2/envvars
echo "All Done!"
我这样做了吗?
答案 0 :(得分:0)
当您使用Packer构建流浪盒时,需要先使用vagrant box add <name> <packer-box-file>
添加它,然后才能执行vagrant init <name> && vagrant up
。