projects/aports·blob master · refs

27 lines · 678 B

1#!/sbin/openrc-run
2
3WORK_DIR="/" # btrfs filesytem root directory
4DB_SIZE=8 # this default setting uses about 140M of memory
5
6BEESSTATUS=/run/$SVCNAME/$SVCNAME.status
7BEESHOME="$WORK_DIR/.beeshome"
8DB_PATH="$BEESHOME/beeshash.dat"
9NEW_SIZE=$(expr $DB_SIZE \* 16777216)
10name=$SVCNAME
11command=/bin/$SVCNAME
12command_args="$WORK_DIR"
13command_background=yes
14pidfile=/run/$SVCNAME/$SVCNAME.pid
15export BEESSTATUS
16
17start_pre() {
18 checkpath -d /run/$SVCNAME
19 if [ ! -d "$BEESHOME" ]; then
20 btrfs sub cre "$BEESHOME"
21 fi
22 touch "$DB_PATH"
23 OLD_SIZE="$(wc -c < "$DB_PATH" | sed 's/\t/ /g' | cut -d' ' -f1)"
24 if [ "$OLD_SIZE" != "$NEW_SIZE" ]; then
25 truncate -s $NEW_SIZE $DB_PATH
26 fi
27}