# hook for compcache # based on Ubuntu initramfs hook # # if [ $TCOS_COMPCACHE ]; then stat_before tcos_manual_add_modules ramzswap tcos_manual_add_modules zram # need swapon for preference option (busybox swapon don't have it) cpifexists /sbin/swapon /sbin/ [ -x /usr/sbin/rzscontrol ] && cpifexists /usr/sbin/rzscontrol /usr/sbin/ mkdir -p $DESTDIR/etc/udev/rules.d cat << EOF > $DESTDIR/etc/udev/rules.d/80-compcache.rules KERNEL=="ramzswap0", ACTION=="add", RUN+="/sbin/swapon -p 100 /dev/ramzswap0 2>/dev/null" EOF cat << EOF > $DESTDIR/scripts/init-top/compcache #!/bin/sh # new header not using prereqs if [ "\$1" = "prereqs" ]; then echo "" exit 0 fi quiet=n . /conf/tcos.conf . /conf/tcos-run-functions # find total amount of available ram TOTAL_RAM=\$(grep MemTotal /proc/meminfo |tr -d ': [A-Z][a-z]') # Do not use compcache if we have more than 256M if [ "\${TOTAL_RAM}" -gt 262144 ]; then exit 0 fi # add TCOS_COMPCACHE_PERCENT% of RAM (by default 20) kbytes="\$((\$TOTAL_RAM * $TCOS_COMPCACHE_PERCENT / 100))" AVALAIBLE_RAM=\$(grep 'Inactive:' /proc/meminfo |tr -d ': [A-Z][a-z]') if [ "\${kbytes}" -gt "\${AVALAIBLE_RAM}" ]; then kbytes=\$(( \${AVALAIBLE_RAM} - 500 )) fi if tcos_find_module "zram"; then modprobe zram echo \$((1024*\$kbytes)) > /sys/block/zram0/disksize /sbin/mkswap /dev/zram0 >/dev/null 2>&1 /sbin/swapon -p 100 /dev/zram0 >/dev/null 2>&1 else modprobe -q --ignore-install ramzswap fi EOF chmod 0755 $DESTDIR/scripts/init-top/compcache stat_after "Compcache support ($TCOS_COMPCACHE_PERCENT%)" fi