System

Git Branches

Branches

some basic commands for branches. you can read Branch Basics and Branch Management for more details

create branch

you wanna develope a feature, fix a bug, test some stuff … you need a branch !

git checkout -b feature1

push upstream

if you have a central repo, push the feature upstream (so others can checkout as well)

git push --set-upstream origin feature1

show branch

you may have multiple branches, list them all. and update pager so list will not open in VIM !

Git Clear your History

Clear History

have you ever checked in some binarys, confidential stuff or something else by mistake ? Git will keep all your history, that’s their design and purpose.

how ever, if you need to cleanup once, here is a short tutorial.

Kill Git Config

cd myrepo
cat .git/config -> note down the url
url=$(git config --get remote.origin.url)
rm -rf .git

Create New Repo

git init
git add .
git commit -m "Removed history, ..."

Push Remote

git remote add origin git@host/yourrepo  <- URL you noted down above
git remote add origin $url
git push -u --force origin master

All in One

_url=$(git remote -v |awk '/fetch/ { print $2 }')
rm -rf .git
git init
git add .
git commit -m "Removed history ..."
git remote add origin ${_url}
git push -u --force origin main
unset _url

and you’re done :)

Serial Console & TTYs

assuming you have a apu2|apu3|apu4 from pcengines or a virtual machine running on KVM/Qemu. And you don’t have vga/dvi/hdmi whatever kind of video output. of course, you can install and run OpenBSD (or Linux) on this boxes.

Prepare USB Stick

write openbsdxx.img to an USB Stick. On MacOS, you can use Balena Etcher for example.

boot.conf

if you wanna install from an USB Stick, set the correct Port and Speed before booting.

Gluerecords

https://serverfault.com/questions/142344/how-to-test-dns-glue-record

Check GlueRecords

host:~ $ dig +short ch. NS
c.nic.ch.
a.nic.ch.
h.nic.ch.
f.nic.ch.
g.nic.ch.
b.nic.ch.
e.nic.ch.

host:~ $ dig +norec @a.nic.ch. noflow.ch. NS

; <<>> DiG 9.10.6 <<>> +norec @a.nic.ch. noflow.ch. NS
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29211
;; flags: qr; QUERY: 1, ANSWER: 0, AUTHORITY: 3, ADDITIONAL: 4

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;noflow.ch. IN  NS

;; AUTHORITY SECTION:
noflow.ch.  3600  IN  NS  ns3.noflow.ch.
noflow.ch.  3600  IN  NS  ns2.noflow.ch.
noflow.ch.  3600  IN  NS  ns1.noflow.ch.

;; ADDITIONAL SECTION:
ns3.noflow.ch.  3600  IN  A 45.32.159.233
ns2.noflow.ch.  3600  IN  A 193.36.36.130
ns1.noflow.ch.  3600  IN  A 45.15.80.202

;; Query time: 12 msec
;; SERVER: 2001:620:0:ff::56#53(2001:620:0:ff::56)
;; WHEN: Wed Aug 26 23:09:52 CEST 2020
;; MSG SIZE  rcvd: 140

you can see, there are three gluerecords with (A) and none with (AAAA). need to talk with my domain hosting provider as i’d like to have AAAA as well …

Checkmk

Some Install Notes

https://checkmk.de/cms_install_packages_debian.html

download and scp check-mk-enterprise-1.6.0p15.demo_0.buster_amd64.deb -> enterprise microkernel, 2 x 10 Hosts download and scp check-mk-raw-1.6.0p15_0.buster_amd64.deb -> raw edition, nagios kernel

ssh root@localhost

apt-get install dpkg-sig libnet-snmp-perl snmp
wget https://checkmk.com/support/Check_MK-pubkey.gpg
gpg --import Check_MK-pubkey.gpg
dpkg-sig --verify /tmp/check-mk-enterprise-1.6.0p15.demo_0.buster_amd64.deb
apt-get install gdebi-core
gdebi /tmp/check-mk-raw-1.6.0p15_0.buster_amd64.deb
omd version

omd create mysite
omd config

oder

omd restore /tmp/mysite.tar.gz

Install v2.0 and migrate existing Config

https://checkmk.de/cms_install_packages_debian.html

download file: check-mk-raw-2.0.0p5_0.buster_amd64.deb

scp check-mk-raw-2.0.0p5_0.buster_amd64.deb host227:/tmp/

Prepare New Host

apt install -y dpkg-sig libnet-snmp-perl snmp

wget https://checkmk.com/support/Check_MK-pubkey.gpg
gpg --import Check_MK-pubkey.gpg
dpkg-sig --verify /tmp/check-mk-raw-2.0.0p5_0.buster_amd64.deb

apt-get install gdebi-core
gdebi /tmp/check-mk-raw-2.0.0p5_0.buster_amd64.deb

omd version

Backup old Server

Backup and copy to new Server

GIT add Folder to Repo

wanna switch a local folder to a remote git repo ?

https://docs.github.com/en/github/using-git/adding-a-remote

GitoLite

create git repo with gitolite (myproject)

add Folder

cd myproject

git init
git remote add origin git@your-git-server:myproject

check Status

git remote -v
git status

add all existing Files, commit and push to remote

git add .
git commit -m "initial commit"
git push --set-upstream origin master

Any Comments ?

sha256: ba5ff311face100add7e9b21efbbb86af94545d3aec2cf8d920ea55ba5353464

Borg

Exclude Dir

CAT << 'EOF' > CACHEDIR.TAG
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by Borg.
# For information about cache directory tags, see:
#       http://www.bford.info/cachedir/spec.html
EOF
chmod 444 CACHEDIR.TAG

Any Comments ?

sha256: 182ef42d357dcaa9a5150e6bc4c617dee1fa0dcbb3ee0382c95e94fac7910265

Hamster Rad

Projekt Hamster Counter

Hamsterrad

Reed Sensor

Installation

Ziel

Ein kleiner Hamster Rad Zähler, um etwas über das (nächtliche) Laufverhalten des Nagers zu erfahren.

Website

Das Projekt hat nen kleinen Webserver bekommen mit Live Statistiken Webserver nur IPv6 erreichbar

Hardware

Aufbau

das Supermaget klebst Du auf das Hamsterrad auf die Rückseite. Das Rad so gut wie es geht am Gehäuse befestigen. Der Magnetsensor steckst/klebst Du ans Gehäuse und kuckst, dass ca. 1 cm Abstand hast zum Magneten am Rad. Die zwei Kabel am Magneten schraubst/lötest du an die 10m Litze und gehst damit auf den Serial Stecker. Dort schliesst Du die Drähte am Pin 4 und Pin 6 an. Das Script gibt logisch “1” auf den DTR Pin und wenn das Magnet schliesst, dann hast Du Logisch “1” auf DSR. DSR wird dann im Script ausgelesen und gezählt

Gitolite

You wanna host your own Git Repositories ? Have a look at Gitolite. It does all for you :)

Install GitoLite

pkg_add gitolite

Add git user

root@gitserver ~# adduser -silent
Enter username []: git
Enter full name []: git repo user
Enter shell bash csh git-shell ksh nologin sh [ksh]:
Uid [1001]:
Login group git [git]:
Login group is ``git''. Invite git into other groups: guest no
[no]:
Login class authpf bgpd daemon default pbuild staff unbound
[default]:
Enter password []:
Disable password logins for the user? (y/n) [n]: y

Name:        git
Password:    ****
Fullname:    git repo user
Uid:         1001
Gid:         1001 (git)
Groups:      git
Login Class: default
HOME:        /home/git
Shell:       /bin/ksh
OK? (y/n) [y]: y
Added user ``git''
Add another user? (y/n) [y]: n

Basic Setup

Setup Repo, add your key

Git

Some Git Commands

Customizing Git

Switch from “Master” to Main globally

git config --global init.defaultBranch main

Merge two Repos “merge unrelated histories”

git pull origin master --allow-unrelated-histories
git push
git pull

add local Folder and Push to Upstream

echo "# test" >> README.md
git init
git config init.defaultBranch main
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin git@github.com:stoege/test.git
git push -u origin main

Find deleted file, sort uniq

git log --all --pretty=format: --name-only --diff-filter=D | sort -u
bla
bla.yml
doit.sh
files.conf.j2
...

Find deleted File

git log --diff-filter=D --summary

commit abcecadce91af3814662fa6a04d0f12e361f0574
Date:   Sun May 31 23:19:59 2020 +0200

    update

 delete mode 100644 master/sed.tcpdump

commit 81ae58d70c27d02eb2f65beed4fe0b571073f087
Date:   Fri May 29 16:06:14 2020 +0200

    update

Restore deleted File

git checkout 81ae58d70c27d02eb2f65beed4fe0b571073f087 sed.tcpdump

Remove Sensitive Data

git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch .geheimesfile' \
--prune-empty --tag-name-filter cat -- --all

git push origin --force --all

git push origin --force --tags

Remove last Commit

will remove the last Commit from your current branch