mirror of
https://github.com/Fishwaldo/build.git
synced 2025-03-18 21:01:26 +00:00
Try to implement persistent XDG_CACHE behaviour
This commit is contained in:
parent
9f5036f335
commit
0280edf9f4
8 changed files with 64 additions and 20 deletions
|
@ -6,7 +6,7 @@ CHROMIUM_FLAGS="\
|
|||
--disable-smooth-scrolling \
|
||||
--disable-low-res-tiling \
|
||||
--enable-low-end-device-mode \
|
||||
--num-raster-threads=4 \
|
||||
--num-raster-threads=2 \
|
||||
--profiler-timing=0 \
|
||||
--disable-composited-antialiasing \
|
||||
--disk-cache-size=300000000
|
||||
--disk-cache-size=100000000"
|
||||
|
|
|
@ -25,7 +25,7 @@ install_desktop ()
|
|||
|
||||
# install optimized chromium configuration
|
||||
cp $SRC/lib/config/chromium.conf $CACHEDIR/$SDCARD/etc/chromium-browser/default
|
||||
echo "export XDG_CACHE_HOME=\"/var/log/.cache\"" > $CACHEDIR/$SDCARD/etc/chromium-browser/customizations/10-cachedir
|
||||
echo "export XDG_CACHE_HOME=\"/var/xdgcache\"" > $CACHEDIR/$SDCARD/etc/chromium-browser/customizations/10-cachedir
|
||||
fi
|
||||
# install dedicated startup icons
|
||||
cp $SRC/lib/bin/icons/${RELEASE}.png $CACHEDIR/$SDCARD/usr/share/pixmaps
|
||||
|
|
|
@ -138,7 +138,7 @@ install_common()
|
|||
install -m 644 $SRC/lib/scripts/firstrun.service $CACHEDIR/$SDCARD/etc/systemd/system/
|
||||
|
||||
# enable additional services
|
||||
chroot $CACHEDIR/$SDCARD /bin/bash -c "systemctl --no-reload enable firstrun.service resize2fs.service armhwinfo.service log2ram.service >/dev/null 2>&1"
|
||||
chroot $CACHEDIR/$SDCARD /bin/bash -c "systemctl --no-reload enable firstrun.service resize2fs.service armhwinfo.service log2ram.service xdgcache2ram.service >/dev/null 2>&1"
|
||||
|
||||
# copy "first run automated config, optional user configured"
|
||||
cp $SRC/lib/config/armbian_first_run.txt $CACHEDIR/$SDCARD/boot/armbian_first_run.txt
|
||||
|
|
|
@ -67,7 +67,7 @@ create_board_package()
|
|||
#!/bin/sh
|
||||
[ remove = "\$1" ] || [ abort-install = "\$1" ] && dpkg-divert --package linux-${RELEASE}-root-${DEB_BRANCH}${BOARD} --remove --rename \
|
||||
--divert /etc/mpv/mpv-dist.conf /etc/mpv/mpv.conf
|
||||
systemctl disable log2ram.service armhwinfo.service >/dev/null 2>&1
|
||||
systemctl disable log2ram.service xdgcache2ram.service armhwinfo.service >/dev/null 2>&1
|
||||
exit 0
|
||||
EOF
|
||||
|
||||
|
@ -88,6 +88,12 @@ create_board_package()
|
|||
if [ -f "/etc/systemd/system/log2ram.service" ]; then
|
||||
mv /etc/systemd/system/log2ram.service /etc/systemd/system/log2ram-service.dpkg-old
|
||||
fi
|
||||
if [ ! -f "/etc/default/xdgcache2ram" ]; then
|
||||
cp /etc/default/xdgcache2ram.dpkg-dist /etc/default/xdgcache2ram
|
||||
fi
|
||||
if [ -f "/etc/systemd/system/xdgcache2ram.service" ]; then
|
||||
mv /etc/systemd/system/xdgcache2ram.service /etc/systemd/system/xdgcache2ram-service.dpkg-old
|
||||
fi
|
||||
exit 0
|
||||
EOF
|
||||
|
||||
|
@ -286,6 +292,11 @@ create_board_package()
|
|||
install -m 755 $SRC/lib/scripts/log2ram/log2ram.hourly $destination/etc/cron.daily/log2ram
|
||||
cp $SRC/lib/scripts/log2ram/log2ram.default $destination/etc/default/log2ram.dpkg-dist
|
||||
|
||||
# xdgcache2ram - persistent xdgcache based on log2ram
|
||||
cp $SRC/lib/scripts/log2ram/xdgcache2ram.service $destination/lib/systemd/system/xdgcache2ram.service
|
||||
ln -s /usr/sbin/log2ram $destination/usr/sbin/xdgcache2ram
|
||||
cp $SRC/lib/scripts/log2ram/xdgcache2ram.default $destination/etc/default/xdgcache2ram.dpkg-dist
|
||||
|
||||
if [[ $LINUXFAMILY == sun*i ]]; then
|
||||
install -m 755 $SRC/lib/scripts/armbian-add-overlay $destination/usr/sbin
|
||||
if [[ $BRANCH == default ]]; then
|
||||
|
|
|
@ -316,7 +316,7 @@ adjust_chromium_settings() {
|
|||
if [ -f /etc/chromium-browser/default ]; then
|
||||
|
||||
# create chromium cache directory
|
||||
[[ ! -d /var/log/.cache ]] && mkdir /var/log/.cache && chgrp netdev /var/log/.cache && chmod g+w /var/log/.cache
|
||||
[[ ! -d /var/xdgcache ]] && mkdir -m775 /var/xdgcache && chgrp netdev /var/xdgcache && chmod g+w /var/xdgcache
|
||||
|
||||
# Desktop image. Let's adjust chromium cache size depending on available DRAM (15%)
|
||||
# and count of render threads based on number of CPU cores
|
||||
|
@ -324,13 +324,13 @@ adjust_chromium_settings() {
|
|||
memory_total=$(awk '{printf("%d",$2/1024)}' <<<${mem_info})
|
||||
cpu_cores=$(grep -c processor /proc/cpuinfo)
|
||||
chromium_disk_cache=$(( ${memory_total} * 158000 ))
|
||||
log2ram_size=$(( 50 + $(( ${memory_total} / 1000 * 150 )) ))
|
||||
xdgcache_size=$(( ${memory_total} / 1000 * 150 ))
|
||||
|
||||
# adjust log2ram config if necessary (switching between devices with different amount
|
||||
# adjust xdgcache config if necessary (switching between devices with different amount
|
||||
# of DRAM but same OS image)
|
||||
grep -q "^SIZE=${log2ram_size}M" /etc/default/log2ram || \
|
||||
sed -i "s/^SIZE=.*/SIZE=${log2ram_size}M/" /etc/default/log2ram && \
|
||||
systemctl restart log2ram
|
||||
grep -q "^SIZE=${xdgcache_size}M" /etc/default/log2ram || \
|
||||
sed -i -e "s/^SIZE=.*/SIZE=${xdgcache_size}M/" -e "s/^ENABLED=.*/ENABLED=true/" \
|
||||
/etc/default/xdgcache2ram && systemctl restart xdgcache2ram
|
||||
|
||||
# adjust chromium settings
|
||||
sed -i -e "s/disk-cache-size=.*/disk-cache-size=${chromium_disk_cache}/" \
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Source: https://github.com/azlux/log2ram
|
||||
# Source based on: https://github.com/azlux/log2ram
|
||||
# License: MIT
|
||||
# License file: /usr/share/log2ram/LICENSE
|
||||
|
||||
SIZE=40M
|
||||
USE_RSYNC=false
|
||||
ENABLED=false
|
||||
ME="${0##*/}"
|
||||
DIRNAME="$(sed 's/2ram$//' <<<"${ME}")"
|
||||
|
||||
[ -f /etc/default/log2ram ] && . /etc/default/log2ram
|
||||
[ -f /etc/default/${ME} ] && . /etc/default/${ME}
|
||||
|
||||
[ "$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"
|
||||
HDD_LOG=/var/${DIRNAME}.hdd/
|
||||
RAM_LOG=/var/${DIRNAME}/
|
||||
LOG2RAM_LOG="${HDD_LOG}${ME}.log"
|
||||
LOG_OUTPUT="tee -a $LOG2RAM_LOG"
|
||||
|
||||
isSafe () {
|
||||
|
@ -28,7 +30,7 @@ syncToDisk () {
|
|||
isSafe
|
||||
|
||||
if [ "$USE_RSYNC" = true ]; then
|
||||
rsync -aXWv --delete --exclude log2ram.log --links $RAM_LOG $HDD_LOG 2>&1 | $LOG_OUTPUT
|
||||
rsync -aXWv --delete --exclude ${ME}.log --links $RAM_LOG $HDD_LOG 2>&1 | $LOG_OUTPUT
|
||||
else
|
||||
cp -rfup $RAM_LOG -T $HDD_LOG 2>&1 | $LOG_OUTPUT
|
||||
fi
|
||||
|
@ -38,7 +40,7 @@ syncFromDisk () {
|
|||
isSafe
|
||||
|
||||
if [ "$USE_RSYNC" = true ]; then
|
||||
rsync -aXWv --delete --exclude log2ram.log --links $HDD_LOG $RAM_LOG 2>&1 | $LOG_OUTPUT
|
||||
rsync -aXWv --delete --exclude ${ME}.log --links $HDD_LOG $RAM_LOG 2>&1 | $LOG_OUTPUT
|
||||
else
|
||||
cp -rfup $HDD_LOG -T $RAM_LOG 2>&1 | $LOG_OUTPUT
|
||||
fi
|
||||
|
@ -51,7 +53,7 @@ case "$1" in
|
|||
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
|
||||
mount -t tmpfs -o nosuid,noexec,nodev,mode=0755,size=$SIZE ${ME} $RAM_LOG
|
||||
syncFromDisk
|
||||
;;
|
||||
|
||||
|
@ -65,7 +67,7 @@ case "$1" in
|
|||
syncToDisk
|
||||
;;
|
||||
*)
|
||||
echo "Usage: log2ram {start|stop|write}" >&2
|
||||
echo "Usage: ${ME} {start|stop|write}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
13
scripts/log2ram/xdgcache2ram.default
Normal file
13
scripts/log2ram/xdgcache2ram.default
Normal file
|
@ -0,0 +1,13 @@
|
|||
# configuration values for the log2ram service
|
||||
#
|
||||
# enable the log2ram service?
|
||||
ENABLED=false
|
||||
#
|
||||
# size of the tmpfs mount
|
||||
SIZE=1M
|
||||
#
|
||||
# use rsync instead of cp -r
|
||||
# requires rsync installed, may provide better performance
|
||||
# due to copying only new and changed files
|
||||
USE_RSYNC=true
|
||||
#
|
18
scripts/log2ram/xdgcache2ram.service
Normal file
18
scripts/log2ram/xdgcache2ram.service
Normal file
|
@ -0,0 +1,18 @@
|
|||
[Unit]
|
||||
Description=Armbian enhanced xdgcache based on Log2Ram
|
||||
DefaultDependencies=no
|
||||
Before=rsyslog.service syslog.target systemd-journald.service sysinit.target shutdown.target
|
||||
After=local-fs.target
|
||||
Conflicts=shutdown.target
|
||||
RequiresMountsFor=/var/xdgcache /var/xdgcache.hdd
|
||||
IgnoreOnIsolate=yes
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/sbin/xdgcache2ram start
|
||||
ExecStop=/usr/sbin/xdgcache2ram stop
|
||||
ExecReload=/usr/sbin/xdgcache2ram write
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=sysinit.target
|
Loading…
Add table
Reference in a new issue