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 echo 'deb http://ftp.debian.org/debian/ testing main contrib non-free' >> /etc/apt/sources.list
69 echo 'deb http://security.debian.org/ testing/updates main contrib non-free' >> /etc/apt/sources.list
70 echo 'deb http://ftp.debian.org/debian/ testing-updates main contrib non-free' >> /etc/apt/sources.list
71 echo 'APT::Default-Release "stable";' >> /etc/apt/apt.conf.d/99defaultrelease
75 apt-get -y dist-upgrade
78 apt-get -y install man-db manpages less
80 if [ "$1" = "thinkpad" ]; then
81 # Power management as per <http://thinkwiki.de/TLP_-_Linux_Stromsparen>.
82 echo '' >> /etc/apt/sources.list
83 echo 'deb http://repo.linrunner.de/debian jessie main' \
84 >> /etc/apt/sources.list
85 apt-key adv --keyserver pool.sks-keyservers.net --recv-keys CD4E8809
87 apt-get -y install linux-headers-amd64 tlp tp-smapi-dkms
88 sed -i 's/^#START_CHARGE_THRESH_BAT0/START_CHARGE_THRESH_BAT0=10 '\
89 '#START_CHARGE_THRESH_BAT0/' /etc/default/tlp
90 sed -i 's/^#STOP_CHARGE_THRESH_BAT0/STOP_CHARGE_THRESH_BAT0=95 '\
91 '#STOP_CHARGE_THRESH_BAT0/' /etc/default/tlp
92 sed -i 's/^#DEVICES_TO_DISABLE_ON_STARTUP/DEVICES_TO_DISABLE_ON_STARTUP='\
93 '"bluetooth wifi wwan" #DEVICES_TO_DISABLE_ON_STARTUP/' /etc/default/tlp
97 # Don't clear boot messages on start up.
98 sed -i 's/^TTYVTDisallocate=yes$/TTYVTDisallocate=no/g' \
99 /etc/systemd/system/getty.target.wants/getty\@tty1.service
102 echo 'Europe/Berlin' > /etc/timezone
103 cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime
106 apt-get -y install locales
107 echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen
110 if [ "$1" = "thinkpad" ]; then
112 DEBIAN_FRONTEND=nointeractive apt-get -y install console-setup
113 echo 'ACTIVE_CONSOLES="/dev/tty[1-6]"' > /etc/default/console-setup
114 echo 'CHARMAP="UTF-8"' >> /etc/default/console-setup
115 echo 'CODESET="Lat15"' >> /etc/default/console-setup
116 echo 'FONTFACE="TerminusBold"' >> /etc/default/console-setup
117 echo 'FONTSIZE="8x16"' >> /etc/default/console-setup
118 echo 'export LC_ALL="en_US.UTF-8"' >> /etc/profile
119 sed -i 's/^XKBLAYOUT/XKBLAYOUT="de" # XKBLAYOUT/g' /etc/default/keyboard
120 service keyboard-setup restart
123 # Clone git repository.
124 apt-get -y install ca-certificates
125 apt-get -y install git
126 git clone http://github.com/plomlompom/config
127 config/bin/symlink.sh
129 # Add user. Remove old user's config/ if it exists.
130 useradd -m -s /bin/bash plom
131 rm -rf /home/plom/config
132 su - plom -c 'git clone http://github.com/plomlompom/config /home/plom/config'
133 su plom -c '/home/plom/config/bin/symlink.sh '$1
137 su plom -c 'mkdir -p /home/plom/.vimbackups/'
138 apt-get -y install vim
140 if [ "$1" = "server" ]; then
142 apt-get -y install sshguard rsyslog
144 # Set up openssh-server.
145 apt-get -y install openssh-server
147 # Set up mail system.
148 su plom -c 'mkdir -p /home/plom/mail/'
149 su plom -c 'mkdir -p /home/plom/mail/inbox/{cur,new,tmp}'
150 su plom -c 'mkdir -p /home/plom/mail/new_inbox/{cur,new,tmp}'
151 sed -i 's/^delete = true$/delete = false/g' \
152 /home/plom/config/dotfiles/user/server/getmail/getmailrc
153 DEBIAN_FRONTEND=noninteractive apt-get -y install getmail4 procmail mutt \
155 cp config/systemfiles/main.cf /etc/postfix/main.cf
156 cp config/systemfiles/aliases /etc/aliases
158 service postfix restart
160 # Set up regular system update reminder.
161 apt-get -y install cron
162 su plom -c "echo '0 18 * * 0 ~/config/bin/simplemail.sh '\
163 '~/config/mails/update_reminder' | crontab -"
165 # Set up screen/weechat/OTR/bitlbee. Make bitlbee listen only locally.
166 apt-get -y install screen weechat-plugins python-potr bitlbee
167 sed -i 's/^# DaemonInterface/DaemonInterface = 127.0.0.1 '\
168 '# DaemonInterface/' /etc/bitlbee/bitlbee.conf
169 sedtest=`grep -E '^DaemonInterface = 127.0.0.1 #' \
170 /etc/bitlbee/bitlbee.conf | wc -l | cut -d ' ' -f 1`
171 if [ 0 -eq $sedtest ]; then
174 cp config/systemfiles/weechat.service /etc/systemd/system/weechat.service
175 systemctl enable /etc/systemd/system/weechat.service
177 # Send instructions mail.
178 config/bin/simplemail.sh config/mails/server_postinstall_finished
180 elif [ "$1" = "thinkpad" ]; then
181 # Set up networking (wifi!).
182 apt-get -y install firmware-iwlwifi
183 DEBIAN_FRONTEND=noninteractive apt-get -y install wicd-curses
184 sed -i 's/^wired_interface = .*$/wired_interface = eth0/g' \
185 /etc/wicd/manager-settings.conf
186 sed -i 's/^wireless_interface = .*$/wireless_interface = wlan0/g' \
187 /etc/wicd/manager-settings.conf
188 systemctl restart wicd
190 # Set up hibernation on lid close.
191 echo 'HandleLidSwitch=hibernate' >> /etc/systemd/logind.conf
194 usermod -aG audio plom
195 apt-get -y install alsa-utils
196 if [ "$2" = "X200s" ]; then
197 amixer -c 0 sset Master playback 100% unmute
198 elif [ "$2" = "T450s" ]; then
199 amixer -c 1 sset Master playback 100% unmute
202 # Set up window system, i3, redshift.
203 apt-get -y install xserver-xorg xinit xterm i3 i3status dmenu redshift
205 # Set up OpenGL and hardware acceleration.
206 apt-get -y install libgl1-mesa-dri
207 apt-get -y install i965-va-driver
208 usermod -aG video plom
211 apt-get -y install x11-xserver-utils
213 # Set up pentadactyl.
214 apt-get -y install iceweasel
215 apt-get -y -t testing install xul-ext-pentadactyl
216 apt-get -y install vim-gtk
217 su plom -c 'mkdir -p /home/plom/downloads/'
219 # Set up openssh-client.
220 apt-get -y install openssh-client
223 # Set password for user.
227 rm jessie_postinstall.sh
229 # Finalize everything with a reboot.