scripts/proxmox/proxmox.template.debian.sh

76 lines
1.7 KiB
Bash
Raw Normal View History

#!/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 {{{
2019-04-26 19:34:06 +02:00
## Update repositories
apt update
2019-04-26 21:25:19 +02:00
## Ensure to install aptitude
apt install -y aptitude
2019-04-26 21:25:19 +02:00
## Ensure to have an up to date system
aptitude full-ugrade -y
## 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
2019-04-26 21:25:19 +02:00
## Clean useless rc files
aptitude -y purge '~c'
2019-04-26 21:25:19 +02:00
## 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
2018-03-26 14:06:26 +02:00
rm -rf -- /var/log/journal/*
# }}}
exit 0