Skip to content

Instantly share code, notes, and snippets.

View tuklusan's full-sized avatar
💭
trading heroes for ghosts.

Supratim Sanyal tuklusan

💭
trading heroes for ghosts.
View GitHub Profile
@tuklusan
tuklusan / hecnet-nodes-list-for-cisco.sh
Created October 29, 2021 00:07
Load HECnet Node List DECnet Node Database into CISCO Router - CISCO IOS used for DECnet over GRE Tunneling: See https://supratim-sanyal.blogspot.com/2017/09/decnet-phase-iv-copy-node-database-from.html
#!/bin/bash
#
# CISCO needs commands of the form
# DECNET HOST PUFF 1.22
#
OUTFILE="nodenames-cisco-ios"
TMPFILE="/tmp/hecnet-cisco-temp.tmp"
curl -sNm 60 http://mim.update.uu.se/hecnod | dos2unix | egrep "^[0-9]" | cut -f 1-2 -d " " | sed -re 's/^/ /' | sed -re 's/[(]/DECNET HOST /' | sed -re 's/[)]//' > ${TMPFILE}
@tuklusan
tuklusan / sbin-init.d-rclocal
Last active October 15, 2021 13:52
/sbin/init.d/rclocal - execute Linux-style rc.local on HP-UX 11.11 or other rc and init.d based Unix environments that don't support rc.local directly; see https://supratim-sanyal.blogspot.com/2021/10/linux-style-etcrclocal-for-hp-ux-1111.html
#!/sbin/sh
# *****
# /sbin/init.d/rclocal
# execute Linux-style rc.local on HP-UX 11.11 or other rc and init.d based
# Unix environments that don't support rc.local directly; see
# https://supratim-sanyal.blogspot.com/2021/10/linux-style-etcrclocal-for-hp-ux-1111.html
# *****
# Allowed exit values:
@tuklusan
tuklusan / clear-kernel-memory-cache.sh
Created September 7, 2021 22:54
SANYALnet Labs | Save State of VirtualBox Virtual Machines on APC UPS power loss shutdown by apcupsd Linux Daemon / clear-kernel-memory-cache.sh: see https://supratim-sanyal.blogspot.com/2021/09/save-state-of-virtualbox-virtual.html
#!/bin/bash
#
# /root/clear-kernel-memory-cache.sh
# See see https://supratim-sanyal.blogspot.com/2021/09/save-state-of-virtualbox-virtual.html
#
sync;sync;sync
echo 3 > /proc/sys/vm/drop_caches
sync;sync;sync
@tuklusan
tuklusan / onbattery
Created September 7, 2021 22:49
SANYALnet Labs | Save State of VirtualBox Virtual Machines on APC UPS power loss shutdown by apcupsd Linux Daemon / onbattery event handler script: see https://supratim-sanyal.blogspot.com/2021/09/save-state-of-virtualbox-virtual.html
#!/bin/bash
#
# /etc/apcupsd/onbattery
#
# This shell script if placed in /etc/apcupsd
# will be called by /etc/apcupsd/apccontrol when the UPS
# goes on batteries.
# We send an email message to root to notify him.
#
@tuklusan
tuklusan / gist:fce4244d4c2f19e5a68b8c0e150d6492
Created September 7, 2021 22:44
SANYALnet Labs | Save State of VirtualBox Virtual Machines on APC UPS power loss shutdown by apcupsd Linux Daemon /etc/apcupsd : see https://supratim-sanyal.blogspot.com/2021/09/save-state-of-virtualbox-virtual.html
# ls -l
total 60
lrwxrwxrwx 1 root root 27 Aug 17 14:09 annoyme -> do-nothing-event-handler.sh
-rwxr-xr-x 1 root root 4007 Mar 22 2020 apccontrol
-rw-r--r-- 1 root root 13295 Aug 17 12:43 apcupsd.conf
-rw-r--r-- 1 root root 13238 Aug 16 20:22 apcupsd.conf.orig
lrwxrwxrwx 1 root root 27 Aug 17 14:11 battattach -> do-nothing-event-handler.sh
lrwxrwxrwx 1 root root 27 Aug 17 14:11 battdetach -> do-nothing-event-handler.sh
lrwxrwxrwx 1 root root 27 Aug 17 14:10 changeme -> do-nothing-event-handler.sh
lrwxrwxrwx 1 root root 27 Aug 17 14:05 commfailure -> do-nothing-event-handler.sh
@tuklusan
tuklusan / gist:4f2b26419ac7bc00000738312510a0c1
Created September 7, 2021 22:40
SANYALnet Labs | Save State of VirtualBox Virtual Machines on APC UPS power loss shutdown by apcupsd Linux Daemon / apcupsd apccontrol events: see https://supratim-sanyal.blogspot.com/2021/09/save-state-of-virtualbox-virtual.html
2021-08-17 11:13:34 +0000 Power failure.
2021-08-17 11:13:40 +0000 Running on UPS batteries.
2021-08-17 11:13:43 +0000 Reached remaining time percentage limit on batteries.
2021-08-17 11:13:43 +0000 Initiating system shutdown!
@tuklusan
tuklusan / save-vms-on-ups-power.sh
Last active July 4, 2022 23:25
SANYALnet Labs | Save State of VirtualBox Virtual Machines on APC UPS power loss shutdown by apcupsd Linux Daemon / save-vms-on-ups-power.sh: see https://supratim-sanyal.blogspot.com/2021/09/save-state-of-virtualbox-virtual.html
#!/bin/bash
#
# /root/save-vms-on-ups-power.sh
#
# SEE https://supratim-sanyal.blogspot.com/2021/09/save-state-of-virtualbox-virtual.html
#
# SANYALnet Labs | Supratim Sanyal's Hobbyist Lab
#
# Based on https://ubuntuforums.org/archive/index.php/t-1890848.html
#
@tuklusan
tuklusan / do-nothing-event-handler.sh
Created September 7, 2021 22:25
SANYALnet Labs | Save State of VirtualBox Virtual Machines on APC UPS power loss shutdown by apcupsd Linux Daemon / do-nothing-event-handler.sh: see https://supratim-sanyal.blogspot.com/2021/09/save-state-of-virtualbox-virtual.html
#!/bin/bash
#
# do-nothing-event-handler.sh
#
# return 99 to abort automatic shutdown by apccontrol
#
echo -e "$0 $(date): doing nothing\a"
wall "$0 $(date): doing nothing"
logger "$0 $(date): doing nothing"
exit 99
@tuklusan
tuklusan / apcaccess.status
Created September 7, 2021 22:21
SANYALnet Labs | Save State of VirtualBox Virtual Machines on APC UPS power loss shutdown by apcupsd Linux Daemon / apcaccess status: see https://supratim-sanyal.blogspot.com/2021/09/save-state-of-virtualbox-virtual.html
APC : 001,035,0900
DATE : 2021-09-07 22:18:10 +0000
HOSTNAME : gigabyte-h410m
VERSION : 3.14.14 (31 May 2016) debian
UPSNAME : SANYALnetLabsUPS
CABLE : USB Cable
DRIVER : USB UPS Driver
UPSMODE : Stand Alone
STARTTIME: 2021-08-17 23:17:44 +0000
MODEL : Back-UPS ES 550G
@tuklusan
tuklusan / zerofree-os2.c
Created December 24, 2020 19:59
Zerofree (fill unused hard disk space with zeroes) for OS/2 Warp, see https://supratim-sanyal.blogspot.com/2016/12/zero-out-free-disk-space-on-virtual.html
/* zerofree-os2.c
(c) 2020 Supratim Sanyal
A minimal program to zero out unused disk space for OS/2 Warp and derivates
(eComstation, ArcaOS etc.). Nothing OS/2 specific here, it should work for all
operating systems with a C compiler once the OS/2-style (MS-DOS style) pathnames
for drive letter and directory for the zero.zero file are adjusted.
Compiled using Borland C++ 2.0 for OS/2. Executable is downloadable free from:
https://supratim-sanyal.blogspot.com/2016/12/zero-out-free-disk-space-on-virtual.html