configs/configure-zram.bash
2025-05-21 17:34:06 -05:00

39 lines
1 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
if [ $(whoami) == "root" ]; then
echo "Run as a normal user, not root"
exit 1
fi
sudo_remove_file_if_exists() {
if [ -f $1 ]; then
sudo rm $1
fi
}
# only fedora is up-to-date
command_exists() { type "$1" &>/dev/null; }
if command_exists "apt-get"; then
sudo apt-get install kitty -y
echo "Please install SchildiChat, nvim/neovim"
elif command_exists "dnf"; then
# remove old zram stuff
echo '' | sudo crontab -
sudo_remove_file_if_exists /etc/modules-load.d/zram.conf
sudo_remove_file_if_exists /etc/udev/rules.d/99-zram.rules
sudo sed -i 's/\/dev\/zram0 none swap defaults,discard,pri=160 0 0//g' /etc/fstab
sudo dnf install zram-generator -y
# set up zram
if [ -f /usr/lib/systemd/zram-generator.conf ]; then
sudo rm /usr/lib/systemd/zram-generator.conf
fi
if ! [ -d /usr/local/lib/systemd ]; then
sudo mkdir -p /usr/local/lib/systemd
fi
echo '[zram0]
zram-size = ram * 3' | sudo tee /usr/local/lib/systemd/zram-generator.conf
fi