-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
248 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
# Exit on error | ||
# If something goes wrong just stop. | ||
# it allows the user to see issues at once rather than having | ||
# scroll back and figure out what went wrong. | ||
set -e | ||
|
||
apt-get install -y --no-install-recommends linux-cpupower | ||
|
||
# Configure the CPU governor to "performance" | ||
CONFIG_FILE="/etc/default/cpupower" | ||
if [[ -f "$CONFIG_FILE" ]]; then | ||
sed -i 's/^CPU_DEFAULT_GOVERNOR=.*/CPU_DEFAULT_GOVERNOR="performance"/' "$CONFIG_FILE" | ||
else | ||
echo 'CPU_DEFAULT_GOVERNOR="performance"' > "$CONFIG_FILE" | ||
fi | ||
|
||
# Create the cpu governor systemd service file | ||
cp -v /mounted-github-repo/cpu-governor.service /etc/systemd/system/cpu-governor.service | ||
# Set permissions, enable, and start the service | ||
chmod 644 /etc/systemd/system/cpu-governor.service | ||
systemctl daemon-reload | ||
systemctl enable cpu-governor.service | ||
echo "CPU governor set to performance and service enabled" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
# Exit on error | ||
# If something goes wrong just stop. | ||
# it allows the user to see issues at once rather than having | ||
# scroll back and figure out what went wrong. | ||
set -e | ||
|
||
|
||
# Define the backup file | ||
FSTAB="/etc/fstab" | ||
|
||
# Process /etc/fstab | ||
while IFS= read -r line; do | ||
# Skip comments and empty lines | ||
if [[ "$line" =~ ^# ]] || [[ -z "$line" ]]; then | ||
echo "$line" | ||
continue | ||
fi | ||
|
||
# Match lines with ext4, xfs, or btrfs filesystems | ||
if [[ "$line" =~ ^(\S+)\s+(\S+)\s+(ext4|xfs|btrfs)\s+([^#]*)\s+(\d+)\s+(\d+)$ ]]; then | ||
DEVICE="${BASH_REMATCH[1]}" | ||
MOUNTPOINT="${BASH_REMATCH[2]}" | ||
FSTYPE="${BASH_REMATCH[3]}" | ||
OPTIONS="${BASH_REMATCH[4]}" | ||
DUMP="${BASH_REMATCH[5]}" | ||
PASS="${BASH_REMATCH[6]}" | ||
|
||
# Check if "noatime" is already present | ||
if [[ ! "$OPTIONS" =~ noatime ]]; then | ||
OPTIONS="$OPTIONS,noatime" | ||
fi | ||
|
||
# Check if "nodiratime" is already present | ||
if [[ ! "$OPTIONS" =~ nodiratime ]]; then | ||
OPTIONS="$OPTIONS,nodiratime" | ||
fi | ||
|
||
# Print the updated line | ||
echo -e "$DEVICE\t$MOUNTPOINT\t$FSTYPE\t$OPTIONS\t$DUMP\t$PASS" | ||
else | ||
# Print lines that do not match the filesystem types | ||
echo "$line" | ||
fi | ||
done < "$FSTAB" > "${FSTAB}.tmp" | ||
|
||
# Replace the original fstab with the updated one | ||
mv "${FSTAB}.tmp" "$FSTAB" | ||
echo "Updated /etc/fstab with noatime and nodiratime options." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
# Exit on error | ||
# If something goes wrong just stop. | ||
# it allows the user to see issues at once rather than having | ||
# scroll back and figure out what went wrong. | ||
set -e | ||
|
||
|
||
# Load I2C, SPI, and I2S kernel modules and make persistent | ||
for module in i2c-dev spidev; do | ||
if ! grep -q "$module" /etc/modules; then | ||
echo "$module" >> /etc/modules | ||
fi | ||
modprobe "$module" | ||
done | ||
|
||
# Enable I2C, SPI, and I2S in /boot/config.txt | ||
CONFIG_FILE="/boot/config.txt" | ||
|
||
declare -A dtparams=( | ||
["dtparam=i2c_arm"]="on" | ||
["dtparam=spi"]="on" | ||
["dtparam=i2s"]="on" | ||
) | ||
|
||
for key in "${!dtparams[@]}"; do | ||
value="${dtparams[$key]}" | ||
if grep -q "^${key}=" "$CONFIG_FILE"; then | ||
sed -i "s|^${key}=.*|${key}=${value}|" "$CONFIG_FILE" | ||
else | ||
echo "${key}=${value}" >> "$CONFIG_FILE" | ||
fi | ||
done | ||
|
||
echo "Kernel modules and Device Tree parameters configured." |
Oops, something went wrong.