-
Notifications
You must be signed in to change notification settings - Fork 0
/
1.sh
executable file
·122 lines (100 loc) · 4.13 KB
/
1.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
# This script should finish quickly. The goal is to obtain a VM with Guest
# Additions as quickly as possible. We postpone the creation of the custom user
# account to 3.sh so that the image taken after 2.sh does not have any other
# user.
#
# 1.sh should contain all non-idempotent operations; 2.sh must be idempotent.
#### SANITY CHECK ####
# don't bother updating yet
pkill -f /usr/bin/update-manager
# who should run this?
if [ vagrant != "$USER" ]; then
echo 'Please run this script as the user "vagrant". Aborting...'
exit 1
fi
#### INTERACTIVE ####
# NOPASSWD vagrant as the very first step to avoid future passowrd prompts
echo vagrant |
sudo -S sed -i '$avagrant ALL=(ALL) NOPASSWD: ALL' /etc/sudoers >& /dev/null
# check Additions CD (downloading ISO is too slow)
sudo mkdir -p /media/vagrant/VBOX
sudo chown -R vagrant:vagrant /media/vagrant
sudo mount -r /dev/sr1 /media/vagrant/VBOX
if [ -z "$(find /media/vagrant -maxdepth 1 -type d -name 'VBOX*' -print \
-quit)" ]; then
read -ep 'Press ENTER after you have mounted the Guest Additions CD...'
fi
#### AUTOPILOT ####
# add antialiasing
# https://github.com/achaphiv/ppa-fonts/blob/master/ppa/README.md
sudo add-apt-repository -s -y ppa:no1wantdthisname/ppa
# add chrome
# http://www.ubuntuupdates.org/ppa/google_chrome?dist=stable
# exact filename is important since they try to edit this file
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub |
sudo apt-key add -
echo 'deb http://dl.google.com/linux/chrome/deb/ stable main' |
sudo tee /etc/apt/sources.list.d/google-chrome.list > /dev/null
# add git
sudo add-apt-repository -s -y ppa:git-core/ppa
# add i386
sudo dpkg --add-architecture i386
# add mariadb
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 \
0xcbcb082a1bb943db
sudo add-apt-repository -s -y \
'deb http://mirror.jmu.edu/pub/mariadb/repo/10.0/ubuntu trusty main'
# add ocaml + opam
# https://launchpad.net/~avsm/+archive/ubuntu/ocaml42+opam12
sudo add-apt-repository -s -y ppa:avsm/ocaml42+opam12
# should update anyway (curl used to have problem if we don't update)
sudo apt-get update
# install Guest Additions early to enable screen resize and copy-and-paste
sudo apt-get install -y dkms
sudo sh /media/vagrant/VBOX*/VBoxLinuxAdditions.run
# antialias: install in this step since we need to re-login afterwards
sudo apt-get install -y fontconfig-infinality libfreetype6
sudo ln -sfT /etc/fonts/infinality/styles.conf.avail/win7 \
/etc/fonts/infinality/conf.d
sudo sed -ri 's/^(USE_STYLE)="DEFAULT"/\1="WINDOWS"/' \
/etc/profile.d/infinality-settings.sh
# bugfix: Fontconfig warning:
# "/etc/fonts/infinality/conf.d/41-repl-os-win.conf", line 148 and 160: Having
# multiple values in <test> isn't supported and may not work as expected
sudo sed -i '/<string>Bitstream Vera Sans<\/string>$/d' \
/etc/fonts/infinality/conf.d/41-repl-os-win.conf
# docker: install in this step since we need to reboot afterwards
# http://docs.docker.com/installation/ubuntulinux/
sudo apt-get install -y docker.io
sudo sed -ri 's/^(DEFAULT_FORWARD_POLICY)=.*/\1="ACCEPT"/' /etc/default/ufw
sudo sed -ri \
's/^(GRUB_CMDLINE_LINUX)=.*/\1="cgroup_enable=memory swapaccount=1"/' \
/etc/default/grub
# vagrant: do this after docker and vboxsf
echo 'root:vagrant' | sudo chpasswd
sudo usermod -a -G docker,root,sudo,vboxsf vagrant
sudo apt-get install -y ssh
sudo sed -i '$aUseDNS no' /etc/ssh/sshd_config
mkdir ~/.ssh
chmod 700 ~/.ssh
wget -q --no-check-certificate -O ~/.ssh/authorized_keys \
https://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub
chmod 600 ~/.ssh/authorized_keys
# /etc adjustments
sudo sed -ri 's/^(AVAHI_DAEMON_DETECT_LOCAL)=.*/\1=0/' /etc/default/avahi-daemon
sudo chmod g+w /etc/profile.d #vagrant provisioning
sudo mkdir /etc/skel/bin #everyone needs this directory
sudo sed -i '$aGRUB_RECORDFAIL_TIMEOUT=2' /etc/default/grub
sudo update-grub
# no more Guest Additions CD on desktop
while head -c 1 /dev/sr1 &> /dev/null; do
sudo eject -v /dev/sr1
done
rm -rf /media/vagrant/VBOX
# yay
echo
echo 'Shutdown VM and take Snapshot 1. Then run the next step.'
echo
rm -f 1.sh
history -cw