scripts/proxmox/proxmox.template.debian.sh

70 lines
1.7 KiB
Bash
Raw Normal View History

#!/bin/sh
#
# Some commands to generate a "good" custom Debian 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
2021-11-12 11:58:07 +01:00
rm --force -- /etc/localtime
dpkg-reconfigure --frontend noninteractive -- tzdata
# }}}
# manage locale {{{
NEW_L="en_US.UTF-8"
2019-07-05 22:34:33 +02:00
## Fix locale for the script
export LANGUAGE="${NEW_L}"
export LANG="${NEW_L}"
export LC_ALL="${NEW_L}"
## Generate new locale
sed -i -e "s/# \(${NEW_L} UTF-8\)/\1/" /etc/locale.gen
locale-gen
echo "LANG=\"${NEW_L}\"" > /etc/default/locale
2021-11-12 11:58:07 +01:00
dpkg-reconfigure --frontend noninteractive -- locales
update-locale LANG="${NEW_L}"
# }}}
# download an additionnal script to manage rsyslog and logrotate {{{
# Previously used hostnamectl but it can't works correctly on LXC container with Apparmor
2021-11-12 11:58:07 +01:00
debian_version=$(grep VERSION_CODENAME /etc/os-release | cut --delimiter="=" --fields=2)
2021-11-12 11:58:07 +01:00
wget https://git.ipr.univ-rennes1.fr/cellinfo/tftpboot/raw/master/scripts/latecommand.tar.gz --output-document=/tmp/latecommand.tar.gz
tar xzf /tmp/latecommand.tar.gz --directory=/tmp/
/bin/sh /tmp/latecommand/post."${debian_version}".sh
# }}}
# APT {{{
2019-04-26 21:25:19 +02:00
## Clean downloaded and list of packages
aptitude clean
2021-11-12 11:58:07 +01:00
rm --force -- /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
2021-11-12 11:58:07 +01:00
rm --force -- /root/.bash_history
rm --recursive --force -- /var/log/journal/*
# }}}
exit 0