1, 简单的LAMP 构建:
# ================= # bin/bash # author Xu # =================== # ++++++++++++++++++++++ # ----------- createFile # arg 1 is Filename # arg 2 is Contents # return 1 function createFile () { if [ -f "./"$1 ];then echo "The File "$1" already exists!" echo " Whether to delete ?"$1" (0) NO (1) YES " read -p 1 input case $input in 0) exit;; 1) rm $1 exit;; esac else echo " Create add file "$1". OK" cat>>$1 <<EDF $2 EDF fi return 1 } echo " [0] create Vagrantfile; [1] chmod + > VirtualBox; [2] vagrant up; [3] ping ip; [4] ssh; [5] Url; [9] exit; " # Url url="192.168.33.11" read -p 9 input case $input in 0 ) echo 'Create add file Vagrantfile'; # Create add file Vagrantfile vagrantfile="Vagrantfile" createFile $vagrantfile "Vagrant.configure("2") do |config| config.vm.box = "scotch/box" config.vm.box_version = "3.5" config.vm.network "private_network", ip: $url config.vm.synced_folder ".", "/vagrant_data" config.vm.synced_folder "public", "/var/www/public" end " # execution this exec sh "$0" # ....... vagrant up exit;; 1 ) echo "Add permissions otherwise an error will be reported!" for bin in VirtualBox VirtualBoxVM VBoxNetAdpCtl VBoxNetDHCP VBoxNetNAT VBoxHeadless; do sudo chmod u+s "/Applications/VirtualBox.app/Contents/MacOS/${bin}" done exit;; 2 ) # rm -rf public && mkdir public && cd public && cat>>index.php<<EDF <?php echo phpinfo();?> EDF vagrant up exit;; 3 ) vagrant ssh -c ifconfig exit;; 4 ) vagrant ssh exit;; 5 ) echo $url exit;; 9 ) exit;; esac
2,