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