Skip to content

Instantly share code, notes, and snippets.

View redneck-f25's full-sized avatar

Daniel Hammerschmidt redneck-f25

  • Leipzig, Germany
View GitHub Profile
@redneck-f25
redneck-f25 / 70-hvnetdev.rules
Last active May 12, 2024 17:32
Stable names for multiple network interfaces in GNU/Linux VM on Hyper-V
# /etc/udev/rules.d/70-hvnetdev.rules
SUBSYSTEM=="net", ACTION=="add", PROGRAM=="/etc/udev/hvnetdev_program", NAME="$result"
@redneck-f25
redneck-f25 / makecert.cmd
Created March 24, 2024 23:56
Make trusted X.509-certificate chain for local development (i.e. Apache HTTPd w/ OpenSSL on Windows).
@echo off & setlocal enableextensions enabledelayedexpansion & set "_bang=^!"
for /f "usebackq tokens=2 delims==" %%T in (`wmic os get LocalDateTime /value`) do (
for /f "usebackq tokens=* delims=" %%T in ('%%T') do (
set "_t=%%T"
set "_n=!_bang!localhost [!_t:+=\+!]"
)
)
pushd "%~dp0"
#!/bin/bash
openssl s_client -showcerts -connect example.org:443 < /dev/null \
| sed -n '/^-----BEGIN CERTIFICATE-----/,/^-----END CERTIFICATE-----/p' \
| {
cert=
while read -r; do
cert+="${REPLY}"$'\n'
if [[ "${REPLY}" == "-----END CERTIFICATE-----" ]]; then
openssl x509 -in - -out - -text <<<"${cert}"
@redneck-f25
redneck-f25 / Call-WindowsSecurity.cmd
Created December 23, 2021 05:20
Change password through RDP without Ctrl-Alt-Del
<!-- : @author daniel.hammerschmidt@bitctrl.de
@echo off & setlocal enableextensions enabledelayedexpansion
title %~n0
mode con cols=80 lines=15
set "xcopyprompt="
for /f "usebackq delims=" %%a in (`xcopy /lw "%~f0" "%~f0" 2^>nul ^<nul`) do if not defined xcopyprompt set "xcopyprompt=%%a"
for /l %%_ in (0,0,1) do (
cscript //nologo "%~f0?.wsf"
ping -n 2 localhost > nul 2> nul
color 5e
@echo off & setlocal enableextensions enabledelayedexpansion
rem wrapper around samconfig to address a single slot in a cfg-block
rem
rem samconfig host port
rem get device-id cfg-block-id:slot-num [value]
rem samconfig host port
rem set device-id cfg-block-id:slot-num value
rem
rem if slot-num is missing command line is passed to samconfig
#!/bin/bash
{
cat <<'EOF'
01.example.com
02.example.com alias.example.com
# comment
@redneck-f25
redneck-f25 / _respawn.cmd
Last active June 27, 2019 22:45
Respawn Windows Console Processes and collect std{out,err} (i.e. for startup-tasks)
@echo off & setlocal enableextensions enabledelayedexpansion
if "%~1" == "" (
set "conf_file=%~dpn0.conf.cmd"
) else (
set "conf_file=%~dp0%~1.conf.cmd"
)
call "%conf_file%" || ( pause & exit 1 )
@redneck-f25
redneck-f25 / MountHiDrive.cmd
Last active June 26, 2019 09:14
Mount Strato HiDrive as network drive
@echo off & setlocal enableextensions enabledelayedexpansion
rem ***************************************************************************
rem * MountHiDrive.cmd *
rem * *
rem * Mount Strato HiDrive as network drive *
rem * *
rem * Copyright (C) 2019 BitCtrl Systems GmbH *
rem * @author Daniel Hammerschmidt <daniel.hammerschmidt@bitctrl.de> *
rem * @date 2019-06-25 *
rem * *
@redneck-f25
redneck-f25 / capture_volwimimgs.cmd
Created June 13, 2018 12:38
Capture WIM images of all dos-like volumes from VSS snapshot.
@echo off & setlocal enableextensions enabledelayedexpansion
rem ***************************************************************************
rem * *
rem * Copyright (C) 2018 BitCtrl Systems GmbH *
rem * *
rem * Capture WIM images of all dos-like volumes from VSS snapshot. *
rem * *
rem * @author Daniel Hammerschmidt <daniel.hammerschmidt@bitctrl.de> *
rem * @version 2018-06-13-001 *
rem * *
@redneck-f25
redneck-f25 / volumeshadowcopy.cmd
Created March 18, 2016 05:17
Windows cmd-skript to create a volume shadow copy from command line
@echo off
setlocal enableextensions enabledelayedexpansion
set on_error=print_usage
call :main_%~1 %* 2>nul && exit /b || goto !on_error! %*
:print_usage
echo\Usage: %~n0 create ^<drive:^> ^<link^>
echo\ %~n0 remove ^<link^>
echo\