Skip to content

Instantly share code, notes, and snippets.

@tasoseng
tasoseng / centos_custom_iso_howto.sh
Last active March 27, 2021 22:50
centos 7 custom iso, autoinstall with ks, salt minion
#
wget http://ftp.ntua.gr/pub/linux/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso
mkdir test
mkdir iso
mount -oloop CentOS-7-x86_64-Minimal-1810.iso iso
rsync -av iso/ test/
umount iso
cd test
#sed -i '/rd.live.check quiet/a \\nlabel autoinstaller\n menu label autoinstaller\n menu default\n kernel vmlinuz\n append initrd=initrd.img ks=https://example.com/ks.cfg' isolinux/isolinux.cfg
#sed -i '/rd.live.check quiet/a \\nlabel autoinstaller\n menu label autoinstaller\n menu default\n kernel vmlinuz\n append initrd=initrd.img ks=hd:sdb1/ks.cfg' isolinux/isolinux.cfg
@tasoseng
tasoseng / delete_old_snapshots.sh
Created March 27, 2021 22:24
incremental zfs backup
#!/bin/sh
export PATH=/usr/local/sbin:/sbin:/usr/local/bin:/bin:/usr/sbin:/usr/bin
#DEBUG="echo"
DEBUG=""
set -eu # -x
TODAY=$(date +%Y-%m-%d)
@tasoseng
tasoseng / port_fwd.sh
Created March 27, 2021 22:09
port forward, nat
#!/bin/sh
# RUN THIS ON $ME
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -F
iptables -t nat -F
iptables -X
@tasoseng
tasoseng / find_mail.sh
Created March 27, 2021 22:06
find all mails a user has received, $1 = To: email (sendmail)
#!/bin/sh
set -eu
export IFS='
'
TO=$1
for ID in $(grep to=\<"$1"\> /var/log/everything | awk '{print $6}'| tr -d : ); do
mfs_load="YES"
mfs_type="mfs_root"
mfs_name="/mfsroot"
ahci_load="YES"
vfs.root.mountfrom="ufs:/dev/md0"
mfsbsd.autodhcp="YES"
autoboot_delay="1"
@tasoseng
tasoseng / url_decode.sh
Created March 27, 2021 00:28
bash url decode
#!/bin/bash
urldecode() {
arg="$1"
i="0"
while [ "$i" -lt ${#arg} ]; do
c0=${arg:$i:1}
if [ "x$c0" = "x%" ]; then
c1=${arg:$((i+1)):1}
c2=${arg:$((i+2)):1}
@tasoseng
tasoseng / decode_sms.sh
Created March 27, 2021 00:26
decode greek sms
#!/bin/sh
set -e
if [ -z $1 ]; then
echo "Usage: $0 file"
exit 1
fi
OS=$(uname -s)
@tasoseng
tasoseng / openbsd_dhcpd_leases.py
Created March 27, 2021 00:12
print active openbsd dhcpd leases
#!/usr/bin/env python
# coding: UTF-8
# for openbsd dhcpd only
# apo dhcpd.leases(5):
# the last declaration is the current
# also, the times are in UTC!
import re
from datetime import datetime
@tasoseng
tasoseng / exclude_webconf_cidrs.py
Last active March 8, 2023 14:37
exclude zoom, teams, webex cidrs from openvpn routes (split tunnel)
import requests
import re
import ipaddress
with requests.Session() as s:
r = s.get('https://support.zoom.us/hc/en-us/articles/201362683-Network-Firewall-or-Proxy-Server-Settings-for-Zoom%C2%A0%20')
zoom = list(set(re.findall(r'(?:\d{1,3}.){3}\d{1,3}\/\d{1,2}', r.text)))
#r = s.get('https://docs.microsoft.com/en-us/microsoft-365/enterprise/urls-and-ip-address-ranges?view=o365-worldwide#skype-for-business-online-and-microsoft-teams')
#teams = list(set(re.findall(r'(?:\d{1,3}.){3}\d{1,3}\/\d{1,2}', r.text)))
@tasoseng
tasoseng / el2gr.sh
Created March 26, 2021 22:37
elot 743 - Transliteraton of greek characters to latin
#!/usr/local/bin/bash
export IFS='
'
string=$1
SED=gsed
gr='αάβγδεέζηήθιίϊΐκλμνξοόπρσςτυύϋΰφχψωώ'
eng='aavgdeezii.iiiiklmnxooprsstyyyyf..oo'