diff --git a/.gitignore b/.gitignore index 7a91af7..d8ca283 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ html/ latex/ make.log make.log.new +localconf diff --git a/Makefile b/Makefile index 35378fb..f06f231 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,11 @@ PREFIX ?= / +LIBEXEC_PREFIX ?= $(PREFIX)/usr/lib/bees + +MARKDOWN := $(shell which markdown markdown2 markdown_py 2>/dev/null) +MARKDOWN ?= markdown + +# allow local configuration to override above variables +-include localconf MARKDOWN := $(shell which markdown markdown2 markdown_py 2>/dev/null) MARKDOWN ?= markdown @@ -21,6 +28,9 @@ test: ## Run tests test: lib src $(MAKE) -C test +scripts/beesd: scripts/beesd.in + sed -e's#@LIBEXEC_PREFIX@#$(LIBEXEC_PREFIX)#' -e's#@PREFIX@#$(PREFIX)#' "$<" >"$@" + README.html: README.md $(MARKDOWN) README.md > README.html.new mv -f README.html.new README.html @@ -28,10 +38,11 @@ README.html: README.md install: ## Install bees + libs install: lib src test install -Dm644 lib/libcrucible.so $(PREFIX)/usr/lib/libcrucible.so - install -Dm755 bin/bees $(PREFIX)/usr/bin/bees + install -Dm755 bin/bees $(LIBEXEC_PREFIX)/bees install_scripts: ## Install scipts - install -Dm755 scripts/beesd $(PREFIX)/usr/bin/beesd +install_scripts: scripts/beesd + install -Dm755 scripts/beesd $(PREFIX)/usr/sbin/beesd install -Dm644 scripts/beesd.conf.sample $(PREFIX)/etc/bees/beesd.conf.sample install -Dm644 scripts/beesd@.service $(PREFIX)/lib/systemd/system/beesd@.service diff --git a/scripts/beesd.conf.sample b/scripts/beesd.conf.sample index 7245c1b..53060fa 100644 --- a/scripts/beesd.conf.sample +++ b/scripts/beesd.conf.sample @@ -2,8 +2,11 @@ ## https://github.com/Zygo/bees ## It's a default values, change it, if needed +# How to use? +# Copy this file to a new file name and adjust the UUID below + # Which FS will be used -UUID=5d3c0ad5-bedf-463d-8235-b4d4f6f99476 +UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ## System Vars # Change carefully diff --git a/scripts/beesd b/scripts/beesd.in similarity index 92% rename from scripts/beesd rename to scripts/beesd.in index cfe256c..f99ea09 100755 --- a/scripts/beesd +++ b/scripts/beesd.in @@ -1,5 +1,4 @@ #!/bin/bash -# /usr/bin/beesd ## Helpful functions INFO(){ echo "INFO:" "$@"; } @@ -13,15 +12,15 @@ export CONFIG_FILE export UUID AL16M readonly AL16M="$((16*1024*1024))" -readonly CONFIG_DIR=/etc/bees/ +readonly CONFIG_DIR=@PREFIX@/etc/bees/ ## Pre checks { [ ! -d "$CONFIG_DIR" ] && ERRO "Missing: $CONFIG_DIR" - [ "$UID" == "0" ] || ERRO "Must be runned as root" + [ "$UID" == "0" ] || ERRO "Must be run as root" } -command -v bees &> /dev/null || ERRO "Missing 'bees' command" +command -v @LIBEXEC_PREFIX@/bees &> /dev/null || ERRO "Missing 'bees' agent" ## Parse args UUID="$1" @@ -123,6 +122,6 @@ filter_path(){ fi } -bees "$MNT_DIR" 3>&1 2>&1 | filter_time | filter_path +@LIBEXEC_PREFIX@/bees "$MNT_DIR" 3>&1 2>&1 | filter_time | filter_path exit 0 diff --git a/scripts/beesd@.service b/scripts/beesd@.service index da73864..55df99c 100644 --- a/scripts/beesd@.service +++ b/scripts/beesd@.service @@ -3,12 +3,22 @@ Description=Bees - Best-Effort Extent-Same, a btrfs deduplicator daemon: %i After=local-fs.target [Service] -ExecStart=/usr/bin/beesd %i +Type=simple +ExecStart=/usr/sbin/beesd %i Nice=19 +KillMode=control-group +KillSignal=SIGTERM +CPUShares=128 +StartupCPUShares=256 +BlockIOWeight=100 +StartupBlockIOWeight=250 IOSchedulingClass=idle +IOSchedulingPriority=7 +CPUSchedulingPolicy=batch +Nice=19 +Restart=on-abnormal CPUAccounting=true MemoryAccounting=true -# CPUQuota=95% [Install] WantedBy=local-fs.target