home · contact · privacy
9effbaa97eb471b8cd4f5785153d0d2bdf0c2b58
[config] / jessie_start_server.sh
1 #!/bin/sh
2 set -x
3 set -e
4
5 # Set root pw.
6 passwd
7
8 # Post-installation reduction.
9 dpkg-query -Wf '${Package} ${Priority}\n' | grep ' required' | sed 's/ required//' > list_white_unsorted 
10 echo 'ifupdown' >> list_white_unsorted 
11 echo 'isc-dhcp-client' >> list_white_unsorted
12 sort list_white_unsorted > list_white
13 dpkg-query -Wf '${Package}\n' > list_all_packages
14 sort list_all_packages > foo
15 mv foo list_all_packages
16 comm -3 list_all_packages list_white > list_black
17 apt-mark auto `cat list_black`
18 echo 'APT::AutoRemove::RecommendsImportant "false";' > /etc/apt/apt.conf.d/99mindeps
19 echo 'APT::AutoRemove::SuggestsImportant "false";' >> /etc/apt/apt.conf.d/99mindeps 
20 DEBIAN_FRONTEND=noninteractive apt-get -y --purge autoremove
21 rm list_all_packages list_white_unsorted list_white list_black 
22 echo 'APT::Install-Recommends "false";' >> /etc/apt/apt.conf.d/99mindeps
23 echo 'APT::Install-Suggests "false";' >> /etc/apt/apt.conf.d/99mindeps
24
25 # Set hostname and FQDN.
26 echo 'plomlompom' > /etc/hostname
27 hostname 'plomlompom'
28 echo '127.0.0.1 localhost' > /etc/hosts
29 ip=`hostname -I`
30 echo "$ip plomlompom.com plomlompom" >> /etc/hosts
31
32 # Call dhclient on startup.
33 cat > /etc/systemd/system/dhclient.service << EOF
34 [Unit]
35 Description=Ethernet connection
36
37 [Service]
38 ExecStart=/sbin/dhclient eth0
39
40 [Install]
41 WantedBy=multi-user.target
42 EOF
43 systemctl enable /etc/systemd/system/dhclient.service
44
45 # Package management config, system upgrade.
46 echo 'deb http://ftp.debian.org/debian/ jessie main contrib non-free' > /etc/apt/sources.list
47 echo 'deb http://security.debian.org/ jessie/updates main contrib non-free' >> /etc/apt/sources.list
48 echo 'deb http://ftp.debian.org/debian/ jessie-updates main contrib non-free' >> /etc/apt/sources.list
49 dhclient eth0
50 apt-get update
51 apt-get -y dist-upgrade
52
53 # Set up manuals.
54 apt-get -y install man-db manpages less
55
56 # Don't clear boot messages on start up.
57 sed -i 's/^TTYVTDisallocate=yes$/TTYVTDisallocate=no/g' /etc/systemd/system/getty.target.wants/getty\@tty1.service
58
59 # Set up timezone.
60 echo 'Europe/Berlin' > /etc/timezone
61 cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime
62
63 # Locale config.
64 apt-get -y install locales
65 echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen
66 locale-gen
67
68 # Clone git repository.
69 apt-get -y install ca-certificates
70 apt-get -y install git
71 git clone http://github.com/plomlompom/config
72 config/symlink.sh
73
74 # Add user. Remove old user's config/ if it exists.
75 useradd -m -s /bin/bash plom
76 rm -rf /home/plom/config
77 su - plom -c 'git clone http://github.com/plomlompom/config /home/plom/config'
78 su plom -c '/home/plom/config/symlink.sh server'
79
80 # Set up editor.
81 apt-get -y install vim
82 mkdir -p .vimbackups
83 su plom -c 'mkdir -p /home/plom/.vimbackups/'
84
85 # Set up ssh-guard.
86 apt-get -y install sshguard rsyslog
87
88 # Set up openssh-server.
89 apt-get -y install openssh-server
90
91 # Set up mail system.
92 su plom -c 'mkdir -p /home/plom/mail/'
93 su plom -c 'mkdir -p /home/plom/mail/inbox/{cur,new,tmp}'
94 su plom -c 'mkdir -p /home/plom/mail/new_inbox/{cur,new,tmp}'
95 sed -i 's/^delete = true$/delete = false/g' /home/plom/config/dotfiles_user_server/getmail/getmailrc
96 DEBIAN_FRONTEND=noninteractive apt-get -y install getmail4 procmail mutt postfix maildrop
97 cp config/systemfiles/main.cf /etc/postfix/main.cf
98 cp config/systemfiles/aliases /etc/aliases
99 newaliases
100 service postfix restart
101
102 # Set up regular system update reminder.
103 apt-get -y install cron
104 su plom -c "echo '0 18 * * 0 ~/config/bin/simplemail.sh ~/config/mails/update_reminder' | crontab -"
105
106 # Set up tmux.
107 apt-get -y install tmux
108
109 # Set up weechat, OTR, bitlbee.
110 apt-get -y install weechat-plugins python-potr bitlbee
111 cp config/systemfiles/weechat.service  /etc/systemd/system/weechat.service
112 systemctl enable /etc/systemd/system/weechat.service
113
114 # Set up screen.
115 #apt-get -y install screen
116 #
117 # Set up ping.
118 #apt-get -y install iputils-ping
119 #
120 # Set up irssi.
121 #apt-get -y install irssi
122 #cp config/systemfiles/irssi.service /etc/systemd/system/irssi.service
123 #systemctl enable /etc/systemd/system/irssi.service
124
125 # Clean up.
126 rm jessie_start_server.sh
127
128 # Send instructions mail.
129 config/bin/simplemail.sh config/mails/server_postinstall_finished
130
131 # Set password for user.
132 passwd plom
133
134 # Finalize everything with a reboot.
135 reboot