summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDebian Live user <user@debian-BULLSEYE-live-builder-AMD64>2023-04-28 23:09:09 -0400
committerDebian Live user <user@debian-BULLSEYE-live-builder-AMD64>2023-04-28 23:09:09 -0400
commitfa4b765120fa7638e8737d6783eedeb1a65fe83c (patch)
tree14d4239ffa8d6420365a5fbef664e550fe49f3ee
parent4221ca2879b2d6f10ffe59d1c710b65f3cd6848c (diff)
reimplement firestart
-rwxr-xr-xfirestart63
1 files changed, 7 insertions, 56 deletions
diff --git a/firestart b/firestart
index abb15f3..1daf05c 100755
--- a/firestart
+++ b/firestart
@@ -1,63 +1,14 @@
1#!/bin/bash 1#!/bin/bash
2 2
3die() { printf "%s: Error: %s\n" "$0" "$*" >&2; exit 1; }
4
5# Test DEVICE WRITE OPS BY WRITEOPS
6test_write_ops()
7{
8 if ! [ -e "$1" ]
9 then
10 mkdir -p "$(dirname "$1")"
11 sync
12 begin=$(date +%s%N)
13 dd if=/dev/urandom of="$DIR"/urandom.out bs=1M count=300
14 sync
15 end=$(date +%s%N)
16 ops=$(( (end - begin) / 1000000000 ))
17 rm "$DIR"/urandom.out
18 echo "$ops" > "$1"
19 fi
20 cat "$1"
21}
22
23CMD=firefox 3CMD=firefox
24UNIT=$CMD 4UNIT=$CMD@$DISPLAY
25DIR=~/.mozilla
26MEMORY_MAX=50%
27READ_OPS=1G
28WRITE_OPS=$READ_OPS
29CONFDIR=$HOME/.config/firestart
30
31if [ -e "$CONFDIR"/conf ]
32then
33 . "$CONFDIR"/conf
34fi
35
36WRITE_OPS=$(test_write_ops "$CONFDIR"/diskspeed.dat)
37WRITE_OPS=${WRITE_OPS%.*}
38READ_OPS=$WRITE_OPS
39 5
40if systemctl --user is-active "$UNIT" >/dev/null 6if systemctl --user is-active "$UNIT" >/dev/null
41then 7then
42 exec "$CMD" "$@" # Asks existing firefox to open a new window. 8 # Asks existing firefox to open a new window. Technically is racy,
43 exit 9 # since the unit could become active after our check.
10 exec "$CMD" "$@"
11else
12 systemctl --user reset-failed "$UNIT" 2>/dev/null
13 systemctl --user start "$UNIT"
44fi 14fi
45
46[ -e "$DIR" ] || die "does not exist: $DIR"
47[ -d "$DIR" ] || die "not a directory: $DIR"
48
49DEV=$(echo $(findmnt --target "$DIR" -o MAJ:MIN -n))
50[ "$DEV" ] || die "could not determine backing device for $DIR"
51
52firefox-io-slayer launch-unit
53
54systemctl --user reset-failed "$UNIT" 2>/dev/null
55systemd-run --user \
56 --unit "$UNIT" \
57 --property PassEnvironment='DISPLAY XAUTHORITY' \
58 --property MemoryMax="$MEMORY_MAX" \
59 --property IOReadIOPSMax="$DEV $READ_OPS" \
60 --property IOWriteIOPSMax="$DEV $WRITE_OPS" \
61 --property Restart="on-failure" \
62 -- \
63 "$CMD" "$@"