fix background statement
[omsmith/bootstrap.git] / bootstrap.sh
1 #!/usr/bin/env bash
2
3 function pause() {
4     read -n1 -s -p "$1"
5 }
6
7 echo bootstrapping machine...
8
9 grep 'http://mirror' /etc/apt/sources.list > /dev/null \
10      || pause "Update /etc/apt/sources.list to use mirror before continuing..."
11
12 # some packages used for initial setup
13 apt-get update
14 apt-get install sed curl
15
16 DIST=`lsb_release -si`
17 DISTVERSION=`lsb_release -sc`
18
19 # we'll be adding emdebian repo if we're on debian
20 if [[ $DIST = "Debian" ]] ; then
21     apt-get install emdebian-archive-keyring
22     cp ./templates/emdebian.list > /etc/apt/sources.list.d/emdebian.list
23 fi
24
25 # add csclub repo
26 sed "s/<distribution>/$DISTVERSION/" < ./templates/csclub.list > /etc/apt/sources.list.d/csclub.list
27 curl -s http://debian.csclub.uwaterloo.ca/csclub.asc | apt-key add -
28
29 # add google-chrome ppa
30 echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
31 curl -s https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
32
33 # lets get inapt going
34 apt-get install inapt
35
36 pause "Verify node is correct in pacakges/nodes.ia before continuing..."
37 inapt packages/*.ia
38
39 # network
40 read -p "ip? 129.97.134." IP_SUFFIX
41 sed "s/_IP_SUFFIX/$IP_SUFFIX/" < ./templates/interfaces > /etc/network/interfaces
42
43 # nsswitch
44 cp ./templates/nsswitch.conf /etc/nsswitch.conf
45
46 # ldap
47 cp ./templates/ldap.conf /etc/ldap/ldap.conf
48 if [[ $DIST = "Debian" ]] ; then
49         ln -s /etc/ldap/ldap.conf /etc/sudo-ldap.conf
50 fi
51
52 # nslcd
53 cp ./templates/nslcd.conf /etc/nslcd.conf
54
55 # krb5
56 cp ./templates/krb5.conf /etc/krb5.conf
57
58 # pam.d
59 cp ./templates/common-account /etc/pam.d/common-account
60
61 # nfs
62 cp ./templates/nfs-common /etc/default/nfs-common
63
64 # ssh
65 cp ./templates/ssh_config /etc/ssh/ssh_config
66 cp ./templates/sshd_config /etc/ssh/sshd_config
67
68 echo "prompts for root on caffeine..."
69 scp root@caffeine.csclub.uwaterloo.ca:/etc/ssh/ssh_known_hosts /etc/ssh
70 scp root@caffeine.csclub.uwaterloo.ca:/etc/hosts /etc
71 scp root@caffeine.csclub.uwaterloo.ca:/etc/ssl/certs/GlobalSign_Intermediate_Root.pem /etc/ssl/certs
72
73 # mounts
74 mkdir /music /scratch /users
75 cat ./templates/fstab >> /etc/fstab
76
77 # root sso
78 cp ./templates/.k5login /root/.k5login
79
80 read -p "Is this an office terminal? " -n 1 -r
81 if [[ $REPLY =~ ^[Yy]$ ]]
82 then
83     # xscreensaver kills machines, redirect to gnome-screensaver
84     cp ./templates/xscreensaver-command /usr/local/bin/xscreensaver-command
85
86     # ncmpc -> nullsleep
87     cp ./templates/ncmpc /usr/local/bin/ncmpc
88
89         # gnome keyring fix
90         rm /etc/pkcs11/modules/gnome-keyring.module
91
92     # lightdm
93     cp ./templates/lightdm.conf /etc/lightdm/lightdm.conf
94     cp ./templates/users.conf /etc/lightdm/users.conf
95
96     # set novelty background
97     cp -r ./templates/backgrounds /usr/local/share
98         sudo -u lightdm dbus-launch gsettings set com.canonical.unity-greeter background /usr/local/share/backgrounds/current.jpg
99 fi
100
101 echo bootstrapping complete
102 echo generate or copy the krb5.keytab for this machine and put it in /etc/krb5.keytab
103 echo verify configuration and then reboot
104