Renamed to bring functionality into the same namespace.
This commit is contained in:
parent
7b6023d8d8
commit
9fa1e37d93
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# the screen will blank after 3 minutes of inactivity on the TTY console.
|
||||||
|
NEWARG="consoleblank=3"
|
||||||
|
sudo sed -i -E "s|^(GRUB_CMDLINE_LINUX_DEFAULT=\"[^\"]*)\"|\1 ${NEWARG}\"|" /etc/default/grub
|
||||||
|
sudo update_grub
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# https://fabianlee.org/2020/01/18/docker-placing-limits-on-container-memory-using-cgroups/
|
||||||
|
|
||||||
|
# Internally Docker uses cgroups to limit memory resources, and in its simplest form is exposed as the flags “-m” and “–memory-swap” when bringing up a docker container.
|
||||||
|
|
||||||
|
# sudo docker run -it -m 8m --memory-swap 8m alpine:latest /bin/sh
|
||||||
|
|
||||||
|
# If you see the message above, or “WARNING: Your kernel does not support cgroup swap limit.”,
|
||||||
|
# then modify “/etc/default/grub” as below:
|
||||||
|
|
||||||
|
## Docker likes kernel swappiness support (on reboot)
|
||||||
|
sudo bash -c "perl -i -pe 's/GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"/g' /etc/default/grub"
|
||||||
|
|
||||||
|
sudo update-grub
|
||||||
|
# Now that your server supports swap limit capabilities in your docker run command you can use --memory-swappiness=0 and set --memory-swap equal to --memory. You also need to set -Des.bootstrap.mlockall=true on the docker run commandline.
|
||||||
|
|
||||||
|
# eg.
|
||||||
|
# https://stefanprodan.com/2016/elasticsearch-cluster-with-docker/
|
||||||
|
|
||||||
|
# docker run -d -p 9200:9200 \
|
||||||
|
# --name es-t0 \
|
||||||
|
# --network es-net \
|
||||||
|
# -v "$PWD/storage":/usr/share/elasticsearch/data \
|
||||||
|
# --cap-add=IPC_LOCK --ulimit nofile=65536:65536 --ulimit memlock=-1:-1 \
|
||||||
|
# --memory="2g" --memory-swap="2g" --memory-swappiness=0 \
|
||||||
|
# -e ES_HEAP_SIZE="1g" \
|
||||||
|
# es-t \
|
||||||
|
# -Des.bootstrap.mlockall=true \
|
||||||
|
# -Des.network.host=_eth0_ \
|
||||||
|
# -Des.discovery.zen.ping.multicast.enabled=false
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# test script for 256 color on the fb console. https://www.robmeerman.co.uk/unix/256colours
|
||||||
|
#wget -c -O /var/tmp/256color.pl https://gist.githubusercontent.com/hSATAC/1095100/raw/ee5b4d79aee151248bdafa8b8412497a5a688d42/256color.pl
|
||||||
|
|
||||||
|
# supported modes can be found at the grub console with 'vbeinfo' or 'videoinfo
|
||||||
|
# 0x17d 1920x1200x32 vga=381
|
||||||
|
# 0x17c 1920x1200x8 vga=380
|
||||||
|
|
||||||
|
## Add this to the /etc/default/grub GRUB_CMDLINE_LINUX_DEFAULT
|
||||||
|
gfxmode="1920x1200x32,1920x1200x8"
|
||||||
|
sed -i "s|^\(GRUB_GFXMODE=\).*|\1\"$gfxmode\"|" /etc/default/grub
|
||||||
|
sed -i '/^GRUB_GFXMODE=.*/ s/.*/&\nGRUB_GFXPAYLOAD_LINUX=\"keep\"/' /etc/default/grub
|
||||||
|
|
||||||
|
|
||||||
|
# DEPRICATED: vesafb requires a vga= on the kernel commandline.
|
||||||
|
#sed -i 's,^\(GRUB_CMDLINE_LINUX=\).*,\1'\"vga=381\"',' /etc/default/grub
|
||||||
|
|
||||||
|
mount /boot/grub
|
||||||
|
update-grub
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Set ignore bios throttling on the kernel commandline
|
||||||
|
NEWARG="processor.ignore_ppc=1"
|
||||||
|
sudo sed -i -E "s|^(GRUB_CMDLINE_LINUX_DEFAULT=\"[^\"]*)\"|\1 ${NEWARG}\"|" /etc/default/grub
|
||||||
|
sudo update_grub
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# prevent renaming of network interfaces by udev
|
||||||
|
#ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules
|
||||||
|
|
||||||
|
## Add this to the /etc/default/grub GRUB_CMDLINE_LINUX_DEFAULT
|
||||||
|
#sed -i 's,^\(GRUB_CMDLINE_LINUX=\).*,\1'\"net.ifnames=0\"',' /etc/default/grub
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,83 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# --- DEFAULTS ---
|
||||||
|
FILE="/etc/default/grub"
|
||||||
|
DRY_RUN=false
|
||||||
|
NEW_SETTING=""
|
||||||
|
|
||||||
|
# --- HELP FUNCTION ---
|
||||||
|
usage() {
|
||||||
|
echo "Usage: sudo $0 [OPTION] \"setting=value\""
|
||||||
|
echo "Example: sudo $0 \"consoleblank=3\""
|
||||||
|
echo ""
|
||||||
|
echo "Options:"
|
||||||
|
echo " -d, --dry-run Show changes without applying them"
|
||||||
|
echo " -h, --help Display this help message"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# --- ARGUMENT PARSING ---
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
-d | --dry-run)
|
||||||
|
DRY_RUN=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-h | --help)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
NEW_SETTING="$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Check if a setting was actually provided
|
||||||
|
if [[ -z "$NEW_SETTING" ]]; then
|
||||||
|
echo "❌ Error: No GRUB setting provided."
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- LOGIC ---
|
||||||
|
apply_grub_change() {
|
||||||
|
local TARGET="$1"
|
||||||
|
# Regex: Appends TARGET inside the quotes of GRUB_CMDLINE_LINUX_DEFAULT
|
||||||
|
local SED_LOGIC="/^GRUB_CMDLINE_LINUX_DEFAULT=/ s/\"\([^\"]*\)\"/\"\1 $TARGET\"/; s/ */ /g; s/ $TARGET\"/$TARGET\"/"
|
||||||
|
|
||||||
|
# 1. PRE-CHECK
|
||||||
|
if grep -q "$TARGET" "$FILE"; then
|
||||||
|
echo "ℹ️ SKIP: '$TARGET' already exists in $FILE."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 2. EXECUTION
|
||||||
|
if [ "$DRY_RUN" = true ]; then
|
||||||
|
echo "🔍 DRY RUN: Simulating '$TARGET' addition..."
|
||||||
|
grep "^GRUB_CMDLINE_LINUX_DEFAULT=" "$FILE" | sed "$SED_LOGIC"
|
||||||
|
else
|
||||||
|
# Ensure script is run as root for actual changes
|
||||||
|
if [[ $EUID -ne 0 ]]; then
|
||||||
|
echo "❌ Error: This script must be run with sudo to apply changes."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "💾 Backing up to $FILE.bak..."
|
||||||
|
cp "$FILE" "$FILE.bak"
|
||||||
|
|
||||||
|
echo "🔧 Applying '$TARGET' to $FILE..."
|
||||||
|
sed -i "$SED_LOGIC" "$FILE"
|
||||||
|
|
||||||
|
# 3. VERIFICATION & UPDATE
|
||||||
|
if grep -q "$TARGET" "$FILE"; then
|
||||||
|
echo "✅ SUCCESS: Updating bootloader..."
|
||||||
|
update-grub
|
||||||
|
else
|
||||||
|
echo "❌ ERROR: Failed to apply changes."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# --- EXECUTE ---
|
||||||
|
apply_grub_change "$NEW_SETTING"
|
||||||
Loading…
Reference in New Issue