aboutsummaryrefslogtreecommitdiffstats
path: root/testing/bees/bees.initd
blob: f8717dbed93f628e9a5c86d12c9c02caccb6af39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/sbin/openrc-run

WORK_DIR="/" # btrfs filesytem root directory
DB_SIZE=8 # this default setting uses about 140M of memory

BEESSTATUS=/run/$SVCNAME/$SVCNAME.status
BEESHOME="$WORK_DIR/.beeshome"
DB_PATH="$BEESHOME/beeshash.dat"
NEW_SIZE=$(expr $DB_SIZE \* 16777216)
name=$SVCNAME
command=/bin/$SVCNAME
command_args="$WORK_DIR"
command_background=yes
pidfile=/run/$SVCNAME/$SVCNAME.pid
export BEESSTATUS

start_pre() {
	checkpath -d /run/$SVCNAME
	if [ ! -d "$BEESHOME" ]; then
		btrfs sub cre "$BEESHOME"
	fi	
	touch "$DB_PATH"
	OLD_SIZE="$(wc -c < "$DB_PATH" | sed 's/\t/ /g' | cut -d' ' -f1)"
	if [ "$OLD_SIZE" != "$NEW_SIZE" ]; then
		truncate -s $NEW_SIZE $DB_PATH
	fi
}