scripts/proxmox/proxmox.template.debian.sh

70 lines
1.6 KiB
Bash
Executable File

#!/bin/sh
#
# Some commands to apply to generate a "good" custom Debian (Stretch) template
# SSH {{{
# allow root connection with a password
/bin/sed -i 's/\(^\|^\#\)\(PermitRootLogin\).*/\2 yes/g' /etc/ssh/sshd_config ;
systemctl restart sshd
# or download admin ssh pubkey
# }}}
# time {{{
# set timezone
echo "Europe/Paris" > /etc/timezone
rm -f -- /etc/localtime
dpkg-reconfigure -f noninteractive tzdata
# }}}
# manage locale {{{
NEW_L="en_US.UTF-8"
sed -i -e "s/# \(${NEW_L} UTF-8\)/\1/" /etc/locale.gen
locale-gen
echo "LANG=\"${NEW_L}\"" > /etc/default/locale
dpkg-reconfigure -f noninteractive locales
update-locale LANG="${NEW_L}"
# }}}
# download an additionnal script to manage rsyslog and logrotate {{{
wget https://git.ipr.univ-rennes1.fr/cellinfo/tftpboot/raw/master/scripts/latecommand.tar.gz -O /tmp/latecommand.tar.gz
tar xzf /tmp/latecommand.tar.gz -C /tmp/
/bin/sh /tmp/latecommand/post.sh
# }}}
# APT {{{
# ensure to install aptitude
apt install -y aptitude
# ensure to remove useless x11 packages
aptitude remove -y x11-common libgl1-mesa-glx xauth libx11-6 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxft2 libxi6 libxinerama1 libxkbfile1 libxmuu1 libxpm4 libxrandr2 libxrender1 libxv1 libxxf86dga1 libxxf86vm1 libx11-data
# clean useless rc files
aptitude -y purge '~c'
# clean downloaded and list of packages
aptitude clean
rm -f /var/cache/apt/*.bin
# }}}
# clean the system {{{
true > /etc/resolv.conf
find /var/log -type f -iname "*.log" -delete -exec touch {} \;
find /var/log -type f \( -iname "*.gz" -o -iname ".*.0" -o -iname "dmesg.*" \) -delete
rm -f -- /root/.bash_history
rm -rf -- /var/log/journal/*
# }}}
exit 0