From 6e5d672ea04fb8c89ce9e91cf4c9a53fbb8c2f81 Mon Sep 17 00:00:00 2001 From: Evgeny Sorokin Date: Sat, 6 Jan 2024 03:41:49 +0000 Subject: add something --- .local/bin/awesome-trace-logs.sh | 10 +++++++ .local/bin/intel-turbo.sh | 30 +++++++++++++++++++ .local/bin/mikrotik-bootp-flash.sh | 24 ++++++++++++++++ .local/bin/mount-luks-partition-dump.sh | 30 +++++++++++++++++++ .local/bin/ps-pull | 51 +++++++++++++++++++++++++++++++++ .local/bin/trackpoint-setup.sh | 15 ++++++++++ 6 files changed, 160 insertions(+) create mode 100755 .local/bin/awesome-trace-logs.sh create mode 100755 .local/bin/intel-turbo.sh create mode 100755 .local/bin/mikrotik-bootp-flash.sh create mode 100755 .local/bin/mount-luks-partition-dump.sh create mode 100755 .local/bin/ps-pull create mode 100755 .local/bin/trackpoint-setup.sh (limited to '.local/bin') diff --git a/.local/bin/awesome-trace-logs.sh b/.local/bin/awesome-trace-logs.sh new file mode 100755 index 0000000..f76f253 --- /dev/null +++ b/.local/bin/awesome-trace-logs.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +pid=$(ps -ef | awk '$8=="awesome" {print $2}') +max_str_length=8192 + +strace -e trace=write -s${max_str_length} -p${pid} 2>&1 \ + | grep --line-buffered --color=no "write([12], " \ + | sed -u 's/write([12], "\(.*\)", [0-9]\+) \+= [0-9]\+$/\1/g' \ + | sed -u 's/\\n/\n/g' \ + | sed -u 's/\\t/\t/g' diff --git a/.local/bin/intel-turbo.sh b/.local/bin/intel-turbo.sh new file mode 100755 index 0000000..57836e0 --- /dev/null +++ b/.local/bin/intel-turbo.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +bold=$(tput bold) +red=$(tput setaf 1) +green=$(tput setaf 2) +reset=$(tput sgr0) +syspath="/sys/devices/system/cpu/intel_pstate/no_turbo" + +case "$1" in + on) + echo 0 > $syspath + ;; + + off) + echo 1 > $syspath + ;; + + *) + echo "Usage: $0 on|off" + echo + echo -n "Current turbo status: " + + status=$(cat $syspath) + if [ "$status" = "0" ]; then + echo "${bold}${green}enabled${reset}" + else + echo "${bold}${red}disabled${reset}" + fi + ;; +esac diff --git a/.local/bin/mikrotik-bootp-flash.sh b/.local/bin/mikrotik-bootp-flash.sh new file mode 100755 index 0000000..48360a9 --- /dev/null +++ b/.local/bin/mikrotik-bootp-flash.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +IFNAME=enp0s25 + +iptables -P INPUT ACCEPT + +ip addr replace 192.168.1.10/24 dev $IFNAME +ip link set dev $IFNAME up + +/usr/sbin/dnsmasq \ + --no-daemon \ + --listen-address 192.168.1.10 \ + --bind-interfaces \ + -p0 \ + --dhcp-authoritative \ + --dhcp-range=192.168.1.100,192.168.1.200 \ + --bootp-dynamic \ + --dhcp-boot=openwrt-23.05.2-ipq40xx-mikrotik-mikrotik_hap-ac2-initramfs-kernel.bin \ + --log-dhcp --log-debug \ + --enable-tftp \ + --tftp-root=$(pwd) + +iptables -P INPUT DROP + diff --git a/.local/bin/mount-luks-partition-dump.sh b/.local/bin/mount-luks-partition-dump.sh new file mode 100755 index 0000000..2382d15 --- /dev/null +++ b/.local/bin/mount-luks-partition-dump.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +error() { + echo "error: $@" + exit 1 +} + +set -e + +DUMP="$1" +MOUNTPOINT=/media/luks-dump + +[ -d "$MOUNTPOINT" ] && error "$MOUNTPOINT already exists, you must delete it first" +[ $EUID -ne 0 ] && error "must be run as root" +[ -f "$DUMP" ] || error "'$DUMP' is not a file or is not readable" + +DEVICE=$(losetup -f) +losetup $DEVICE "$DUMP" + +cryptsetup luksOpen $DEVICE luks-dump +mkdir $MOUNTPOINT +mount /dev/mapper/luks-dump $MOUNTPOINT + +echo "press enter when done..." +read + +umount $MOUNTPOINT +rmdir $MOUNTPOINT +cryptsetup luksClose luks-dump +losetup -d $DEVICE diff --git a/.local/bin/ps-pull b/.local/bin/ps-pull new file mode 100755 index 0000000..f25ba48 --- /dev/null +++ b/.local/bin/ps-pull @@ -0,0 +1,51 @@ +#!/bin/sh + +set -e + +git_branch() { + git rev-parse --symbolic-full-name --abbrev-ref HEAD +} + +[ -d .git ] || { + echo "error: not a git repository" + exit 1 +} + +[ -d .idea ] || { + echo "error: not a jetbrains repository" + exit 1 +} + +PREFETCH_HOOK=.git/hooks/prefetch +CUR_BRANCH=$(git_branch) +TARGET_BRANCH="$CUR_BRANCH" + +while getopts b: option +do + case "${option}" + in + b) + TARGET_BRANCH=${OPTARG} + ;; + + *) + : + ;; + esac +done + +if [ "$CUR_BRANCH" != "$TARGET_BRANCH" ]; then + echo "new target branch: $TARGET_BRANCH" +fi + +git add . +git reset --hard +[ -x "$PREFETCH_HOOK" ] && "./$PREFETCH_HOOK" +git fetch -a dev +if [ "$CUR_BRANCH" != "$TARGET_BRANCH" ]; then + git checkout "$TARGET_BRANCH" -- +fi +git reset --hard dev/$TARGET_BRANCH +#git pull dev $TARGET_BRANCH + +echo "current branch: $(git_branch)" diff --git a/.local/bin/trackpoint-setup.sh b/.local/bin/trackpoint-setup.sh new file mode 100755 index 0000000..e06c529 --- /dev/null +++ b/.local/bin/trackpoint-setup.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +TP="TPPS/2 IBM TrackPoint" + +xinput set-prop "$TP" "Evdev Wheel Emulation" 1 +xinput set-prop "$TP" "Evdev Wheel Emulation Button" 2 +xinput set-prop "$TP" "Evdev Wheel Emulation Timeout" 200 +xinput set-prop "$TP" "Evdev Wheel Emulation Axes" 6 7 4 5 + +xinput set-prop "$TP" "Device Accel Profile" 2 +xinput set-prop "$TP" "Device Accel Constant Deceleration" 0.8 +xinput set-prop "$TP" "Device Accel Adaptive Deceleration" 2.0 + +xinput set-ptr-feedback "$TP" 0 20 15 # acceleration factor = 20/10 + -- cgit v1.2.3