Skip to content

Instantly share code, notes, and snippets.

View ChatchaiJ's full-sized avatar

Chatchai Jantaraprim ChatchaiJ

View GitHub Profile
@ChatchaiJ
ChatchaiJ / verify-sdcard.sh
Created April 18, 2024 01:21
check that sdcard that how much actually it could contain data
#!/bin/sh
SDCARD="$1"
RANDFILE="/tmp/rand10m"
TMPBIN="/tmp/tmp.bin"
MAGICWORD="--i-know-what-i-am-doing"
BS="10240"
COUNT="1024"
@ChatchaiJ
ChatchaiJ / dmesg-datestamp.sh
Created December 8, 2015 07:26
Show dmesg in time/date stamp like in system log.
#!/bin/sh
# --------------------------------------------------------------------- #
# dmesg-datestamp - Show dmesg in time/date stamp like in system #
# log. Since my brain can't interpret uptime #
# that well. #
# #
# version 0.1 - cj (2013-03-25) init. #
# --------------------------------------------------------------------- #
@ChatchaiJ
ChatchaiJ / pkgupdate
Created December 8, 2015 06:50
Get list of packages to be updated on debian system
#!/bin/sh
# ********************************************************************* #
# pkgupdate : script for calling from crontab to update debian #
# packages on a machine using apt-get #
# Mainly this is a two commands #
# #
# apt-get update && apt-get upgrade -y -d upgrade #
# #
# but made readable report from the output of those #
@ChatchaiJ
ChatchaiJ / pkgupgrade
Created December 8, 2015 06:48
Upgrade debian package on the system
#!/bin/bash
# --------------------------------------------------------------------- #
# pkgupgrade - Upgrade debian package on the system. #
# #
# version 0.1 - cj (200x-xx-xx) init. #
# version 0.2 - cj (2013-07-17) comment, and start/finished time #
# added. #
# --------------------------------------------------------------------- #
@ChatchaiJ
ChatchaiJ / pkgorphremove
Created December 8, 2015 06:46
Remove Orphaned Packages
#!/bin/sh
# --------------------------------------------------------------------- #
# pkgorphremove : Remove Orphaned Packages. #
# Loop repeate removing/purging orphan packages #
# #
# version 0.1 : 2004-08-08 (cj) initial. #
# --------------------------------------------------------------------- #
while [ "`deborphan`" ]
@ChatchaiJ
ChatchaiJ / build-python-deb-package.sh
Last active July 4, 2022 23:50
Create python 3.10.4 debian package from source
#!/bin/bash
# ----- work space config -----
WORKDIR="$(pwd)"
SRCDIR="${WORKDIR}/src"
BUILDDIR="${WORKDIR}/build"
LOGDIR="${WORKDIR}/log"
# ----- package config -----
NAME="python"
@ChatchaiJ
ChatchaiJ / video-record.sh
Last active July 3, 2022 18:37
Record video from webcam using ffmpeg
#!/bin/sh
LEN=10 # video length in seconds
SLEEP=3 # sleep time in seconds
SAVEDIR="/tmp/camera"
CAMERA=$1
# How to use thi script
[ -z "$CAMERA" ] && echo "Usage: $0 /dev/videoX ## where X is [0..n]" && exit
@ChatchaiJ
ChatchaiJ / reprepro-config.sh
Created May 29, 2022 17:35
Config reprepro on debian server to create debian repository -- example add python package to repos
#!/bin/sh
BASEDIR="/srv/repos/apt/debian"
CONFDIR="${BASEDIR}/conf"
DISTFILE="${CONFDIR}/distributions"
OPTIONS="${CONFDIR}/options"
DEBWORKDIR="/home/cj/work"
# DEBFILE="${DEBWORKDIR}/python_3.10.4-1_amd64.deb"
DEBFILE="python_3.10.4-1_amd64.deb"
@ChatchaiJ
ChatchaiJ / build-repos.sh
Created May 29, 2022 17:33
Prepare debian system + apache2 server to be debian repository
#!/bin/sh
REPODIR="/srv/repos/apt/debian"
CONF="/tmp/repos-$$.conf"
APACHECONFDIR="/etc/apache2/conf-available"
[ ! -d "${APACHECONFDIR}" ] && \
echo "Apache2 conf directory is not available, is it installed?" && \
exit
#!/usr/bin/env bash
NAME="Chatchai Jantaraprim"
EMAIL="cj@cjv6.net"
[ -d ".gnupg" ] && echo "Directory .gnupg exist" && exit
# rm -rf .gnupg
mkdir -m 0700 .gnupg
touch .gnupg/gpg.conf