diff options
Diffstat (limited to 'src/generate-firefox-unit')
-rwxr-xr-x | src/generate-firefox-unit | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/generate-firefox-unit b/src/generate-firefox-unit new file mode 100755 index 0000000..c285ffc --- /dev/null +++ b/src/generate-firefox-unit | |||
@@ -0,0 +1,51 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | INPUT_FILE=$1 | ||
4 | OUTPUT_FILE=$2 | ||
5 | |||
6 | die() { printf "%s: Error: %s\n" "$0" "$*" >&2; exit 1; } | ||
7 | |||
8 | # Test DEVICE WRITE OPS BY WRITEOPS | ||
9 | test_write_ops() | ||
10 | { | ||
11 | if ! [ -e "$1" ] | ||
12 | then | ||
13 | mkdir -p "$(dirname "$1")" | ||
14 | sync | ||
15 | begin=$(date +%s%N) | ||
16 | dd if=/dev/urandom of="$DIR"/urandom.out bs=1M count=300 | ||
17 | sync | ||
18 | end=$(date +%s%N) | ||
19 | ops=$(( (end - begin) / 1000000000 )) | ||
20 | rm "$DIR"/urandom.out | ||
21 | echo "$ops" > "$1" | ||
22 | fi | ||
23 | cat "$1" | ||
24 | } | ||
25 | |||
26 | DIR=~/.mozilla | ||
27 | READ_OPS=1G | ||
28 | WRITE_OPS=$READ_OPS | ||
29 | CONFDIR=$HOME/.config/firestart | ||
30 | |||
31 | if [ -e "$CONFDIR"/conf ] | ||
32 | then | ||
33 | . "$CONFDIR"/conf | ||
34 | fi | ||
35 | |||
36 | WRITE_OPS=$(test_write_ops "$CONFDIR"/diskspeed.dat) | ||
37 | WRITE_OPS=${WRITE_OPS%.*} | ||
38 | READ_OPS=$WRITE_OPS | ||
39 | |||
40 | [ -e "$DIR" ] || die "does not exist: $DIR" | ||
41 | [ -d "$DIR" ] || die "not a directory: $DIR" | ||
42 | |||
43 | DEV=$(echo $(findmnt --target "$DIR" -o MAJ:MIN -n)) | ||
44 | [ "$DEV" ] || die "could not determine backing device for $DIR" | ||
45 | |||
46 | IOReadIOPSMax="$DEV $READ_OPS" | ||
47 | IOWriteIOPSMax="$DEV $WRITE_OPS" | ||
48 | |||
49 | sed -e "s/^IOReadIOPSMax *=.*/IOReadIOPSMax = $IOReadIOPSMax/" \ | ||
50 | -e "s/^IOWriteIOPSMax *=.*/IOWriteIOPSMax = $IOWriteIOPSMax/" \ | ||
51 | < "$INPUT_FILE" > "$OUTPUT_FILE" | ||