2021-05-02 21:58:11 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# stdin: default config
|
|
|
|
# stdout: modified config
|
2021-07-02 12:50:24 +02:00
|
|
|
set -e
|
2021-05-03 13:26:54 +02:00
|
|
|
|
2021-11-13 17:43:42 +01:00
|
|
|
# save stdin in variable
|
2021-07-02 12:50:24 +02:00
|
|
|
stdin="$(cat)"
|
2021-05-03 13:26:54 +02:00
|
|
|
|
2021-06-12 20:47:54 +02:00
|
|
|
# assert MODULES is empty
|
2021-06-12 23:42:34 +02:00
|
|
|
echo "$stdin" | grep --quiet '^MODULES=()'
|
2021-05-03 13:26:54 +02:00
|
|
|
|
|
|
|
# assert HOOKS is as expected
|
2021-06-12 23:42:34 +02:00
|
|
|
echo "$stdin" | grep --quiet '^HOOKS=(base udev autodetect modconf block filesystems keyboard fsck)'
|
2021-05-03 13:26:54 +02:00
|
|
|
|
|
|
|
# assert no COMPRESSION option is enabled yet
|
2021-06-12 23:42:34 +02:00
|
|
|
! echo "$stdin" | grep --quiet '^COMPRESSION='
|
2021-05-03 13:26:54 +02:00
|
|
|
|
|
|
|
# assert lz4 COMPRESSION is uncommented
|
2021-06-12 23:42:34 +02:00
|
|
|
echo "$stdin" | grep --quiet '^#COMPRESSION="lz4"'
|
2021-05-03 13:26:54 +02:00
|
|
|
|
|
|
|
# 1) add to MODULES; 2 replace HOOKS; 3) uncomment lz4 COMPRESSION
|
2021-07-02 12:50:24 +02:00
|
|
|
echo "$stdin" | sed '
|
2021-05-03 13:26:54 +02:00
|
|
|
s|^MODULES=(|MODULES=(crc32c-intel |;
|
|
|
|
s|^#COMPRESSION="lz4".*$|COMPRESSION="lz4"|;
|
2021-05-03 22:17:59 +02:00
|
|
|
s|^HOOKS=(.*$|HOOKS=(base udev modconf block keyboard keymap encrypt lvm2 btrfs filesystems fsck resume)|
|
2021-07-02 12:50:24 +02:00
|
|
|
'
|