Files
DebianTweaks/DebianTweaks.sh
2023-07-21 10:22:26 +02:00

78 lines
3.0 KiB
Bash
Executable File

#!/bin/bash
#Set the correct mailer fqdn
echo $(hostname -f) > /etc/mailname
#Add mailto address in crontab
awk '/PATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/sbin:\/bin:\/usr\/sbin:\/usr\/bin/ { print; print "MAILTO=thomas@de-roo.org"; next }1' /etc/crontab > /tmp/crontab.temp
cat /tmp/crontab.temp > /etc/crontab
rm /tmp/crontab.temp
#Better logon-message
figlet $(hostname)>/etc/motd
#Apt Updates
curl https://git.de-roo.org/DEROO/apt-update/raw/branch/main/apt-update.sh -o /usr/local/bin/apt-update.sh
chmod a+x /usr/local/bin/apt-update.sh
echo 0 0 * * * root /usr/local/bin/apt-update.sh >> /etc/crontab
#SNMP things. N.B.: replace VULHIERDELOCATIEIN later
cat > /etc/snmp/snmpd.conf << 'EOF'
sysLocation VULHIERDELOCATIEIN
sysContact Thomas de Roo <thomas@de-roo.org>
rocommunity cacti
rocommunity librenms
includeAllDisks 10%
#OS Distribution Detection
extend distro /usr/bin/distro
#Hardware Detection
# (uncomment for x86 platforms)
extend manufacturer '/bin/cat /sys/devices/virtual/dmi/id/sys_vendor'
extend hardware '/bin/cat /sys/devices/virtual/dmi/id/product_name'
extend serial '/bin/cat /sys/devices/virtual/dmi/id/product_serial'
# (uncomment for ARM platforms)
#extend hardware '/bin/cat /sys/firmware/devicetree/base/model'
#extend serial '/bin/cat /sys/firmware/devicetree/base/serial-number'
EOF
curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
chmod a+x /usr/bin/distro
echo @reboot root chmod 444 /sys/devices/virtual/dmi/id/product_serial >> /etc/crontab
chmod 444 /sys/devices/virtual/dmi/id/product_serial
systemctl restart snmpd
# Debian Trixie apt sources
cat > /etc/apt/sources.list << "EOF"
deb http://deb.debian.org/debian trixie main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian trixie main contrib non-free non-free-firmware
deb http://deb.debian.org/debian-security/ trixie-security main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian-security/ trixie-security main contrib non-free non-free-firmware
deb http://deb.debian.org/debian trixie-updates main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian trixie-updates main contrib non-free non-free-firmware
EOF
cat >> /etc/apt/sources.list.d/multimedia.list << "EOF"
deb https://www.deb-multimedia.org trixie main non-free
EOF
cat >> /etc/apt/sources.list.d/chrome.list << "EOF"
deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main
EOF
cat >> /etc/apt/sources.list.d/microsoft.list << "EOF"
deb [arch=amd64] https://packages.microsoft.com/debian/12/prod bookworm main
deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-bookworm-prod bookworm main
deb [arch=amd64] http://packages.microsoft.com/repos/code stable main
EOF
apt install gnupg -y
# Chrome
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B
# Microsoft
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EB3E94ADBE1229CF
# Multimedia
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5C808C2B65558117
ln -s /etc/apt/trusted.gpg /etc/apt/trusted.gpg.d/