mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-28 11:43:25 +02:00
ramdisk: Make usage of ramdisk configurable
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
@@ -61,8 +61,8 @@ $(TARGET) :
|
|||||||
-rm -rf /etc/init.d
|
-rm -rf /etc/init.d
|
||||||
ln -svf rc.d/init.d /etc/init.d
|
ln -svf rc.d/init.d /etc/init.d
|
||||||
|
|
||||||
#create ramdiskfile to force ramdiskcreation if FORCE=1
|
# Create default ramdisk configuration
|
||||||
echo "FORCE=0" > /etc/sysconfig/ramdisk
|
echo "RAMDISK_MODE=0" > /etc/sysconfig/ramdisk
|
||||||
|
|
||||||
for i in $(DIR_SRC)/src/initscripts/init.d/*; do \
|
for i in $(DIR_SRC)/src/initscripts/init.d/*; do \
|
||||||
install -v -m 754 $$i /etc/rc.d/init.d/; \
|
install -v -m 754 $$i /etc/rc.d/init.d/; \
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Begin $rc_base/init.d/collecd
|
# Begin $rc_base/init.d/collecd
|
||||||
|
|
||||||
|
|
||||||
. /etc/sysconfig/rc
|
. /etc/sysconfig/rc
|
||||||
. $rc_functions
|
. $rc_functions
|
||||||
|
|
||||||
eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
|
eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
|
||||||
eval $(/usr/local/bin/readhash /etc/sysconfig/ramdisk)
|
|
||||||
|
|
||||||
if [ "$RRDLOG" = '' ]; then
|
if [ "$RRDLOG" = '' ]; then
|
||||||
RRDLOG=/var/log/rrd
|
RRDLOG=/var/log/rrd
|
||||||
@@ -14,7 +12,7 @@ fi
|
|||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
if [ "$FORCE" == '1' ] || [ "$(mem_amount)" -gt "490" ];then
|
if use_ramdisk; then
|
||||||
#mount ramdisk
|
#mount ramdisk
|
||||||
if ! mountpoint $RRDLOG &>/dev/null; then
|
if ! mountpoint $RRDLOG &>/dev/null; then
|
||||||
boot_mesg "Mount rrd Ramdisk..."
|
boot_mesg "Mount rrd Ramdisk..."
|
||||||
|
|||||||
@@ -709,6 +709,39 @@ mem_amount() {
|
|||||||
echo "$(( ${pagesize} * ${pages} / 1024 / 1024 ))"
|
echo "$(( ${pagesize} * ${pages} / 1024 / 1024 ))"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use_ramdisk() {
|
||||||
|
eval $(/usr/local/bin/readhash /etc/sysconfig/ramdisk)
|
||||||
|
|
||||||
|
case "${RAMDISK_MODE}" in
|
||||||
|
# Don't use ramdisk
|
||||||
|
0)
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
|
||||||
|
# Always use ramdisk
|
||||||
|
1)
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
|
||||||
|
# Automatic mode - use ramdisk if sufficient
|
||||||
|
# memory is available
|
||||||
|
2)
|
||||||
|
local mem_avail="$(mem_amount)"
|
||||||
|
|
||||||
|
if [ ${mem_avail} -ge 490 ]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
# Fail for everything else
|
||||||
|
*)
|
||||||
|
return 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
mount_ramdisk() {
|
mount_ramdisk() {
|
||||||
mount -t tmpfs none $1
|
mount -t tmpfs none $1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ fi
|
|||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
if [ "$FORCE" == '1' ] || [ "$(mem_amount)" -gt "490" ];then
|
if use_ramdisk; then
|
||||||
if ! mountpoint $VNSTATLOG &>/dev/null; then
|
if ! mountpoint $VNSTATLOG &>/dev/null; then
|
||||||
boot_mesg "Mount vnstat ramdisk..."
|
boot_mesg "Mount vnstat ramdisk..."
|
||||||
if [ $(find "$VNSTATLOG" | wc -l) -ne 1 ]; then
|
if [ $(find "$VNSTATLOG" | wc -l) -ne 1 ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user