mirror of
https://github.com/Fishwaldo/build.git
synced 2025-03-29 18:21:27 +00:00
Add and enable by default the log2ram service
Clean up distribution specific tweaks
This commit is contained in:
parent
959237557f
commit
5f038955e3
5 changed files with 140 additions and 40 deletions
|
@ -141,9 +141,6 @@ install_common()
|
|||
# enable firstrun script
|
||||
chroot $CACHEDIR/$SDCARD /bin/bash -c "update-rc.d firstrun defaults >/dev/null 2>&1"
|
||||
|
||||
# remove .old on new image
|
||||
rm -rf $CACHEDIR/$SDCARD/boot/dtb.old
|
||||
|
||||
# enable verbose kernel messages on first boot
|
||||
touch $CACHEDIR/$SDCARD/boot/.verbose
|
||||
|
||||
|
@ -152,6 +149,39 @@ install_common()
|
|||
|
||||
# switch to beta repository at this stage if building nightly images
|
||||
[[ $IMAGE_TYPE == nightly ]] && echo "deb http://beta.armbian.com $RELEASE main utils ${RELEASE}-desktop" > $CACHEDIR/$SDCARD/etc/apt/sources.list.d/armbian.list
|
||||
|
||||
# log2ram - systemd compatible ramlog alternative
|
||||
mkdir -p $CACHEDIR/$SDCARD/usr/local/sbin/ $CACHEDIR/$SDCARD/usr/local/share/log2ram/
|
||||
cp $SRC/lib/scripts/log2ram/LICENSE.log2ram $CACHEDIR/$SDCARD/usr/local/share/log2ram/LICENSE
|
||||
cp $SRC/lib/scripts/log2ram/log2ram.service $CACHEDIR/$SDCARD/etc/systemd/system/log2ram.service
|
||||
install -m 755 $SRC/lib/scripts/log2ram/log2ram $CACHEDIR/$SDCARD/usr/local/sbin/
|
||||
install -m 755 $SRC/lib/scripts/log2ram/log2ram.hourly $CACHEDIR/$SDCARD/etc/cron.hourly/log2ram
|
||||
chroot $CACHEDIR/$SDCARD /bin/bash -c "systemctl --no-reload enable log2ram.service 2>/dev/null"
|
||||
cat <<-EOF > $CACHEDIR/$SDCARD/etc/default/log2ram
|
||||
# configuration values for the log2ram service
|
||||
ENABLED=true
|
||||
SIZE=50M
|
||||
USE_RSYNC=false
|
||||
EOF
|
||||
|
||||
# enable getty on serial console
|
||||
chroot $CACHEDIR/$SDCARD /bin/bash -c "systemctl --no-reload enable serial-getty@$SERIALCON.service 2>/dev/null"
|
||||
|
||||
# don't clear screen tty1
|
||||
mkdir -p "$CACHEDIR/$SDCARD/etc/systemd/system/getty@tty1.service.d/"
|
||||
printf "[Service]\nTTYVTDisallocate=no" > "$CACHEDIR/$SDCARD/etc/systemd/system/getty@tty1.service.d/10-noclear.conf"
|
||||
|
||||
# reduce modules unload timeout
|
||||
mkdir -p $CACHEDIR/$SDCARD/etc/systemd/system/systemd-modules-load.service.d/
|
||||
printf "[Service]\nTimeoutStopSec=10" > $CACHEDIR/$SDCARD/etc/systemd/system/systemd-modules-load.service.d/10-timeout.conf
|
||||
|
||||
# handle PMU power button
|
||||
mkdir -p $CACHEDIR/$SDCARD/etc/udev/rules.d/
|
||||
cp $SRC/lib/config/71-axp-power-button.rules $CACHEDIR/$SDCARD/etc/udev/rules.d/
|
||||
|
||||
# Fix for PuTTY/KiTTY & ncurses-based dialogs (i.e. alsamixer) over serial
|
||||
# may break other terminals like screen
|
||||
#printf "[Service]\nEnvironment=TERM=xterm-256color" > /etc/systemd/system/serial-getty@.service.d/10-term.conf
|
||||
}
|
||||
|
||||
install_distribution_specific()
|
||||
|
@ -164,25 +194,6 @@ install_distribution_specific()
|
|||
# enable root login for latest ssh on jessie
|
||||
sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' $CACHEDIR/$SDCARD/etc/ssh/sshd_config
|
||||
|
||||
# add serial console
|
||||
#cp $SRC/lib/config/ttyS0.conf $CACHEDIR/$SDCARD/etc/init/$SERIALCON.conf
|
||||
#sed -e "s/ttyS0/$SERIALCON/g" -i $CACHEDIR/$SDCARD/etc/init/$SERIALCON.conf
|
||||
chroot $CACHEDIR/$SDCARD /bin/bash -c "systemctl --no-reload enable serial-getty@$SERIALCON.service >/dev/null 2>&1"
|
||||
mkdir -p "$CACHEDIR/$SDCARD/etc/systemd/system/serial-getty@$SERIALCON.service.d"
|
||||
printf "[Service]\nExecStart=\nExecStart=-/sbin/agetty -L 115200 %%I $TERM" > "$CACHEDIR/$SDCARD/etc/systemd/system/serial-getty@$SERIALCON.service.d/10-rate.conf"
|
||||
|
||||
# don't clear screen tty1
|
||||
mkdir -p "$CACHEDIR/$SDCARD/etc/systemd/system/getty@tty1.service.d/"
|
||||
printf "[Service]\nTTYVTDisallocate=no" > "$CACHEDIR/$SDCARD/etc/systemd/system/getty@tty1.service.d/10-noclear.conf"
|
||||
|
||||
# seting timeout
|
||||
mkdir -p $CACHEDIR/$SDCARD/etc/systemd/system/systemd-modules-load.service.d/
|
||||
printf "[Service]\nTimeoutStopSec=10" > $CACHEDIR/$SDCARD/etc/systemd/system/systemd-modules-load.service.d/10-timeout.conf
|
||||
|
||||
# handle PMU power button
|
||||
mkdir -p $CACHEDIR/$SDCARD/etc/udev/rules.d/
|
||||
cp $SRC/lib/config/71-axp-power-button.rules $CACHEDIR/$SDCARD/etc/udev/rules.d/
|
||||
|
||||
mkdir -p $CACHEDIR/$SDCARD/etc/NetworkManager/dispatcher.d/
|
||||
cat <<-'EOF' > $CACHEDIR/$SDCARD/etc/NetworkManager/dispatcher.d/99disable-power-management
|
||||
#!/bin/sh
|
||||
|
@ -201,20 +212,6 @@ install_distribution_specific()
|
|||
# remove legal info from Ubuntu
|
||||
[[ -f $CACHEDIR/$SDCARD/etc/legal ]] && rm $CACHEDIR/$SDCARD/etc/legal
|
||||
|
||||
chroot $CACHEDIR/$SDCARD /bin/bash -c "systemctl --no-reload enable serial-getty@$SERIALCON.service >/dev/null 2>&1"
|
||||
|
||||
# Fix for PuTTY/KiTTY & ncurses-based dialogs (i.e. alsamixer) over serial
|
||||
# may break other terminals like screen
|
||||
#printf "[Service]\nEnvironment=TERM=xterm-256color" > /etc/systemd/system/serial-getty@.service.d/10-term.conf
|
||||
|
||||
# don't clear screen tty1
|
||||
mkdir -p "$CACHEDIR/$SDCARD/etc/systemd/system/getty@tty1.service.d/"
|
||||
printf "[Service]\nTTYVTDisallocate=no" > "$CACHEDIR/$SDCARD/etc/systemd/system/getty@tty1.service.d/10-noclear.conf"
|
||||
|
||||
# seting timeout
|
||||
mkdir -p $CACHEDIR/$SDCARD/etc/systemd/system/systemd-modules-load.service.d/
|
||||
printf "[Service]\nTimeoutStopSec=10" > $CACHEDIR/$SDCARD/etc/systemd/system/systemd-modules-load.service.d/10-timeout.conf
|
||||
|
||||
# Fix for haveged service
|
||||
mkdir -p -m755 $CACHEDIR/$SDCARD/etc/systemd/system/haveged.service.d
|
||||
cat <<-EOF > $CACHEDIR/$SDCARD/etc/systemd/system/haveged.service.d/10-no-new-privileges.conf
|
||||
|
@ -222,10 +219,6 @@ install_distribution_specific()
|
|||
NoNewPrivileges=false
|
||||
EOF
|
||||
|
||||
# handle PMU power button
|
||||
mkdir -p $CACHEDIR/$SDCARD/etc/udev/rules.d/
|
||||
cp $SRC/lib/config/71-axp-power-button.rules $CACHEDIR/$SDCARD/etc/udev/rules.d/
|
||||
|
||||
# disable not working on unneeded services
|
||||
# ureadahead needs kernel tracing options that AFAIK are present only in mainline
|
||||
chroot $CACHEDIR/$SDCARD /bin/bash -c "systemctl --no-reload mask ureadahead.service >/dev/null 2>&1"
|
||||
|
|
21
scripts/log2ram/LICENSE.log2ram
Normal file
21
scripts/log2ram/LICENSE.log2ram
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
67
scripts/log2ram/log2ram
Normal file
67
scripts/log2ram/log2ram
Normal file
|
@ -0,0 +1,67 @@
|
|||
#!/bin/sh
|
||||
|
||||
SIZE=40M
|
||||
USE_RSYNC=false
|
||||
ENABLED=false
|
||||
|
||||
[ -f /etc/default/log2ram ] && . /etc/default/log2ram
|
||||
|
||||
[ "$ENABLED" != true ] && exit 0
|
||||
|
||||
# don't touch anything below here.
|
||||
|
||||
HDD_LOG=/var/log.hdd/
|
||||
RAM_LOG=/var/log/
|
||||
LOG2RAM_LOG="${HDD_LOG}log2ram.log"
|
||||
LOG_OUTPUT="tee -a $LOG2RAM_LOG"
|
||||
|
||||
isSafe () {
|
||||
[ -d $HDD_LOG ] || echo "ERROR: $HDD_LOG doesn't exist! Can't sync."
|
||||
[ -d $HDD_LOG ] || exit 1
|
||||
}
|
||||
|
||||
syncToDisk () {
|
||||
isSafe
|
||||
|
||||
if [ "$USE_RSYNC" = true ]; then
|
||||
rsync -aXWv --delete --exclude log2ram.log --links $RAM_LOG $HDD_LOG 2>&1 | $LOG_OUTPUT
|
||||
else
|
||||
cp -rfup $RAM_LOG -T $HDD_LOG 2>&1 | $LOG_OUTPUT
|
||||
fi
|
||||
}
|
||||
|
||||
syncFromDisk () {
|
||||
isSafe
|
||||
|
||||
if [ "$USE_RSYNC" = true ]; then
|
||||
rsync -aXWv --delete --exclude log2ram.log --links $HDD_LOG $RAM_LOG 2>&1 | $LOG_OUTPUT
|
||||
else
|
||||
cp -rfup $HDD_LOG -T $RAM_LOG 2>&1 | $LOG_OUTPUT
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
[ -d $HDD_LOG ] || mkdir $HDD_LOG
|
||||
rm -f $LOG2RAM_LOG
|
||||
mount --bind $RAM_LOG $HDD_LOG
|
||||
mount --make-private $HDD_LOG
|
||||
mount -t tmpfs -o nosuid,noexec,nodev,mode=0755,size=$SIZE log2ram $RAM_LOG
|
||||
syncFromDisk
|
||||
;;
|
||||
|
||||
stop)
|
||||
syncToDisk
|
||||
umount -l $RAM_LOG
|
||||
umount -l $HDD_LOG
|
||||
;;
|
||||
|
||||
write)
|
||||
syncToDisk
|
||||
;;
|
||||
*)
|
||||
echo "Usage: log2ram {start|stop|write}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
3
scripts/log2ram/log2ram.hourly
Normal file
3
scripts/log2ram/log2ram.hourly
Normal file
|
@ -0,0 +1,3 @@
|
|||
#! /bin/sh
|
||||
|
||||
/usr/local/sbin/log2ram write
|
16
scripts/log2ram/log2ram.service
Normal file
16
scripts/log2ram/log2ram.service
Normal file
|
@ -0,0 +1,16 @@
|
|||
[Unit]
|
||||
Description=Log2Ram
|
||||
DefaultDependencies=no
|
||||
Wants=rsyslog.service systemd-journald.service
|
||||
Before=syslog.target sysinit.target
|
||||
After=local-fs.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/sbin/log2ram start
|
||||
ExecStop=/usr/local/sbin/log2ram stop
|
||||
ExecReload=/usr/local/sbin/log2ram write
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=sysinit.target
|
Loading…
Add table
Reference in a new issue