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