File: update-balance-usage-defaults.sh

package info (click to toggle)
btrfsmaintenance 0.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 388 kB
  • sloc: sh: 855; python: 50; makefile: 18
file content (45 lines) | stat: -rwxr-xr-x 852 bytes parent folder | download | duplicates (2)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh -e

# Switch unmodified defaults from versions up to 0.4 to new defaults from 0.5+
# Usage: $0 [target file]

file=
dryrun=false

if [ -f /etc/default/btrfsmaintenance ] ; then
	file=/etc/default/btrfsmaintenance
fi

if [ -f /etc/default/btrfsmaintenance ] ; then
	file=/etc/default/btrfsmaintenance
fi

if [ -f "$1" ]; then
	file="$1"
fi

if ! [ -f "$file" ]; then
	echo "ERROR: config file for btrfsmaintenance not found: $file"
	exit 1
fi

fixup()
{
	if $dryrun; then
		grep "^$1\$" "$file"
	else
		sed -i -e "s,$1,$2," "$file"
	fi
}

fixup	'## Default:     "1 5 10 20 30 40 50"'			\
	'## Default:     "5 10"'

fixup	'BTRFS_BALANCE_DUSAGE="1 5 10 20 30 40 50"'		\
	'BTRFS_BALANCE_DUSAGE="5 10"'

fixup	'## Default:     "1 5 10 20 30"'			\
	'## Default:     "5"'

fixup	'BTRFS_BALANCE_MUSAGE="1 5 10 20 30"'			\
	'BTRFS_BALANCE_MUSAGE="5"'