github.com/dahs81/otto@v0.2.1-0.20160126165905-6400716cf085/images/scripts/omnios/postinstall.sh (about) 1 #!/bin/sh 2 3 echo "Creating vagrant user" 4 useradd -m -k /etc/skel/ -b /export/home -s /usr/bin/bash vagrant 5 passwd -N vagrant 6 7 echo "Adding Vagrant user to sudoers" 8 echo "vagrant ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers 9 echo 'Defaults env_keep += "SSH_AUTH_SOCK"' >> /etc/sudoers 10 chmod 0440 /etc/sudoers 11 12 # add paths and other options to vagrant user's shell 13 echo "Setting Vagrant user's and root's environment" 14 echo "export PATH=\$PATH:/opt/omni/bin" >> /export/home/vagrant/.profile 15 echo "export PATH=\$PATH:/opt/omni/bin" >> /root/.profile 16 17 # move /usr/gnu/bin to end of PATH for root and vagrant, since its presence at 18 # the front breaks vagrant 1.1+ 19 echo "Moving GNU path in Vagrant user's and root's environment" 20 sed -i -e 's/PATH=\/usr\/gnu\/bin:\(.*\)/PATH=\1:\/usr\/gnu\/bin/' \ 21 /export/home/vagrant/.profile 22 sed -i -e 's/PATH=\/usr\/gnu\/bin:\(.*\)/PATH=\1:\/usr\/gnu\/bin/' \ 23 /root/.profile 24 25 # setup the vagrant key 26 # you can replace this key-pair with your own generated ssh key-pair 27 echo "Setting the vagrant ssh pub key" 28 mkdir /export/home/vagrant/.ssh 29 chmod 700 /export/home/vagrant/.ssh 30 chown vagrant:root /export/home/vagrant/.ssh 31 touch /export/home/vagrant/.ssh/authorized_keys 32 curl -sL http://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub > \ 33 /export/home/vagrant/.ssh/authorized_keys 34 chmod 600 /export/home/vagrant/.ssh/authorized_keys 35 chown vagrant:root /export/home/vagrant/.ssh/authorized_keys 36 37 # formally add omniti-ms publisher 38 echo "Adding omniti-ms publisher" 39 pkg set-publisher -g http://pkg.omniti.com/omniti-ms/ ms.omniti.com 40 41 # remove root login from sshd 42 echo "Removing root login over SSH" 43 sed -i -e "s/PermitRootLogin yes/PermitRootLogin no/" /etc/ssh/sshd_config 44 svcadm restart ssh 45 46 # update grub menu to lower timeout and remove unnecessary second entry 47 echo "Updating Grub boot menu" 48 sed -i -e 's/^timeout.*$/timeout 5/' -e "/^title omniosvar/,`wc -l /rpool/boot/grub/menu.lst | awk '{ print $1 }'` d" /rpool/boot/grub/menu.lst 49 50 # Reset resolv.conf 51 echo "Resetting resolv.conf" 52 echo "nameserver 8.8.8.8" > /etc/resolv.conf 53 54 echo "Post-install done"