Skip to content

Instantly share code, notes, and snippets.

@5p0ng3b0b
5p0ng3b0b / functions.sh
Created March 23, 2025 09:42
Useful bash function collection
#!/bin/bash
#dbdl: Download file from dropbox link
dbdl(){ DL=${1/=0/=1} FN=$(sed -e 's|?.*0||' -e 's|.*/||' <<<$1); wget -q --show-progress $DL -O $FN; }
@5p0ng3b0b
5p0ng3b0b / mk-uci-defaults.sh
Last active March 5, 2025 01:57
Script to generate a uci defaults file from an openwrt router. For use in custom firmwares using imagebuilder.
#!/bin/sh
# Create OpenWRT uci-defaults file for image builder
target=$(sed -n 1p /etc/opkg/distfeeds.conf | cut -d'/' -f8)
soc=$(sed -n 1p /etc/opkg/distfeeds.conf | cut -d'/' -f9)
arch=$(sed -n 2p /etc/opkg/distfeeds.conf | cut -d'/' -f8)
model=$(cat /tmp/sysinfo/model)
profile=$(cat /tmp/sysinfo/board_name | sed 's/,/_/')
script="/tmp/99-custom"
echo ----------------------------------------------------
echo Generating custom default file for $model
@5p0ng3b0b
5p0ng3b0b / list-installed.sh
Last active March 4, 2025 16:14
List openwrt user installed packages without the additional dependencies. Used for generating the PACKAGES variable in openwrt imagebuilder.
#!/bin/sh
P=/usr/lib/opkg/status
T=$(awk -v RS= '/^P.{0,8}ker/' $P|grep '^I'|cut -d' ' -f2) #get timestamp of firmware
I=$(awk -v RS= -v t="$T" '$0 !~t' $P|grep '^Pa'|cut -d' ' -f2|sort) #get all user installed packages
D=$(awk -v RS= -v t="$T" '$0 !~t' $P|grep '^D'|cut -d' ' -f2-|sed 's#, #\n#g'|sort|uniq) #get packages that are dependencies
p=;for i in $I;do if [ $(echo $D|grep -c $i) = 0 ];then p="$p $i";fi;done;echo $p #get user packages not listed as a dependency
@5p0ng3b0b
5p0ng3b0b / serio.py
Created March 1, 2025 23:38
serio. a program to send a file over serial port or telnet. original script is in python2. this one is converted and debugged to run in python 3
#!/usr/bin/env python
# Small utility to upload a file to an embedded Linux system that provides a shell
# via its serial port.
import sys, time
from getopt import GetoptError, getopt as GetOpt
class SerialFTP:
IO_TIME = .1
@5p0ng3b0b
5p0ng3b0b / mwan-config.sh
Created November 25, 2021 10:29 — forked from braian87b/mwan-config.sh
/etc/config/mwan
# My documentation:
#
# Important: this works well on OpenWRT 15.05.1, on newer versions there was some breaking changes, for example, the wan ifaces have ipv6 capability and now are named with letters ("wan, wanb... , wanc" instead of "wan, wan2... wan3" so wanb6 means 2nd wan ipv6.): https://github.com/openwrt/packages/blob/master/net/mwan3/files/etc/config/mwan3
#
# We have Interfaces, Members, Policyes y Rules:
#
# Interfaces: Allows to identify the wan interface, we just need to have it enabled`
# the others parameters are only to track if the interface it is up or down.
#
# Members: Can be defined in some metric and weight, both values will be important ambos when used in policyes.
@5p0ng3b0b
5p0ng3b0b / init-opt.sh
Last active July 21, 2020 16:59
ix4-300d boot script
#!/bin/sh
# IX4-300D startup and optware-ng init script
# Set path for additional files use USB or HDD
# If USB then specify UUID of USB drive
files=HDD
UUID="1827a6c8-c9a7-442c-adda-34806977c107"
# Wait until storage pool is mounted
while [ ! "$(ls -a /mnt/pools/A/A0/ 2>/dev/null)" ]; do sleep 2; done
@5p0ng3b0b
5p0ng3b0b / autoexec.py
Last active April 4, 2024 05:17
Kodi startup script to enable all addons.
import xbmc, xbmcvfs, xbmcaddon, xbmcgui,re, os, glob, thread
from datetime import datetime
try: from sqlite3 import dbapi2 as database
except: from pysqlite2 import dbapi2 as database
def main():
class enableAll():
def __init__(self):
self.databasepath = xbmc.translatePath('special://database/')
self.addons = xbmc.translatePath('special://home/addons/')
@5p0ng3b0b
5p0ng3b0b / apkdrop.sh
Last active January 15, 2019 11:00
Script for processing APK files from cron
#!/bin/sh
# 11/01/2019
# Drop Folder script for renaming APKs
# Read apk file from SRC folder and move it to TGT folder while changing filename to APKLABEL_APKVERSION.apk
# If an existing version of the APK exists in the target folder then script will remove it
# Define METHOD as "aapt" or "apktool" depending upon what is available on server
# Script is much slower using apktool method
# Variables
METHOD="aapt"
@5p0ng3b0b
5p0ng3b0b / sslsetup.sh
Created January 6, 2019 00:49
Script for generating and registering ssl certs
#!/bin/sh
# sslsetup.sh
# This script is designed to be run on a shared hosting service to automatically genrate and register SSL certs
# Upload to your server and then run via ssh then set a cron job to renew every 90 days
# Prerequisites: openssh, openssl, perl, gcc,
# Usage: sslsetup <domainname> or: sslsetup
# Initial setup (if not setup already)
if [ ! -d ~/bin ]; then mkdir ~/bin; fi
if [ ! -d ~/.cpan ]; then echo 'Configuring cpan'; echo y | cpan > /dev/null 2>&1; fi