2018-02-13 13:58:04 +01:00
|
|
|
#!/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"
|
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
|
|
|
|
dpkg-reconfigure -f noninteractive locales
|
|
|
|
update-locale LANG="${NEW_L}"
|
|
|
|
|
|
|
|
# }}}
|
|
|
|
|
|
|
|
# download an additionnal script to manage rsyslog and logrotate {{{
|
|
|
|
|
2019-07-05 22:48:29 +02:00
|
|
|
debian_version=$(hostnamectl | grep "Operating System" | sed 's/.*(\(.*\))/\1/')
|
|
|
|
|
2018-02-13 13:58:04 +01:00
|
|
|
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/
|
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 19:34:06 +02:00
|
|
|
## Update repositories
|
|
|
|
apt update
|
|
|
|
|
2019-04-26 21:25:19 +02:00
|
|
|
## Ensure to install aptitude
|
2019-04-26 19:33:25 +02:00
|
|
|
apt install -y aptitude
|
|
|
|
|
2019-04-26 21:25:19 +02:00
|
|
|
## Ensure to have an up to date system
|
2019-07-05 22:24:09 +02:00
|
|
|
aptitude full-upgrade -y
|
2019-04-26 21:25:19 +02:00
|
|
|
|
|
|
|
## Ensure to remove useless x11 packages
|
2018-02-13 13:58:04 +01:00
|
|
|
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
|
2018-02-13 13:58:04 +01:00
|
|
|
aptitude -y purge '~c'
|
|
|
|
|
2019-04-26 21:25:19 +02:00
|
|
|
## Clean downloaded and list of packages
|
2018-02-13 13:58:04 +01:00
|
|
|
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/*
|
2018-02-13 13:58:04 +01:00
|
|
|
|
|
|
|
# }}}
|
|
|
|
|
|
|
|
exit 0
|