2017-06-23 10:17:08 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-06-25 20:49:10 +02:00
|
|
|
SOURCE_DIR=$(realpath $(dirname "${0}"))
|
|
|
|
|
2017-06-23 10:17:08 +02:00
|
|
|
# Uninstall unnecessary packages
|
2017-06-25 20:49:10 +02:00
|
|
|
apt-get -y purge bsdmainutils dictionaries-common emacsen-common gnupg gnupg-agent iamerican ibritish ienglish-common installation-report ispell laptop-detect nano os-prober pinentry-curses task-english tasksel tasksel-data wamerican
|
|
|
|
|
|
|
|
# Install useful packages
|
2017-06-30 18:05:48 +02:00
|
|
|
apt-get -y --no-install-recommends install bash-completion ca-certificates git ntp openssl sudo unzip
|
2017-06-25 20:49:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
######
|
2017-06-30 18:05:48 +02:00
|
|
|
# OpenSSH and user settings
|
2017-06-25 20:49:10 +02:00
|
|
|
#####
|
2017-06-23 10:17:08 +02:00
|
|
|
|
2017-06-23 16:03:19 +02:00
|
|
|
# Install OpenSSH server
|
2017-06-25 20:49:10 +02:00
|
|
|
apt-get -y --no-install-recommends install openssh-server
|
2017-06-23 11:01:08 +02:00
|
|
|
|
2017-06-29 11:38:48 +02:00
|
|
|
# Copy profile files
|
|
|
|
cp ${SOURCE_DIR}/basic/root/.bashrc /root/.bashrc
|
2017-06-25 20:49:10 +02:00
|
|
|
cp ${SOURCE_DIR}/basic/root/.ssh/authorized_keys /root/.ssh/authorized_keys
|
|
|
|
|
2017-06-30 18:05:48 +02:00
|
|
|
# Remove default user
|
|
|
|
deluser --remove-all-files user 2>/dev/null
|
2017-06-25 20:49:10 +02:00
|
|
|
|
|
|
|
#####
|
|
|
|
# System boot
|
|
|
|
#####
|
2017-06-23 11:01:08 +02:00
|
|
|
|
2017-06-23 10:24:16 +02:00
|
|
|
# Rename encrypted partition
|
|
|
|
sed -i 's/sda2_crypt/system/' /etc/crypttab
|
|
|
|
dmsetup rename sda2_crypt system
|
|
|
|
|
2017-06-23 16:09:10 +02:00
|
|
|
# Suppress warnings during boot
|
2017-06-25 20:49:10 +02:00
|
|
|
cp ${SOURCE_DIR}/basic/usr/share/initramfs-tools/scripts/local-top/lvm2 /usr/share/initramfs-tools/scripts/local-top/lvm2
|
|
|
|
cp ${SOURCE_DIR}/basic/usr/share/initramfs-tools/scripts/local-top/cryptroot /usr/share/initramfs-tools/scripts/local-top/cryptroot
|
2017-06-23 16:03:19 +02:00
|
|
|
|
|
|
|
# Set GRUB options
|
2017-06-25 20:49:10 +02:00
|
|
|
cp ${SOURCE_DIR}/basic/etc/default/grub /etc/default/grub
|
2017-06-23 10:32:56 +02:00
|
|
|
|
2017-06-23 10:35:14 +02:00
|
|
|
# Set legal banner with URL + latin2 character set
|
2017-06-25 20:49:10 +02:00
|
|
|
cp ${SOURCE_DIR}/basic/etc/default/console-setup /etc/default/console-setup
|
|
|
|
cp ${SOURCE_DIR}/basic/etc/issue /etc/issue
|
2017-06-23 10:37:25 +02:00
|
|
|
|
|
|
|
# Forbid login on tty1, disable tty2-6
|
2017-06-25 20:49:10 +02:00
|
|
|
cp ${SOURCE_DIR}/basic/lib/systemd/system/getty@.service /lib/systemd/system/getty@.service
|
2017-06-23 10:37:25 +02:00
|
|
|
systemctl mask getty-static
|
2017-06-25 20:49:10 +02:00
|
|
|
|
|
|
|
# Update initramfs and GRUB
|
|
|
|
update-initramfs -u
|
|
|
|
update-grub
|
|
|
|
|
|
|
|
|
|
|
|
#####
|
|
|
|
# Nginx + uWSGI
|
|
|
|
#####
|
|
|
|
|
|
|
|
# Install packages
|
|
|
|
apt-get -y --no-install-recommends install nginx-light uwsgi uwsgi-plugin-python
|
|
|
|
|
|
|
|
# Create a self-signed certificate
|
|
|
|
openssl req -x509 -new -out /etc/ssl/certs/services.pem -keyout /etc/ssl/private/services.key -nodes -days 3654 -subj "/C=CZ/CN=$(hostname -f)"
|
|
|
|
chmod 640 /etc/ssl/private/services.key
|
|
|
|
|
2017-06-26 15:17:55 +02:00
|
|
|
# Create Diffie-Hellman param
|
|
|
|
openssl dhparam -out /etc/ssl/dhparam.pem 2048
|
|
|
|
chmod 640 /etc/ssl/dhparam.pem
|
|
|
|
|
2017-06-25 20:49:10 +02:00
|
|
|
# Modify default nginx site
|
|
|
|
mkdir /etc/nginx/apps-available /etc/nginx/apps-enabled
|
|
|
|
mkdir /srv/portal
|
|
|
|
cp ${SOURCE_DIR}/basic/etc/nginx/sites-available/default /etc/nginx/sites-available/default
|
|
|
|
cp ${SOURCE_DIR}/basic/srv/portal/index.html /srv/portal/index.html
|
|
|
|
chown -R www-data:www-data /srv/portal
|
|
|
|
|
|
|
|
# Restart
|
|
|
|
systemctl restart nginx
|
|
|
|
|
|
|
|
|
|
|
|
#####
|
|
|
|
# PostgreSQL + PostGIS
|
|
|
|
#####
|
|
|
|
|
|
|
|
# Install packages
|
|
|
|
apt-get -y --no-install-recommends -y install postgresql-9.6 postgresql-9.6-postgis
|
|
|
|
|
|
|
|
# Configure
|
|
|
|
cp ${SOURCE_DIR}/basic/etc/postgresql/9.6/main/postgresql.conf /etc/postgresql/9.6/main/postgresql.conf
|
|
|
|
cp ${SOURCE_DIR}/basic/etc/postgresql/9.6/main/pg_hba.conf /etc/postgresql/9.6/main/pg_hba.conf
|
|
|
|
|
|
|
|
# Restart
|
|
|
|
systemctl restart postgresql
|