Skip to content

Instantly share code, notes, and snippets.

@ktnr74
ktnr74 / rps10_cmd.sh
Created Sep 18, 2018
FreeBSD shell compatible script to control WTI RPS-10 remote power switch from pfSense/OpnSense boxes
View rps10_cmd.sh
#!/bin/sh
PORT=/dev/${1:-cuau0}
BAUD=${2:-9600}
# WTI RPS-10 Commands
ALL_DEVICES="*"
TOGGLE="T"
GET_STATE="?"
SWITCH_ON="1"
@ktnr74
ktnr74 / 99-android.rules
Created Jul 19, 2018
Universal udev rules file to set Android device permissions
View 99-android.rules
# do not forget to run 'sudo udevadm control --reload-rules' after editing this file
ACTION!="add", GOTO="android_usb_rules_end"
SUBSYSTEM!="usb", GOTO="android_usb_rules_end"
ENV{DEVTYPE}!="usb_device", GOTO="android_usb_rules_end"
ENV{ID_SERIAL_SHORT}=="", GOTO="android_empty_serial"
ENV{ID_SERIAL_SHORT}=="0000:*", GOTO="android_empty_serial"
ENV{ID_SERIAL_SHORT}=="0123456789ABCDEF", GOTO="android_empty_serial"
@ktnr74
ktnr74 / get_support_package_source.sh
Created Sep 10, 2016
Download all available source code jars for com.android.support.appcompat-v7 package
View get_support_package_source.sh
#!/bin/bash
GOOGLE_SOURCE_URL="https://android.googlesource.com"
REPO="platform/prebuilts/maven_repo/android"
BRANCH="+/master"
PACKAGE="com/android/support/appcompat-v7"
XPATH="/metadata/versioning/versions/version/text()"
GetGoogleSourceFile () {
curl -s --compressed -G -d "format=text" --url "$4/$3/$2/$1" | base64 -d
@ktnr74
ktnr74 / provision-lg1535.py
Last active Jul 10, 2016
Nortel LG 1535 VOIP video phone provisioning script
View provision-lg1535.py
#!/usr/bin/python
import time
import sys
from telnetlib import Telnet, IAC, DO, DONT, WILL, WONT, SB, SE, ECHO, SGA
from argparse import ArgumentParser
from crypt import crypt
class Nortel1535(Telnet):
@ktnr74
ktnr74 / service_call_test.py
Last active Jan 8, 2020
*update_transaction_codes.py* parses Android services source code to find out transaction codes and saves them in YAML format for later use. *transaction_codes.yaml* is an example of the resulting file. *service_call_test.py* shows how it can be used
View service_call_test.py
#!/usr/bin/python
import os
import sys
import time
import yaml
import subprocess
import re
import struct
View cron-daily-adb-update
#!/bin/bash
#sudo apt-get install libxml2-utils
GetGoogleSourceFile () {
[ "-$1" == "-" ] && return 1
curl -s --compressed -G -d "format=text" --url "$GOOGLE_SOURCE_URL/${3:-platform/frameworks/base}/${2:-+/master}/$1" | base64 -d
}
GetRepositoryXmlURL () {
@ktnr74
ktnr74 / adb_helpers.sh
Last active Dec 9, 2018
more adb helper functions for bash
View adb_helpers.sh
#!/bin/bash
ListAndroidSYSFS () { find -L /sys/bus/usb/devices -maxdepth 2 -path "*/modalias" -printf "%h\t" -exec cat {} \; | awk -F: '/icFFisc42ip0/ {print $1}'; }
ListAndroidSYSFSderef () { ListAndroidSYSFS | xargs -i readlink -f {}; }
ListAndroidSerials () { ListAndroidSYSFS | xargs -i cat {}/serial; }
ListAndroidVendorIDs () { ListAndroidSYSFS | xargs -i cat {}/idVendor | awk '{printf "0x%s\n", $1}' | sort -u; }
ListAndroidUSBDevices () { ListAndroidSYSFS | xargs -i cat {}/busnum {}/devnum | awk '{printf "/%03d", $1}' | sed -e 's#.\{8\}#/dev/bus/usb&\n#g'; }
ADBShell () { adb ${2+-s} $2 shell "$1" | tr -d '\r'; }
ADBExec () { adb ${2+-s} $2 exec-out "$1"; }
ADBServicePackageName () { ADBShell "service list" $2 | sed 's/^[0-9]\{1,3\}\t\([^:]*\): \[\([^]]*\)\].*/\1 \2/' | awk '/^'$1' / {print $2}' | head -n 1; }
View android_winusb.inf
;
; Android WinUsb driver installation.
;
[Version]
Signature = "$Windows NT$"
Class = AndroidUsbDeviceClass
ClassGuid = {3F966BD9-FA04-4ec5-991C-D326973B5128}
Provider = %ProviderName%
DriverVer = 08/28/2014,11.0.0000.00000
CatalogFile.NTx86 = androidwinusb86.cat
View get_android_service_call_numbers.sh
#!/bin/bash
ADBShell () { adb ${2+-s }$2 shell "$1" | tr -d '\r'
}
GetAndroidVersion () {
local ALL_TAGS=$(wget -qO - "$GOOGLE_SOURCE/$REPO/+refs/tags/?format=text" | \
tr -d '^{}' | cut -d/ -f3 | sort -u | grep -vE -- '-(cts|sdk)-' | grep -v "_r0")
TAG=${1:-$(ADBShell 'getprop ro.build.version.release')}
echo -e "ANDROID_SERIAL=$ANDROID_SERIAL\nro.build.version.release=$TAG" 1>&2
View install_adb.sh
#!/bin/bash
AbortIfExecutableMissing () {
BIN=($@)
MISSINGBIN=$(for B in ${BIN[@]}; do [ "$(which $B 2>/dev/null)-" == "-" ] && echo $B; done)
if [ "${MISSINGBIN}-" != "-" ]
then
echo -e "Can't find the following executables: "$MISSINGBIN
exit 1
fi