first commit
This commit is contained in:
30
roles/zram/config.sh
Executable file
30
roles/zram/config.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
source "${PROJECT_DIR:?}/lib.sh"
|
||||
enable_strict_mode
|
||||
|
||||
cat <<'EOM'
|
||||
|
||||
=> ZRAM
|
||||
|
||||
EOM
|
||||
|
||||
ZFILE="/etc/default/zramswap"
|
||||
|
||||
if [[ ! -f "$ZFILE" ]]; then
|
||||
write_text_file_if_changed $'# Configuration minimale pour zramswap\nALGO=zstd\nPERCENT=50\n' "$ZFILE" >/dev/null || true
|
||||
fi
|
||||
|
||||
if grep -q '^ALGO=lz4' "$ZFILE" 2>/dev/null; then
|
||||
sed -i 's/^ALGO=lz4/ALGO=zstd/' "$ZFILE"
|
||||
elif ! grep -q '^ALGO=' "$ZFILE" 2>/dev/null; then
|
||||
echo 'ALGO=zstd' >>"$ZFILE"
|
||||
fi
|
||||
|
||||
if ! grep -q '^PERCENT=' "$ZFILE" 2>/dev/null; then
|
||||
echo 'PERCENT=50' >>"$ZFILE"
|
||||
fi
|
||||
|
||||
restart_service_if_present zramswap
|
||||
if ! systemctl is-active --quiet zramswap.service; then
|
||||
echo 'Warning: zramswap.service not active' >&2
|
||||
fi
|
||||
3
roles/zram/packages.list
Normal file
3
roles/zram/packages.list
Normal file
@@ -0,0 +1,3 @@
|
||||
ROLE_PACKAGES=(
|
||||
"zram-tools"
|
||||
)
|
||||
Reference in New Issue
Block a user