Skip to content

Instantly share code, notes, and snippets.

View themactep's full-sized avatar

Paul Philippov themactep

View GitHub Profile
@themactep
themactep / dusk2dawn.sh
Last active April 28, 2024 22:27
Generate cron job lines from sunrise and sunset time provided by api.sunrise-sunset.org
#!/bin/sh
#
# Set cron jobs by sunset and sunrise
# 2023, Paul Philippov <paul@themactep.com>
#
# Do not forget to tip the API provider!
# https://www.buymeacoffee.com/sunrisesunsetapi
#
# Geographic coordinates of your place
@themactep
themactep / chopchop.rb
Last active March 3, 2024 10:09
Firmware spitter
#!/bin/ruby
# frozen_string_literal: true
#
# Firmware spitter
# Paul Philippov <paul@themactep.com>
#
# 2022-11-16: Initial version
# 2023-04-16: Support for dd older than v9.0
# Use the last found mtdparts
# 2024-03-02: Extract an arbitrary range of addresses
@themactep
themactep / ipc-linux-hijacker.sh
Last active February 15, 2024 00:42
Repack firmware with a blank root password.
#!/bin/bash
#
# Embedded Linux root hijacker
#
# This script repacks firmware replacing existing root password with a blank password.
# Tested on HiSilicon and Ingenic firmware dumps from NOR SPI flash chips.
# Use at your own risk.
#
# Paul Philppov <paul@themactep.com>
# 2023-11-21: Initial release
@themactep
themactep / ansi-colors.sh
Created January 18, 2024 03:29
ANSI color codes
#!/bin/bash
#
# ANSI color codes
# 2019 Paul Philippov <paul@themactep.com>
for k in {1..9}; do
for i in {0..9}; do
echo -en " \e[1;${k}${i}m$(printf "%02s" "${k}${i}")\e[0m"
done
echo
@themactep
themactep / cn2en.sh
Created January 18, 2024 03:18
Translate Chinese text file to English.
#!/bin/bash
#
# cn2en.sh
# Translate Chinese text file to English.
#
# 2020-09-06, Paul Philippov <paul@themactep.com>
if ! command -v trans >/dev/null; then
echo "Translate Shell is required. https://www.soimort.org/translate-shell/"
echo "wget git.io/trans && chmod +x ./trans"
#!/bin/bash
#
# OpenIPC full firmware file assembler.
# Creates a file suitable for programming a flash chip.
#
# Example:
# ./compile4programmer.sh uboot.bin uImage rootfs.squashfs 8
#
# Running this command will produce a new binary file
# full4programmer-8MB.bin or full4programmer-16MB.bin
@themactep
themactep / openipc-toolchains-updater.sh
Created December 26, 2023 05:45
Script to retrieve the latest toolchains for building OpenIPC firmware.
#!/bin/bash
#
# OpenIPC Toolchains Updater
#
# This script retrieves the latest toolchains for building OpenIPC firmware.
# Execute the script in the directory where you want to store the toolchains
# locally, for example, /opt/toolchains/openipc/. You can re-run the script
# to update the toolchains.
#
# 2021, Paul Philippov <paul@themactep.com>
@themactep
themactep / test-video-delay.sh
Last active December 17, 2023 05:19
IP camera video stream delay test
#!/bin/bash
#
# GStreamer based video player for glass-on-glass tests.
# Use it together with https://openipc.org/tools/high-resolution-timer
#
protocol="$1"
codec="$2"
show_help_and_exit() {
#!/bin/sh
BR_OUTPUT_DIR=/path/to/openipc/output
CROSS_PATH=${BR_OUTPUT_DIR}/host/bin
CROSS_COMPILE=$(readlink -f $CROSS_PATH)/mipsel-openipc-linux-musl-
CC=${CROSS_COMPILE}gcc
make ARCH=mips CC="${CC}" \
CROSS_COMPILE="${CROSS_COMPILE}" \
@themactep
themactep / ircut.sh
Last active October 16, 2023 00:53
Manua IR filter control for OpenIPC camera
#!/bin/sh
pin1=$(cli -g .nightMode.irCutPin1)
pin2=$(cli -g .nightMode.irCutPin2)
if [ -z "$pin1" ]; then
echo "IRCUT pin 1 is not set!"
echo "Please set it by running cli -s .nightMode.irCutPin1 XX, where XX is a GPIO pin number."
exit 1
fi