1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-16 12:45:18 +03:00
aports/testing/bees/bees.initd
Bradley Saulteaux 42422ba756 testing/bees: new aport
https://github.com/Zygo/bees
Best-Effort Extent-Same, a btrfs dedup agent
2019-02-05 14:14:27 +00:00

27 lines
678 B
Bash
Executable file

#!/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
}