5 if [ ! "$1" = "thinkpad" ] && [ ! "$1" = "server" ]; then
10 if [ "$1" = "thinkpad" ] && [ ! "$2" = "X200s" ] && [ ! "$2" = "T450s" ]; then
11 echo "Need Thinkpad type."
15 if [ "$1" = "server" ] && [ ! "$2" = "plomlompom.com" ] && \
16 [ ! "$2" = "test.plomlompom.com" ]; then
17 echo "Need server type."
21 # Some important variables
22 if [ "$2" = "plomlompom.com" ]; then
24 elif [ "$2" = "test.plomlompom.com" ]; then
25 hostname="test.plomlompom"
26 elif [ "$2" = "X200s" ]; then
28 elif [ "$2" = "T450s" ]; then
32 if [ "$1" = "server" ]; then
37 # Post-installation reduction.
38 dpkg-query -Wf '${Package} ${Priority}\n' | grep ' required' | sed \
39 's/ required//' > list_white_unsorted
40 echo 'ifupdown' >> list_white_unsorted
41 echo 'isc-dhcp-client' >> list_white_unsorted
42 sort list_white_unsorted > list_white
43 dpkg-query -Wf '${Package}\n' > list_all_packages
44 sort list_all_packages > foo
45 mv foo list_all_packages
46 comm -3 list_all_packages list_white > list_black
47 apt-mark auto `cat list_black`
48 echo 'APT::AutoRemove::RecommendsImportant "false";' > /etc/apt/apt.conf.d/99mindeps
49 echo 'APT::AutoRemove::SuggestsImportant "false";' >> /etc/apt/apt.conf.d/99mindeps
50 DEBIAN_FRONTEND=noninteractive apt-get -y --purge autoremove
51 rm list_all_packages list_white_unsorted list_white list_black
52 echo 'APT::Install-Recommends "false";' >> /etc/apt/apt.conf.d/99mindeps
53 echo 'APT::Install-Suggests "false";' >> /etc/apt/apt.conf.d/99mindeps
55 # Set hostname and FQDN.
56 echo $hostname > /etc/hostname
58 if [ "$1" = "server" ]; then
59 echo '127.0.0.1 localhost' > /etc/hosts
60 ip=`hostname -I | cut -d " " -f 1`
61 echo "$ip $2 $hostname" >> /etc/hosts
63 # Call dhclient on startup.
64 cat > /etc/systemd/system/dhclient.service << EOF
66 Description=Ethernet connection
69 ExecStart=/sbin/dhclient eth0
72 WantedBy=multi-user.target
74 systemctl enable /etc/systemd/system/dhclient.service
77 # Package management config, system upgrade.
78 echo 'deb http://ftp.debian.org/debian/ jessie main contrib non-free' \
79 > /etc/apt/sources.list
80 echo 'deb http://security.debian.org/ jessie/updates main contrib non-free' \
81 >> /etc/apt/sources.list
82 echo 'deb http://ftp.debian.org/debian/ jessie-updates main contrib non-free' \
83 >> /etc/apt/sources.list
84 if [ "$1" = "thinkpad" ]; then
85 echo 'deb http://ftp.debian.org/debian/ jessie-backports main contrib' \
86 ' non-free' >> /etc/apt/sources.list
87 echo 'deb http://ftp.debian.org/debian/ testing main contrib non-free' \
88 >> /etc/apt/sources.list
89 echo 'deb http://security.debian.org/ testing/updates main contrib' \
90 ' non-free' >> /etc/apt/sources.list
91 echo 'deb http://ftp.debian.org/debian/ testing-updates main contrib' \
92 ' non-free' >> /etc/apt/sources.list
93 echo 'APT::Default-Release "stable";' \
94 >> /etc/apt/apt.conf.d/99defaultrelease
98 apt-get -y dist-upgrade
101 apt-get -y install man-db manpages less
103 if [ "$1" = "thinkpad" ]; then
104 # Power management as per <http://thinkwiki.de/TLP_-_Linux_Stromsparen>.
105 echo '' >> /etc/apt/sources.list
106 echo 'deb http://repo.linrunner.de/debian jessie main' \
107 >> /etc/apt/sources.list
108 apt-key adv --keyserver pool.sks-keyservers.net --recv-keys CD4E8809
110 apt-get -y install linux-headers-amd64 tlp tp-smapi-dkms
111 sed -i 's/^#START_CHARGE_THRESH_BAT0/START_CHARGE_THRESH_BAT0=10 '\
112 '#START_CHARGE_THRESH_BAT0/' /etc/default/tlp
113 sed -i 's/^#STOP_CHARGE_THRESH_BAT0/STOP_CHARGE_THRESH_BAT0=95 '\
114 '#STOP_CHARGE_THRESH_BAT0/' /etc/default/tlp
115 sed -i 's/^#DEVICES_TO_DISABLE_ON_STARTUP/DEVICES_TO_DISABLE_ON_STARTUP='\
116 '"bluetooth wifi wwan" #DEVICES_TO_DISABLE_ON_STARTUP/' /etc/default/tlp
120 # Don't clear boot messages on start up.
121 sed -i 's/^TTYVTDisallocate=yes$/TTYVTDisallocate=no/g' \
122 /etc/systemd/system/getty.target.wants/getty\@tty1.service
125 echo 'Europe/Berlin' > /etc/timezone
126 cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime
129 apt-get -y install locales
130 echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen
133 if [ "$1" = "thinkpad" ]; then
135 DEBIAN_FRONTEND=nointeractive apt-get -y install console-setup
136 echo 'ACTIVE_CONSOLES="/dev/tty[1-6]"' > /etc/default/console-setup
137 echo 'CHARMAP="UTF-8"' >> /etc/default/console-setup
138 echo 'CODESET="Lat15"' >> /etc/default/console-setup
139 echo 'FONTFACE="TerminusBold"' >> /etc/default/console-setup
140 echo 'FONTSIZE="8x16"' >> /etc/default/console-setup
141 echo 'export LC_ALL="en_US.UTF-8"' >> /etc/profile
142 sed -i 's/^XKBLAYOUT/XKBLAYOUT="de" # XKBLAYOUT/g' /etc/default/keyboard
143 service keyboard-setup restart
146 # Clone git repository.
147 apt-get -y install ca-certificates
148 apt-get -y install git
149 git clone http://github.com/plomlompom/config
150 config/bin/symlink.sh
152 # Add user. Remove old user's config/ if it exists.
153 useradd -m -s /bin/bash plom
154 rm -rf /home/plom/config
155 su - plom -c 'git clone http://github.com/plomlompom/config /home/plom/config'
156 su plom -c '/home/plom/config/bin/symlink.sh '$1' '$2
158 # Allow user to sudo.
159 if [ "$1" = "thinkpad" ]; then
160 apt-get -y install sudo
166 su plom -c 'mkdir -p /home/plom/.vimbackups/'
167 apt-get -y install vim
169 if [ "$1" = "server" ]; then
171 apt-get -y install sshguard rsyslog
173 # Set up openssh-server.
174 apt-get -y install openssh-server
176 # Set up mail system.
177 su plom -c 'mkdir -p /home/plom/mail/'
178 su plom -c 'mkdir -p /home/plom/mail/inbox/{cur,new,tmp}'
179 su plom -c 'mkdir -p /home/plom/mail/new_inbox/{cur,new,tmp}'
180 sed -i 's/^delete = true$/delete = false/g' \
181 /home/plom/config/dotfiles/user/server/getmail/getmailrc
182 DEBIAN_FRONTEND=noninteractive apt-get -y install getmail4 procmail mutt \
184 cp config/systemfiles/main.cf /etc/postfix/main.cf
185 sed -i 's/HOSTNAME/'$2'/g' /etc/postfix/main.cf
186 cp config/systemfiles/aliases /etc/aliases
188 service postfix restart
190 # Set up regular system update reminder.
191 apt-get -y install cron
192 su plom -c "echo '0 18 * * 0 ~/config/bin/simplemail.sh '\
193 '~/config/mails/update_reminder' | crontab -"
195 # Set up screen/weechat/OTR/bitlbee. Make bitlbee listen only locally.
196 apt-get -y install screen weechat-plugins python-potr bitlbee
197 sed -i 's/^# DaemonInterface/DaemonInterface = 127.0.0.1 '\
198 '# DaemonInterface/' /etc/bitlbee/bitlbee.conf
199 sedtest=`grep -E '^DaemonInterface = 127.0.0.1 #' \
200 /etc/bitlbee/bitlbee.conf | wc -l | cut -d ' ' -f 1`
201 if [ 0 -eq $sedtest ]; then
204 cp config/systemfiles/weechat.service /etc/systemd/system/weechat.service
205 systemctl enable /etc/systemd/system/weechat.service
207 # Send instructions mail.
208 config/bin/simplemail.sh config/mails/server_postinstall_finished
210 elif [ "$1" = "thinkpad" ]; then
211 # Set up networking (wifi!).
212 apt-get -y install firmware-iwlwifi
213 DEBIAN_FRONTEND=noninteractive apt-get -y install wicd-curses
214 sed -i 's/^wired_interface = .*$/wired_interface = eth0/g' \
215 /etc/wicd/manager-settings.conf
216 sed -i 's/^wireless_interface = .*$/wireless_interface = wlan0/g' \
217 /etc/wicd/manager-settings.conf
218 systemctl restart wicd
220 # Set up hibernation on lid close.
221 echo 'HandleLidSwitch=hibernate' >> /etc/systemd/logind.conf
224 usermod -aG audio plom
225 apt-get -y install alsa-utils
226 if [ "$2" = "X200s" ]; then
227 amixer -c 0 sset Master playback 100% unmute
228 elif [ "$2" = "T450s" ]; then
229 amixer -c 1 sset Master playback 100% unmute
230 # Re-order souncards so the commonly used one is the first one.
231 echo 'options snd_hda_intel index=1,0' >> /etc/modprobe.d/sound.conf
234 # Set up window system, i3, redshift.
235 apt-get -y install xserver-xorg xinit xterm i3 i3status dmenu redshift
237 # Set up OpenGL and hardware acceleration.
238 if [ "$2" = "X200s" ]; then
239 apt-get -y install i965-va-driver
240 elif [ "$2" = "T450s" ]; then
241 apt-get -y -t jessie-backports install xserver-xorg-video-intel
243 apt-get -y install libgl1-mesa-dri
244 usermod -aG video plom
247 apt-get -y install x11-xserver-utils
249 # Set up pentadactyl.
250 apt-get -y install iceweasel
251 apt-get -y -t jessie-backports install xul-ext-pentadactyl
252 apt-get -y install vim-gtk
253 su plom -c 'mkdir -p /home/plom/downloads/'
255 # Set up openssh-client.
256 apt-get -y install openssh-client
259 # Set password for user.
263 rm jessie_postinstall.sh
265 # Finalize everything with a reboot.