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" ]; then
20 # Post-installation reduction.
21 dpkg-query -Wf '${Package} ${Priority}\n' | grep ' required' | sed \
22 's/ required//' > list_white_unsorted
23 echo 'ifupdown' >> list_white_unsorted
24 echo 'isc-dhcp-client' >> list_white_unsorted
25 sort list_white_unsorted > list_white
26 dpkg-query -Wf '${Package}\n' > list_all_packages
27 sort list_all_packages > foo
28 mv foo list_all_packages
29 comm -3 list_all_packages list_white > list_black
30 apt-mark auto `cat list_black`
31 echo 'APT::AutoRemove::RecommendsImportant "false";' > /etc/apt/apt.conf.d/99mindeps
32 echo 'APT::AutoRemove::SuggestsImportant "false";' >> /etc/apt/apt.conf.d/99mindeps
33 DEBIAN_FRONTEND=noninteractive apt-get -y --purge autoremove
34 rm list_all_packages list_white_unsorted list_white list_black
35 echo 'APT::Install-Recommends "false";' >> /etc/apt/apt.conf.d/99mindeps
36 echo 'APT::Install-Suggests "false";' >> /etc/apt/apt.conf.d/99mindeps
38 if [ "$1" = "server" ]; then
39 # Set hostname and FQDN.
40 echo 'plomlompom' > /etc/hostname
42 echo '127.0.0.1 localhost' > /etc/hosts
44 echo "$ip plomlompom.com plomlompom" >> /etc/hosts
46 # Call dhclient on startup.
47 cat > /etc/systemd/system/dhclient.service << EOF
49 Description=Ethernet connection
52 ExecStart=/sbin/dhclient eth0
55 WantedBy=multi-user.target
57 systemctl enable /etc/systemd/system/dhclient.service
60 # Package management config, system upgrade.
61 echo 'deb http://ftp.debian.org/debian/ jessie main contrib non-free' \
62 > /etc/apt/sources.list
63 echo 'deb http://security.debian.org/ jessie/updates main contrib non-free' \
64 >> /etc/apt/sources.list
65 echo 'deb http://ftp.debian.org/debian/ jessie-updates main contrib non-free' \
66 >> /etc/apt/sources.list
67 if [ "$1" = "thinkpad" ]; then
68 if [ "$2" = "T450s" ]; then
69 echo 'deb http://ftp.debian.org/debian/ jessie-backports main contrib' \
70 ' non-free' >> /etc/apt/sources.list
72 echo 'deb http://ftp.debian.org/debian/ testing main contrib non-free' \
73 >> /etc/apt/sources.list
74 echo 'deb http://security.debian.org/ testing/updates main contrib' \
75 ' non-free' >> /etc/apt/sources.list
76 echo 'deb http://ftp.debian.org/debian/ testing-updates main contrib' \
77 ' non-free' >> /etc/apt/sources.list
78 echo 'APT::Default-Release "stable";' \
79 >> /etc/apt/apt.conf.d/99defaultrelease
83 apt-get -y dist-upgrade
86 apt-get -y install man-db manpages less
88 if [ "$1" = "thinkpad" ]; then
89 # Power management as per <http://thinkwiki.de/TLP_-_Linux_Stromsparen>.
90 echo '' >> /etc/apt/sources.list
91 echo 'deb http://repo.linrunner.de/debian jessie main' \
92 >> /etc/apt/sources.list
93 apt-key adv --keyserver pool.sks-keyservers.net --recv-keys CD4E8809
95 apt-get -y install linux-headers-amd64 tlp tp-smapi-dkms
96 sed -i 's/^#START_CHARGE_THRESH_BAT0/START_CHARGE_THRESH_BAT0=10 '\
97 '#START_CHARGE_THRESH_BAT0/' /etc/default/tlp
98 sed -i 's/^#STOP_CHARGE_THRESH_BAT0/STOP_CHARGE_THRESH_BAT0=95 '\
99 '#STOP_CHARGE_THRESH_BAT0/' /etc/default/tlp
100 sed -i 's/^#DEVICES_TO_DISABLE_ON_STARTUP/DEVICES_TO_DISABLE_ON_STARTUP='\
101 '"bluetooth wifi wwan" #DEVICES_TO_DISABLE_ON_STARTUP/' /etc/default/tlp
105 # Don't clear boot messages on start up.
106 sed -i 's/^TTYVTDisallocate=yes$/TTYVTDisallocate=no/g' \
107 /etc/systemd/system/getty.target.wants/getty\@tty1.service
110 echo 'Europe/Berlin' > /etc/timezone
111 cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime
114 apt-get -y install locales
115 echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen
118 if [ "$1" = "thinkpad" ]; then
120 DEBIAN_FRONTEND=nointeractive apt-get -y install console-setup
121 echo 'ACTIVE_CONSOLES="/dev/tty[1-6]"' > /etc/default/console-setup
122 echo 'CHARMAP="UTF-8"' >> /etc/default/console-setup
123 echo 'CODESET="Lat15"' >> /etc/default/console-setup
124 echo 'FONTFACE="TerminusBold"' >> /etc/default/console-setup
125 echo 'FONTSIZE="8x16"' >> /etc/default/console-setup
126 echo 'export LC_ALL="en_US.UTF-8"' >> /etc/profile
127 sed -i 's/^XKBLAYOUT/XKBLAYOUT="de" # XKBLAYOUT/g' /etc/default/keyboard
128 service keyboard-setup restart
131 # Clone git repository.
132 apt-get -y install ca-certificates
133 apt-get -y install git
134 git clone http://github.com/plomlompom/config
135 config/bin/symlink.sh
137 # Add user. Remove old user's config/ if it exists.
138 useradd -m -s /bin/bash plom
139 rm -rf /home/plom/config
140 su - plom -c 'git clone http://github.com/plomlompom/config /home/plom/config'
141 su plom -c '/home/plom/config/bin/symlink.sh '$1
145 su plom -c 'mkdir -p /home/plom/.vimbackups/'
146 apt-get -y install vim
148 if [ "$1" = "server" ]; then
150 apt-get -y install sshguard rsyslog
152 # Set up openssh-server.
153 apt-get -y install openssh-server
155 # Set up mail system.
156 su plom -c 'mkdir -p /home/plom/mail/'
157 su plom -c 'mkdir -p /home/plom/mail/inbox/{cur,new,tmp}'
158 su plom -c 'mkdir -p /home/plom/mail/new_inbox/{cur,new,tmp}'
159 sed -i 's/^delete = true$/delete = false/g' \
160 /home/plom/config/dotfiles/user/server/getmail/getmailrc
161 DEBIAN_FRONTEND=noninteractive apt-get -y install getmail4 procmail mutt \
163 cp config/systemfiles/main.cf /etc/postfix/main.cf
164 cp config/systemfiles/aliases /etc/aliases
166 service postfix restart
168 # Set up regular system update reminder.
169 apt-get -y install cron
170 su plom -c "echo '0 18 * * 0 ~/config/bin/simplemail.sh '\
171 '~/config/mails/update_reminder' | crontab -"
173 # Set up screen/weechat/OTR/bitlbee. Make bitlbee listen only locally.
174 apt-get -y install screen weechat-plugins python-potr bitlbee
175 sed -i 's/^# DaemonInterface/DaemonInterface = 127.0.0.1 '\
176 '# DaemonInterface/' /etc/bitlbee/bitlbee.conf
177 sedtest=`grep -E '^DaemonInterface = 127.0.0.1 #' \
178 /etc/bitlbee/bitlbee.conf | wc -l | cut -d ' ' -f 1`
179 if [ 0 -eq $sedtest ]; then
182 cp config/systemfiles/weechat.service /etc/systemd/system/weechat.service
183 systemctl enable /etc/systemd/system/weechat.service
185 # Send instructions mail.
186 config/bin/simplemail.sh config/mails/server_postinstall_finished
188 elif [ "$1" = "thinkpad" ]; then
189 # Set up networking (wifi!).
190 apt-get -y install firmware-iwlwifi
191 DEBIAN_FRONTEND=noninteractive apt-get -y install wicd-curses
192 sed -i 's/^wired_interface = .*$/wired_interface = eth0/g' \
193 /etc/wicd/manager-settings.conf
194 sed -i 's/^wireless_interface = .*$/wireless_interface = wlan0/g' \
195 /etc/wicd/manager-settings.conf
196 systemctl restart wicd
198 # Set up hibernation on lid close.
199 echo 'HandleLidSwitch=hibernate' >> /etc/systemd/logind.conf
202 usermod -aG audio plom
203 apt-get -y install alsa-utils
204 if [ "$2" = "X200s" ]; then
205 amixer -c 0 sset Master playback 100% unmute
206 elif [ "$2" = "T450s" ]; then
207 amixer -c 1 sset Master playback 100% unmute
210 # Set up window system, i3, redshift.
211 apt-get -y install xserver-xorg xinit xterm i3 i3status dmenu redshift
213 # Set up OpenGL and hardware acceleration.
214 if [ "$1" = "X220s" ]; then
215 apt-get -y install libgl1-mesa-dri
216 apt-get -y install i965-va-driver
217 usermod -aG video plom
218 elif [ "$2" = "T450s" ]; then
219 apt-get -y -t jessie-backports install xserver-xorg-video-intel
223 apt-get -y install x11-xserver-utils
225 # Set up pentadactyl.
226 apt-get -y install iceweasel
227 apt-get -y -t testing install xul-ext-pentadactyl
228 apt-get -y install vim-gtk
229 su plom -c 'mkdir -p /home/plom/downloads/'
231 # Set up openssh-client.
232 apt-get -y install openssh-client
235 # Set password for user.
239 rm jessie_postinstall.sh
241 # Finalize everything with a reboot.