Squashed initial commit

This commit is contained in:
2024-09-10 13:47:29 -04:00
commit 8ebb6ad265
6221 changed files with 2512206 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
#!/usr/bin/env bash
# Generic btrfsmaintenance install script
# Copyright 2021 Bryan C. Roessler
parent="${BASH_SOURCE[0]}"
parent=${parent%/*}
[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1
is_root
# Optionally provide the config directory manually
if [[ $# -lt 1 ]]; then
if [[ -d /etc/sysconfig ]]; then
CONFDIR=/etc/sysconfig
elif [[ -d /etc/default ]]; then
CONFDIR=/etc/default
else
echo "Cannot detect sysconfig directory, please specify manually"
exit 1
fi
else
CONFDIR="$1"
fi
# This is hardcoded by the btrfs maintenance scripts, change at your peril
INSTALLDIR="/usr/share/btrfsmaintenance"
# Backup existing installation
if [[ -d "$INSTALLDIR" ]]; then
TEMPDIR="/tmp/btrfs-maintenance.bk"
echo "Moving existing $INSTALLDIR to $TEMPDIR"
[[ -d "$TEMPDIR" ]] && rm -rf "$TEMPDIR"
mv "$INSTALLDIR" "$TEMPDIR"
fi
git clone "https://github.com/kdave/btrfsmaintenance.git" "$INSTALLDIR"
# Quirks
if [[ -e "/etc/os-release" ]]; then
source "/etc/os-release"
if [[ "$ID" == "centos" && "$VERSION_ID" == "7" ]]; then
sed -i 's/flock --verbose/flock' "$INSTALLDIR"/btrfsmaintenance-functions
fi
fi
chmod 755 "$INSTALLDIR"/*.sh
# Copy config file
[[ ! -f "$CONFDIR"/btrfsmaintenance ]] && install -oroot -groot -m644 "$INSTALLDIR"/sysconfig.btrfsmaintenance "$CONFDIR"/btrfsmaintenance
# Copy systemd files and reload
for f in "$INSTALLDIR"/btrfs-*.{service,timer}; do
cp "$f" /usr/lib/systemd/system/
done
systemctl daemon-reload
# Optionally, start and enable the services
# systemctl enable --now btrfs-scrub
exit $?