2767
Comment: Async logging for rsyslog
|
4508
Spelling correction
|
Deletions are marked like this. | Additions are marked like this. |
Line 11: | Line 11: |
# Disable installation of recommended packages (TODO: this is interactive; how to pass "yes"?) | # Disable installation of recommended packages |
Line 21: | Line 21: |
cat /etc/logrotate.conf | sed "s/#compress/compress/" > /etc/logrotate.conf.tmp echo "dateext" >> /etc/logrotate.conf.tmp |
cat /etc/logrotate.conf | sed "s/#compress/compress\ndateext/" > /etc/logrotate.conf.tmp |
Line 24: | Line 23: |
# Disable root login—public key access only! cat /etc/ssh/sshd_config | sed "s/PermitRootLogin yes/PermitRootLogin without-password/" > /etc/ssh/sshd_config.tmp mv /etc/ssh/sshd_config.tmp /etc/ssh/sshd_config service ssh restart |
|
Line 37: | Line 41: |
mosh \ | |
Line 41: | Line 46: |
sysfsutils procpsutils \ | sysfsutils procps \ |
Line 49: | Line 54: |
sudo dpkg-reconfigure -plow unattended-upgrades | sudo DEBIAN_FRONTEND=noninteractive dpkg-reconfigure -plow unattended-upgrades |
Line 87: | Line 92: |
# Add noatime,commit=900 to entries in /etc/fstab # Enable SATA ALPM echo SATA_ALPM_ENABLE=true | sudo tee /etc/pm/config.d/sata_alpm |
|
Line 88: | Line 98: |
== New account setup == === Remote === {{{#!highlight sh # Quiet login touch .hushlogin cd ~ mkdir -p .ssh/controls mkdir -p .vim/tmp chmod -R 755 .ssh chmod 644 .ssh/authorized_keys }}} === Locally === {{{#!highlight sh # Setup dot files git clone https://github.com/samatjain/dotfiles.git source dotfiles/init dots groups set base dots install }}} === Raspberry Pi stuff === {{{#!highlight sh # Switch from wheezy to testing cd /etc/apt/ sudo find . -type f -exec sed -i 's/wheezy/testing/g' {} \; # Disable tty2–tty6 sed -i '/[2-6]:23:respawn:\/sbin\/getty 38400 tty[2-6]/s%^%#%g' /etc/inittab # Disable tty on serial line sed -i '/T0:23:respawn:\/sbin\/getty -L ttyAMA0 115200 vt100/s%^%#%g' /etc/inittab # Optimize mounts sed -i 's/defaults,noatime/defaults,noatime,nodiratime/g' /etc/fstab # Overclock to 800 Mhz (no overvolting required). Overclocking not forced, but keep it on for the first 2 min during boot echo -e "arm_freq=800\nsdram_freq=400\ncore_freq=300\nforce_turbo=0\ninitial_turbo=120" >> /boot/config.txt # Use only 16 MiB for GPU (only run after updating firmware!) echo -e "gpu_mem=16" >> /boot/config.txt }}} Some of these are from [[https://extremeshok.com/1081/raspberry-pi-raspbian-tuning-optimising-optimizing-for-reduced-memory-usage/|Raspberry Pi Raspbian tuning / optimising / optimizing for reduced memory usage]] |
Chris Lamb has a good Debian installation checklist, from which I stole most of this list.
1 # Configure sudo, adding my user to the sudo group so I don't get password prompts
2 aptitude install sudo
3 adduser xjjk sudo
4 echo '%sudo ALL=NOPASSWD: ALL' > /etc/sudoers.d/No-Passwords-for-sudo-Group
5 chmod 0440 /etc/sudoers.d/No-Passwords-for-sudo-Group
6
7 # Disable installation of recommended packages
8 echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/90recommends
9
10 # Configure locales to prevent harassment about it later
11 aptitude install locales
12 dpkg-reconfigure -plow locales
13 # …or install all locales so they don't need to be configured/reinstalled
14 aptitude install locales-all
15
16 # Enable log compression with date suffixed extension
17 cat /etc/logrotate.conf | sed "s/#compress/compress\ndateext/" > /etc/logrotate.conf.tmp
18 mv /etc/logrotate.conf.tmp /etc/logrotate.conf
19
20 # Disable root login—public key access only!
21 cat /etc/ssh/sshd_config | sed "s/PermitRootLogin yes/PermitRootLogin without-password/" > /etc/ssh/sshd_config.tmp
22 mv /etc/ssh/sshd_config.tmp /etc/ssh/sshd_config
23 service ssh restart
24
25 # Prevent PAM from allowing easily-crackable passwords
26 aptitude install libpam-cracklib
27
28 # Install essential utilities
29 sudo aptitude install \
30 openssh-server screen \
31 rsync \
32 atool lzma rzip xz-utils \
33 htop dstat iotop \
34 manpages manpages-dev \
35 strace tcpdump lsof \
36 moreutils \
37 mosh \
38 dnsutils \
39 chrony \
40 vim less \
41 bash-completion \
42 sysfsutils procps \
43 vnstat \
44 unattended-upgrades \
45 ncurses-term \
46 cpufrequtils powertop \
47 molly-guard
48
49 # Enable automatic security updates (careful!)
50 sudo DEBIAN_FRONTEND=noninteractive dpkg-reconfigure -plow unattended-upgrades
51
52 # HDD Temperature/SMART monitoring utilities
53 aptitude install hddtemp smartmontools
54 sed -i 's/^#start_smartd=yes/start_smartd=yes/' /etc/default/smartmontools
55 /etc/init.d/smartmontools start
56
57 # Configure rsyslog for daily archival logging
58 cat << EOF > /etc/rsyslog.d/51-cron.conf
59 # Enable cron logging
60 cron.* /var/log/cron.log
61 EOF
62 cat << EOF > /etc/rsyslog.d/99-archive.conf
63 \$template DailyLogs,"/var/log/archive/%\$YEAR%%\$MONTH%/%\$YEAR%%\$MONTH%%\$DAY%.log"
64 # Archive logging
65 *.* -?DailyLogs
66 EOF
67 cat << EOF > /etc/cron.daily/rsyslog-archive
68 #!/bin/sh
69 # Compress *.log-files not changed in more than 24 hours
70 find /var/log/archive -type f -mtime +1 -name "*.log" -exec xz '{}' \;
71 EOF
72 chmod +x /etc/cron.daily/rsyslog-archive
73
74 # Async logging for rsync (commit every 30m)
75 cat << EOF > /etc/rsyslog.d/98-async.conf
76 \$OMFileFlushInterval 1800
77 \$OMFileASyncWriting on
78 EOF
79
80 # Use tmpfs for /var/run and /var/lock (may break some buggy packages), like Ubuntu
81 cat << EOF >> /etc/default/rcS
82 RAMRUN=yes
83 RAMLOCK=yes
84 EOF
85
86 # Allow running X11 apps remotely
87 sudo aptitude install xbase-clients
88
89 # Add noatime,commit=900 to entries in /etc/fstab
90
91 # Enable SATA ALPM
92 echo SATA_ALPM_ENABLE=true | sudo tee /etc/pm/config.d/sata_alpm
New account setup
Remote
Locally
Raspberry Pi stuff
1 # Switch from wheezy to testing
2 cd /etc/apt/
3 sudo find . -type f -exec sed -i 's/wheezy/testing/g' {} \;
4
5 # Disable tty2–tty6
6 sed -i '/[2-6]:23:respawn:\/sbin\/getty 38400 tty[2-6]/s%^%#%g' /etc/inittab
7 # Disable tty on serial line
8 sed -i '/T0:23:respawn:\/sbin\/getty -L ttyAMA0 115200 vt100/s%^%#%g' /etc/inittab
9
10 # Optimize mounts
11 sed -i 's/defaults,noatime/defaults,noatime,nodiratime/g' /etc/fstab
12
13 # Overclock to 800 Mhz (no overvolting required). Overclocking not forced, but keep it on for the first 2 min during boot
14 echo -e "arm_freq=800\nsdram_freq=400\ncore_freq=300\nforce_turbo=0\ninitial_turbo=120" >> /boot/config.txt
15
16 # Use only 16 MiB for GPU (only run after updating firmware!)
17 echo -e "gpu_mem=16" >> /boot/config.txt
Some of these are from Raspberry Pi Raspbian tuning / optimising / optimizing for reduced memory usage