Skip to content

Instantly share code, notes, and snippets.

@Juma7C9
Juma7C9 / fancontrol.sh
Created July 26, 2023 19:10
Simple script to control pwm fans using a defined curve; requires a companion script to actually send the correct command to the fan controller.
#!/bin/bash
INTERVAL="10s"
INPUT_DRIVER="coretemp"
#TEMP_PATH="/sys/class/hwmon/hwmon3/temp1_input"
FAN_CMD="/usr/bin/fan.sh"
# Find correct input temperature path
for hwmon in `ls /sys/class/hwmon/`; do
driver=$(</sys/class/hwmon/$hwmon/name)
@Juma7C9
Juma7C9 / clear-pacman-cache
Created July 26, 2023 19:07
Simple script to delete pacman package files older than some period, printing the freed space
#!/bin/bash
CACHE_PATH=/var/cache/pacman/pkg
PRESERVE_MONTHS=3
DELETED_SIZE=$(/usr/bin/find . ! -newermt "$PRESERVE_MONTHS months ago" -ls | awk -F' ' 'BEGIN {sum=0} {sum+=$7} END {print sum}' | numfmt --to=iec-i)B
/usr/bin/echo "Deleting $DELETED_SIZE of package files older than $PRESERVE_MONTHS months..."
/usr/bin/find $CACHE_PATH ! -newermt "$PRESERVE_MONTHS months ago" -delete
# Custom scancode-keycode mappings for Interfree/BTC 9000 keyboard
# Old udev ABI (systemd<220)
#keyboard:name:AT Translated Set 2 keyboard:*
# New udev ABI (systemd>=220)
evdev:name:AT Translated Set 2 keyboard:*
KEYBOARD_KEY_de=power
KEYBOARD_KEY_df=sleep
KEYBOARD_KEY_e3=wakeup
KEYBOARD_KEY_ae=help
#!/bin/bash
# upower-ksysguardd.sh - Script to poll upower tool with a ksysguardd
# compatible interface. Useful with kde/plasma's ksysguard system monitor.
# To use it, launch ksysguard, then File -> Connect Host, and choose
# "Custom command" (see https://techbase.kde.org/Development/Tutorials/Sensors).
#
# Copyright (C) 2017 Juma7C9
#
# This program is free software; you can redistribute it and/or modify
@Juma7C9
Juma7C9 / make_le_cert.sh
Last active March 23, 2017 15:16
Request a letsencrypt cert for multiple domain and related subdomain and encrypt the relative key
#!/bin/bash
# Request a letsencrypt cert for multiple domain and related subdomain, for example
# foo.domain.com, foo.domain.com
# bar.domain.net, bar.domain.net
# and encrypt the generated private key for security purposes.
# The MIT License (MIT)
# Copyright (c) 2016, 2017 Juma7C9
#
/* Simple program to test memory allocation - goes on until killed */
#include "stdlib.h"
#include "stdio.h"
#define _256M 64*1024*1024
int* p;
int i=0, j;
int main(){
@Juma7C9
Juma7C9 / fan.sh
Last active July 26, 2023 19:14
Start/stop fans on Asus Zenbook UX32A
#!/bin/bash
# fan.sh - Script to stop and restart (setting to auto) fans on Asus Zenbook UX32A
# (should work also on other UX-series models - see http://goo.gl/BKcWm1)
# Requires acpi_call kernel module - see https://github.com/mkottman/acpi_call/)
# USAGE: fan.sh auto|stop|full
# Copyright (C) 2014-2023 Juma7C9
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@Juma7C9
Juma7C9 / net_speed.sh
Created October 12, 2013 20:54
Simple real time network traffic monitor
#!/bin/bash
# net_speed.sh -- A simple real time network traffic monitor
# USAGE: net_speed.sh interface
# Copyright (C) 2013 Juma7C9
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
@Juma7C9
Juma7C9 / report.sh
Created October 5, 2013 19:27
Script to report number of failed/suceeded ssh login attempts, and most banned IPs by fail2ban. Paths are the ones used by CentOS 6, change the if you are using another distro. Usage: ./report.sh [day]
#!/bin/bash
# report.sh - Script to report number of ssh login attempts, and banned IPs by fail2ban.
# Copyright (C) 2013 Juma7C9
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
@Juma7C9
Juma7C9 / iptables_conf.sh
Last active December 1, 2016 17:01
Script for loading and reloading iptables
#!/bin/bash
# Script to configure Linux' iptables and ip6tables
# setting the specified ports open and closing the rest.
# Optionally enables Fail2Ban on IPv4 (as the latest
# stables version [0.9.5] does not support it yet).
# The MIT License (MIT)
# Copyright (c) 2013-2016 Juma7C9
#