#!/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" ## 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 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 {{{ ## Update repositories apt update ## Ensure to install aptitude apt install -y aptitude ## Ensure to have an up to date system aptitude full-upgrade -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 ## 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