2015-04-01 16:24:07 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2018-01-30 17:55:49 +01:00
|
|
|
APT_CONF_INCLUDE_SRC="$(dirname $0)/stretch/etc/apt/apt.conf.d/"
|
2018-01-30 17:18:47 +01:00
|
|
|
APT_CONF_INCLUDE_PATH="/etc/apt/apt.conf.d/"
|
|
|
|
|
2018-01-30 16:59:36 +01:00
|
|
|
RSYSLOGD_CONF_SRC="$(dirname $0)/stretch/etc/rsyslog.conf"
|
|
|
|
RSYSLOGD_CONF_PATH="/etc/rsyslog.conf"
|
2018-01-30 17:55:49 +01:00
|
|
|
RSYSLOGD_INCLUDE_SRC="$(dirname $0)/stretch/etc/rsyslog.d/"
|
2018-01-30 16:59:36 +01:00
|
|
|
RSYSLOGD_INCLUDE_PATH="/etc/rsyslog.d/"
|
2015-04-01 16:24:07 +02:00
|
|
|
|
2018-01-30 17:04:28 +01:00
|
|
|
LOGROTATE_CONF_SRC="$(dirname $0)/stretch/etc/logrotate.conf"
|
|
|
|
LOGROTATE_CONF_PATH="/etc/logrotate.conf"
|
2018-01-30 17:55:49 +01:00
|
|
|
LOGROTATE_INCLUDE_SRC="$(dirname $0)/stretch/etc/logrotate.d/"
|
2018-01-30 17:04:28 +01:00
|
|
|
LOGROTATE_INCLUDE_PATH="/etc/logrotate.d/"
|
2015-04-01 16:24:07 +02:00
|
|
|
|
2018-01-30 17:18:47 +01:00
|
|
|
# apt configuration {{{
|
|
|
|
|
|
|
|
# ensure to have some default configuration for Apt
|
2018-01-30 17:55:49 +01:00
|
|
|
cp -- "${APT_CONF_INCLUDE_SRC}"* "${APT_CONF_INCLUDE_PATH}"
|
2018-01-30 17:18:47 +01:00
|
|
|
|
|
|
|
# }}}
|
|
|
|
|
2017-12-06 15:52:51 +01:00
|
|
|
## Packages {{{
|
2018-01-30 17:18:47 +01:00
|
|
|
|
|
|
|
# update repositories and packages
|
|
|
|
apt update
|
|
|
|
apt -y full-upgrade
|
|
|
|
|
2017-12-06 15:52:51 +01:00
|
|
|
# Ensure to have some basic packages
|
2021-05-27 07:59:18 +02:00
|
|
|
apt -y install aptitude tmux vim-nox zsh
|
|
|
|
|
|
|
|
# Ensure to remove some "too"-basic packages
|
|
|
|
aptitude -y remove vim-tiny
|
|
|
|
|
2017-12-06 15:52:51 +01:00
|
|
|
|
2018-02-15 19:03:12 +01:00
|
|
|
# Ensure to have some systemd basic packages
|
|
|
|
aptitude -y install dbus libpam-systemd
|
|
|
|
|
2017-12-06 15:52:51 +01:00
|
|
|
# Remove NFS and rpcbind
|
|
|
|
aptitude -y remove nfs-common rpcbind
|
|
|
|
|
2017-12-08 16:17:05 +01:00
|
|
|
### Documentation {{{
|
2019-03-05 19:07:19 +01:00
|
|
|
# If no X display is expected
|
|
|
|
if [ ! "$(dpkg -l xorg)" ]; then
|
|
|
|
## Remove unwanted x11 lib
|
|
|
|
aptitude -y remove libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxmuu1 xauth
|
|
|
|
if [ "$(dpkg -l task-english)" ]; then
|
|
|
|
## Remove task-english
|
|
|
|
aptitude -y remove task-english iamerican ibritish ienglish-common ispell util-linux-locales wamerican
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ "$(dpkg -l task-english)" ]; then
|
|
|
|
## Remove task-english
|
|
|
|
aptitude -y remove task-english
|
|
|
|
fi
|
2017-12-08 16:18:17 +01:00
|
|
|
fi
|
|
|
|
|
2017-12-08 16:20:39 +01:00
|
|
|
# Ensure to have minimal documentation
|
|
|
|
aptitude -y install man-db manpages
|
|
|
|
|
2017-12-08 16:17:05 +01:00
|
|
|
### }}}
|
|
|
|
|
2017-12-08 16:06:42 +01:00
|
|
|
### SSH {{{
|
|
|
|
# Remove task-ssh-server
|
|
|
|
if [ "$(dpkg -l task-ssh-server)" ]; then
|
|
|
|
aptitude -y remove task-ssh-server
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Ensure to install openssh-server
|
2017-12-06 15:52:51 +01:00
|
|
|
aptitude -y install openssh-server openssh-sftp-server
|
|
|
|
|
2017-12-08 16:06:42 +01:00
|
|
|
### }}}
|
|
|
|
|
2017-12-06 15:52:51 +01:00
|
|
|
# Ansible dependencies
|
|
|
|
aptitude -y install python-apt
|
|
|
|
|
2018-01-02 12:25:18 +01:00
|
|
|
### Tasksel {{{
|
|
|
|
# If tasksel and tasksel-data are the only task* relative packages
|
2018-02-15 19:03:12 +01:00
|
|
|
if [ "$(dpkg -l | grep -c task)" -eq "2" ]; then
|
2018-01-02 12:25:18 +01:00
|
|
|
aptitude -y remove tasksel tasksel-data
|
|
|
|
fi
|
|
|
|
|
2018-02-15 19:03:12 +01:00
|
|
|
# purge configuration files
|
|
|
|
aptitude -y purge '~c'
|
|
|
|
|
2018-01-02 12:25:18 +01:00
|
|
|
### }}}
|
|
|
|
|
2017-12-06 15:52:51 +01:00
|
|
|
## }}}
|
|
|
|
|
2019-03-08 09:07:14 +01:00
|
|
|
# Grub {{{
|
|
|
|
|
|
|
|
## If EFI directory is present
|
|
|
|
EFI_PATH="/boot/efi"
|
|
|
|
if [ -d "${EFI_PATH}" ]; then
|
|
|
|
## Install grub-efi
|
|
|
|
aptitude install -y grub-efi-amd64
|
|
|
|
## Get grub device (keep only some patterns, eg. /dev/sda, /dev/vda, /dev/nvme0n1,…)
|
|
|
|
GRUB_DEVICE=$(sed -n "s;^\(/dev/[a-z]\{3\}\|/dev/nvme[a-z0-9]\{3\}\)\(p[0-9]\|[0-9]\) ${EFI_PATH} .*;\1;p" /etc/mtab)
|
|
|
|
grub-install --target=x86_64-efi "${GRUB_DEVICE}" 2>/dev/null
|
|
|
|
if [ -d "${EFI_PATH}"/EFI ]; then
|
|
|
|
## Copy efi entries to a boot directory
|
|
|
|
mkdir -p -- "${EFI_PATH}"/EFI/boot
|
|
|
|
find "${EFI_PATH}"/EFI/grub -type f -iname "grubx64.efi" -exec cp {} "${EFI_PATH}"/EFI/boot/bootx64.efi \; -quit 2>/dev/null
|
|
|
|
find "${EFI_PATH}"/EFI/debian -type f -iname "grubx64.efi" -exec cp {} "${EFI_PATH}"/EFI/boot/bootx64.efi \; -quit
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
### }}}
|
|
|
|
|
2017-12-06 15:52:51 +01:00
|
|
|
### Rsyslog {{{
|
2015-04-01 16:24:07 +02:00
|
|
|
|
|
|
|
# Install new Rsyslog configuration
|
2018-01-30 16:59:36 +01:00
|
|
|
if [ -f "${RSYSLOGD_CONF_PATH}" ]; then
|
|
|
|
cp "${RSYSLOGD_CONF_SRC}" "${RSYSLOGD_CONF_PATH}"
|
2015-04-01 16:24:07 +02:00
|
|
|
fi
|
2018-01-30 17:55:49 +01:00
|
|
|
cp -- "${RSYSLOGD_INCLUDE_SRC}"* "${RSYSLOGD_INCLUDE_PATH}"
|
2015-04-01 16:24:07 +02:00
|
|
|
|
|
|
|
# Restart Rsyslog service
|
2017-09-06 10:22:14 +02:00
|
|
|
systemctl restart rsyslog
|
2015-04-01 16:24:07 +02:00
|
|
|
|
2017-12-06 15:52:51 +01:00
|
|
|
### }}}
|
2017-08-20 15:51:14 +02:00
|
|
|
### Logrotate {{{
|
2015-04-01 16:24:07 +02:00
|
|
|
|
|
|
|
# Install new Logrotate configuration
|
2018-01-30 17:04:28 +01:00
|
|
|
if [ -f "${LOGROTATE_CONF_PATH}" ]; then
|
|
|
|
cp "${LOGROTATE_CONF_SRC}" "${LOGROTATE_CONF_PATH}"
|
2015-04-01 16:24:07 +02:00
|
|
|
fi
|
2018-01-30 17:55:49 +01:00
|
|
|
cp -- "${LOGROTATE_INCLUDE_SRC}"* "${LOGROTATE_INCLUDE_PATH}"
|
2015-04-01 16:24:07 +02:00
|
|
|
|
2017-08-20 16:07:26 +02:00
|
|
|
# Create an archive directory for some log files (aptitude, dpkg,…)
|
2018-01-30 16:48:12 +01:00
|
|
|
mkdir -p -- /var/log/old_logs.d /var/log/aptitude.d /var/log/dpkg.d /var/log/alternatives.d /var/log/syslog.d /var/log/cron.d /var/log/daemon.d /var/log/kern.d /var/log/lpr.d /var/log/mail.d /var/log/auth.d /var/log/messages.d
|
2017-09-05 17:04:52 +02:00
|
|
|
|
2018-01-30 16:48:12 +01:00
|
|
|
chmod 0750 /var/log/auth.d /var/log/daemon.d /var/log/kern.d /var/log/messages.d /var/log/syslog.d
|
|
|
|
chown root:adm /var/log/auth.d /var/log/daemon.d /var/log/kern.d /var/log/messages.d /var/log/syslog.d
|
2015-04-01 16:24:07 +02:00
|
|
|
|
2015-04-30 14:09:32 +02:00
|
|
|
# Create the log directory for journald (Systemd), need the configuration Storage=(auto|persistent)
|
|
|
|
mkdir -p -- /var/log/journal
|
2017-08-20 16:07:26 +02:00
|
|
|
### }}}
|
|
|
|
|
2017-08-20 15:51:14 +02:00
|
|
|
exit 0
|