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" ]; then
25 hostname="test.plomlompom.com"
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
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
160 su plom -c 'mkdir -p /home/plom/.vimbackups/'
161 apt-get -y install vim
163 if [ "$1" = "server" ]; then
165 apt-get -y install sshguard rsyslog
167 # Set up openssh-server.
168 apt-get -y install openssh-server
170 # Set up mail system.
171 su plom -c 'mkdir -p /home/plom/mail/'
172 su plom -c 'mkdir -p /home/plom/mail/inbox/{cur,new,tmp}'
173 su plom -c 'mkdir -p /home/plom/mail/new_inbox/{cur,new,tmp}'
174 sed -i 's/^delete = true$/delete = false/g' \
175 /home/plom/config/dotfiles/user/server/getmail/getmailrc
176 DEBIAN_FRONTEND=noninteractive apt-get -y install getmail4 procmail mutt \
178 cp config/systemfiles/main.cf /etc/postfix/main.cf
179 cp config/systemfiles/aliases /etc/aliases
181 service postfix restart
183 # Set up regular system update reminder.
184 apt-get -y install cron
185 su plom -c "echo '0 18 * * 0 ~/config/bin/simplemail.sh '\
186 '~/config/mails/update_reminder' | crontab -"
188 # Set up screen/weechat/OTR/bitlbee. Make bitlbee listen only locally.
189 apt-get -y install screen weechat-plugins python-potr bitlbee
190 sed -i 's/^# DaemonInterface/DaemonInterface = 127.0.0.1 '\
191 '# DaemonInterface/' /etc/bitlbee/bitlbee.conf
192 sedtest=`grep -E '^DaemonInterface = 127.0.0.1 #' \
193 /etc/bitlbee/bitlbee.conf | wc -l | cut -d ' ' -f 1`
194 if [ 0 -eq $sedtest ]; then
197 cp config/systemfiles/weechat.service /etc/systemd/system/weechat.service
198 systemctl enable /etc/systemd/system/weechat.service
200 # Send instructions mail.
201 config/bin/simplemail.sh config/mails/server_postinstall_finished
203 elif [ "$1" = "thinkpad" ]; then
204 # Set up networking (wifi!).
205 apt-get -y install firmware-iwlwifi
206 DEBIAN_FRONTEND=noninteractive apt-get -y install wicd-curses
207 sed -i 's/^wired_interface = .*$/wired_interface = eth0/g' \
208 /etc/wicd/manager-settings.conf
209 sed -i 's/^wireless_interface = .*$/wireless_interface = wlan0/g' \
210 /etc/wicd/manager-settings.conf
211 systemctl restart wicd
213 # Set up hibernation on lid close.
214 echo 'HandleLidSwitch=hibernate' >> /etc/systemd/logind.conf
217 usermod -aG audio plom
218 apt-get -y install alsa-utils
219 if [ "$2" = "X200s" ]; then
220 amixer -c 0 sset Master playback 100% unmute
221 elif [ "$2" = "T450s" ]; then
222 amixer -c 1 sset Master playback 100% unmute
223 # Re-order souncards so the commonly used one is the first one.
224 echo 'options snd_hda_intel index=1,0' >> /etc/modprobe.d/sound.conf
227 # Set up window system, i3, redshift.
228 apt-get -y install xserver-xorg xinit xterm i3 i3status dmenu redshift
230 # Set up OpenGL and hardware acceleration.
231 if [ "$2" = "X200s" ]; then
232 apt-get -y install i965-va-driver
233 elif [ "$2" = "T450s" ]; then
234 apt-get -y -t jessie-backports install xserver-xorg-video-intel
236 apt-get -y install libgl1-mesa-dri
237 usermod -aG video plom
240 apt-get -y install x11-xserver-utils
242 # Set up pentadactyl.
243 apt-get -y install iceweasel
244 apt-get -y -t jessie-backports install xul-ext-pentadactyl
245 apt-get -y install vim-gtk
246 su plom -c 'mkdir -p /home/plom/downloads/'
248 # Set up openssh-client.
249 apt-get -y install openssh-client
252 # Set password for user.
256 rm jessie_postinstall.sh
258 # Finalize everything with a reboot.