2018-02-13 13:58:04 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2021-11-12 11:53:52 +01:00
|
|
|
# Some commands to generate a "good" custom Debian template
|
2018-02-13 13:58:04 +01:00
|
|
|
|
|
|
|
# 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
|
2018-02-13 13:58:04 +01:00
|
|
|
|
|
|
|
# }}}
|
|
|
|
|
|
|
|
# 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
|
2018-02-13 13:58:04 +01:00
|
|
|
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
|
2018-02-13 13:58:04 +01:00
|
|
|
update-locale LANG="${NEW_L}"
|
|
|
|
|
|
|
|
# }}}
|
|
|
|
|
|
|
|
# download an additionnal script to manage rsyslog and logrotate {{{
|
|
|
|
|
2020-08-06 17:00:52 +02:00
|
|
|
# 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)
|
2019-07-05 22:48:29 +02:00
|
|
|
|
2023-11-03 15:54:59 +01:00
|
|
|
wget https://git.ipr.univ-rennes.fr/cellinfo/tftpboot/raw/master/scripts/latecommand.tar.gz --output-document=/tmp/latecommand.tar.gz
|
2021-11-12 11:58:07 +01:00
|
|
|
tar xzf /tmp/latecommand.tar.gz --directory=/tmp/
|
2019-07-05 22:48:29 +02:00
|
|
|
/bin/sh /tmp/latecommand/post."${debian_version}".sh
|
2018-02-13 13:58:04 +01:00
|
|
|
|
|
|
|
# }}}
|
|
|
|
|
|
|
|
# APT {{{
|
|
|
|
|
2019-04-26 21:25:19 +02:00
|
|
|
## Clean downloaded and list of packages
|
2018-02-13 13:58:04 +01:00
|
|
|
aptitude clean
|
2021-11-12 11:58:07 +01:00
|
|
|
rm --force -- /var/cache/apt/*.bin
|
2018-02-13 13:58:04 +01:00
|
|
|
|
|
|
|
# }}}
|
|
|
|
|
|
|
|
# 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/*
|
2018-02-13 13:58:04 +01:00
|
|
|
|
|
|
|
# }}}
|
|
|
|
|
|
|
|
exit 0
|