Skip to content

Instantly share code, notes, and snippets.

@KekTuSx
KekTuSx / tlp-limit-cpu-freq.sh
Last active September 5, 2022 09:26
Sets upper limit for CPU frequency via TLP. EXPERIMENTAL
#!/bin/bash
#
# Sets upper limit for CPU clock speed with TLP config.
set -e
# Variables
#####################
reload=false
conf="/etc/tlp.conf"
PS3="Select max CPU frequency: "
@KekTuSx
KekTuSx / which-pkg-manager.sh
Created August 24, 2022 17:54
Checks which package manager to use.
#!/bin/bash
declare -A pkgman
pgkman[apt]=$(which apt)
pkgman[yum]=$(which yum)
pkgman[pacman]=$(which pacman)
for i in "${!pkgman[@]}" # takes index of array
do
# apt (debian, ubuntu, mint...)
@KekTuSx
KekTuSx / vm-template.xml
Created August 23, 2022 09:13
An XML template for creating VMs with virt-install, used in my automation projects.
<domain type='kvm'>
<name>Virtual</name>
<memory unit='MiB'>2048</memory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' machine='pc-q35-5.2'>hvm</type>
<boot dev='hd'/>
</os>
<cpu mode='host-model' check='none'/>
<devices>
@KekTuSx
KekTuSx / disk-check.sh
Last active August 23, 2022 10:44
A bash script that checks all connected disks with Smartmontools short test.
#!/bin/bash
#
# Checks all connected disks for errors with smartmontools
# Variables
###########
date=null # time for logs
diskcount=$(lsblk -l | grep -c 'disk') # counts all connected disks
disklist=$(lsblk -l | grep 'disk' | grep -oh "[[:alpha:]]*sd[[:alpha:]]*") # create a list of all connected disks https://stackoverflow.com/a/15997066
@KekTuSx
KekTuSx / ubuntu-cleanup.sh
Last active August 23, 2022 14:41
Removes telemetery and tracking from Ubuntu operating systems, then blocks them from installing.
#!/bin/bash
sudo apt purge snapd ubuntu-report popularity-contest apport whoopsie apport-symptoms && sudo apt-mark hold snapd ubuntu-report popularity-contest apport whoopsie apport-symptoms