From 24ba220c53ef38e74d6c68b92c13b28ece999269 Mon Sep 17 00:00:00 2001 From: Lassulus Date: Fri, 7 Dec 2012 16:59:24 +0100 Subject: added more info --- retiolum/doc/cronjob | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/retiolum/doc/cronjob b/retiolum/doc/cronjob index 356b5c96..3f640311 100644 --- a/retiolum/doc/cronjob +++ b/retiolum/doc/cronjob @@ -1,3 +1,7 @@ cron-eintrag fuer automatisches hosts-update +ueberschreibt keine bearbeitete host-dateien if ping -c 1 euer.krebsco.de -W 5 &>/dev/null; then (curl http://euer.krebsco.de/retiolum/hosts.tar.gz | tar xzk -C /etc/tinc/retiolum/hosts/);fi + +ueberschreibt bearbeitete hostdateien +if ping -c 1 euer.krebsco.de -W 5 &>/dev/null; then (curl http://euer.krebsco.de/retiolum/hosts.tar.gz | tar xz -C /etc/tinc/retiolum/hosts/);fi -- cgit v1.2.3 From a417442f720a1590fc16af93af421a06a00200ea Mon Sep 17 00:00:00 2001 From: Lassulus Date: Fri, 7 Dec 2012 19:17:15 +0100 Subject: added new installer WIP --- retiolum/scripts/tinc_setup/new_install.sh | 158 +++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100755 retiolum/scripts/tinc_setup/new_install.sh diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh new file mode 100755 index 00000000..ab42aedc --- /dev/null +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -0,0 +1,158 @@ +#!/bin/sh + +usage() +{ +cat << EOF +usage $0 options +This script gets you into the KREBS Darknet +all parameters are optional + +Options: + -h Show this message(haha) + -4 \$ipv4 specify an ip(version 4), this also disables random ip mode, default is random + -t \$DIR Choose another Temporary directory, default is /tmp/tinc-install-fu + -o \$HOST Choose another Hostname, default is your system hostname + -n \$NET Choose another tincd netname,this also specifies the path to your tinc config, default is retiolum + -s \$SUBNET Choose another Subnet(version4), default is 10.243. + -m \$MASK Choose another Subnet Mask(version4), default is /16 + -u \$URL specify another hostsfiles.tar.gz url, default is euer.krebsco.de/retiolum/hosts.tar.gz +EOF +} + +#check if ip is valid ipv4 function +check_ip_valid4() +{ + if [ "$(echo $1 | awk -F"\." ' $0 ~ /^([0-9]{1,3}\.){3}[0-9]{1,3}$/ && $1 <=255 && $2 <= 255 && $3 <= 255 && $4 <= 255 ' 2>/dev/null)" == "$1" ] && [ ${1:0:${#SUBNET4}} == $SUBNET4 ] + then + return 0 + else + return 1 + fi +} + +#check if ip is taken function +check_ip_taken() +{ + if grep -q -E "$1(#|/)" $TEMPDIR/hosts/* ;then + echo $1 is taken + return 1 + else + echo $1 seems free + return 0 + fi +} + +#if hostname is taken, count upwards until it isn't taken function +check_hostname() +{ + TSTFILE=$TEMPDIR/hosts/$1 + LCOUNTER=0 + if test -e $TSTFILE; then + while test -e $TSTFILE; do + let LCOUNTER=LCOUNTER+1 + TSTFILE=$TEMPDIR/hosts/$1$LCOUNTER + done + HOSTN=$1$LCOUNTER + else + HOSTN=$1 + fi +} + +TEMPDIR=/tmp/tinc-install-fu +HOSTN=$(hostname) +NETNAME=retiolum +SUBNET4=10.243. +MASK4=/16 +RAND=1 +URL=euer.krebsco.de/retiolum/hosts.tar.gz + +#check if everything is installed +if $(! test -e "/usr/sbin/tincd"); then + echo "Please install tinc" + exit 1 +fi + +if $(! test -e /usr/bin/awk); then + echo "Please install awk" + exit 1 +fi + +if $(! test -e /usr/bin/curl); then + echo "Please install curl" + exit 1 +fi + +if $(! /bin/ping -c 1 euer.krebsco.de -W 5 &>/dev/null) ;then + echo "Cant reach euer, check if your internet is working" + exit 1 +fi + + +#parse options +while getopts "h4:t:o:n:s:m:u:" OPTION +do + case $OPTION in + h) + usage + exit 1 + ;; + 4) + IP4=$OPTARG + RAND=0 + if ! check_ip_valid4 $IP4; then echo "ip is invalid" && exit 1; fi + ;; + t) + TEMPDIR=$OPTARG + ;; + o) + HOSTN=$OPTARG + ;; + n) + NETNAME=$OPTARG + ;; + s) + SUBNET4=$OPTARG + ;; + m) + MASK4=$OPTARG + ;; + u) + URL=$OPTARG + if $(! curl -s --head $URL | head -n 1 | grep "HTTP/1.[01] [23].." > /dev/null); then + echo "url not reachable" + exit 1 + fi + ;; + + esac +done + +#test if tinc directory already exists +if test -e /etc/tinc/$NETNAME; then + echo "tinc config directory /etc/tinc/$NETNAME does already exist. (backup and) delete config directory and restart" + exit 1 +fi + +#get tinc-hostfiles +mkdir -p $TEMPDIR/hosts +curl euer.krebsco.de/retiolum/hosts.tar.gz | tar zx -C $TEMPDIR/hosts/ + +#check for free ip +until check_ip_taken $IP4; do + if [ $RAND -eq 1 ]; then + IP4="10.243.$((RANDOM%255)).$((RANDOM%255))" + else + printf 'choose new ip: ' + read IP4 + while ! check_ip_valid4 $IP4; do + printf 'the ip is invalid, retard, choose a valid ip: ' + read IP4 + done + fi +done + +#check for free hostname +check_hostname $HOSTN + +echo "your ip is $IP4" +echo "your hostname is $HOSTN" -- cgit v1.2.3 From ad09d521243d9275d2af99b5aa5b67b9f79d3a77 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 7 Dec 2012 22:34:39 +0100 Subject: write_channel.py rewritten to announce_pubkey announce_pubkey is a shell-only implementation of the now obsolete write_channel script to announce a hosts public key the only dependency of this script is telnet, haven't seen a system without it for a while now --- retiolum/bin/announce_pubkey | 35 ++++++++++++++++++++++++++++ retiolum/scripts/tinc_setup/install.sh | 2 +- retiolum/scripts/tinc_setup/write_channel.py | 27 --------------------- 3 files changed, 36 insertions(+), 28 deletions(-) create mode 100644 retiolum/bin/announce_pubkey delete mode 100644 retiolum/scripts/tinc_setup/write_channel.py diff --git a/retiolum/bin/announce_pubkey b/retiolum/bin/announce_pubkey new file mode 100644 index 00000000..ce5aed19 --- /dev/null +++ b/retiolum/bin/announce_pubkey @@ -0,0 +1,35 @@ +#!/bin/sh +set -euf +HOST="${1:-}" + +usage (){ +cat < Date: Fri, 7 Dec 2012 22:48:51 +0100 Subject: chmod +x annouce_pubkey --- retiolum/bin/announce_pubkey | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 retiolum/bin/announce_pubkey diff --git a/retiolum/bin/announce_pubkey b/retiolum/bin/announce_pubkey old mode 100644 new mode 100755 -- cgit v1.2.3 From 253f0a908b190f0ff6d2f71023d050c088533c02 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 7 Dec 2012 23:06:17 +0100 Subject: pattern/README -> ENTERPRISE_PATTERN add to pattern : 'litterate programming' and 'Enterprise Expect' --- cholerab/ENTERPRISE_PATTERN | 84 +++++++++++++++++++++++++++++++++++++++++++++ cholerab/pattern/README | 68 ------------------------------------ 2 files changed, 84 insertions(+), 68 deletions(-) create mode 100644 cholerab/ENTERPRISE_PATTERN delete mode 100644 cholerab/pattern/README diff --git a/cholerab/ENTERPRISE_PATTERN b/cholerab/ENTERPRISE_PATTERN new file mode 100644 index 00000000..4e417709 --- /dev/null +++ b/cholerab/ENTERPRISE_PATTERN @@ -0,0 +1,84 @@ +Enterprise Patterns +================== +Stellt sicher, dass das richtige passiert, egal was gemacht wird + +Enterprise Loop +--------------- + +Enterprise Exception Handling +----------------------------- +ggf ersetzbar durch enterprise loop. + + +Enterprise Installation +----------------------- + +Rebooting +---------- + +Enterprise Einschalter (eon) +---------------------------- +Device that turns something on as soon as possible. + +Supernintendo Pattern +--------------------- + +Enterprise Root +--------------- +scripts which need root access but are called with lower privileges. The Enterprise Root Pattern provides a Solution for this issue by calling the script itself as sudo. + +if test "${nosudo-false}" != true -a `id -u` != 0; then + echo "we're going sudo..." >&2 + exec sudo "$0" "$@" + exit 23 # go to hell +fi + // enterprise ist, wenn ... trotzdem matcht + +Enterprise Shutdown +------------------ +Mittel der Wahl um einen Shutdown zu erzwingen + +Bsp: das Not-Aus in der Maschinensicherheit + +Enterprise Deep Copy +-------------------- +Bsp: var copy = JSON.parse(JSON.stringify(source)) + +Enterprise Thinking +------------------- +Prozess um auf Enterprise Patterns zu kommen + +Bug-Driven Development +--------------------- + +Source-based Documentation / Help +--------------------------------- + + #! /bin/sh + if echo "$*" | grep -q '\(^\| \)-h\( \|$\)'; then + cat "$0" + fi + # [more code] + + +Literate Programming +-------------------- +Omit all the comments. + +Litterate Programming +--------------------- +Write throw-away code and it will become production code + +Enterprise Expect +----------------- +Because you always know what you want, `expect(3)` script code can be replaced +by a `subshell and pipe` pattern : + + + ( echo "$username"; sleep 1; echo "$password"; sleep 1; echo "cp old new" ) | telnet + + +painload example: `//retiolum/bin/announce_pubkey` + + + diff --git a/cholerab/pattern/README b/cholerab/pattern/README deleted file mode 100644 index 0980ac6e..00000000 --- a/cholerab/pattern/README +++ /dev/null @@ -1,68 +0,0 @@ -Enterprise Patterns -================== -Stellt sicher, dass das richtige passiert, egal was gemacht wird - -Enterprise Loop ---------------- - -Enterprise Exception Handling ------------------------------ -ggf ersetzbar durch enterprise loop. - - -Enterprise Installation ------------------------ - -Rebooting ----------- - -Enterprise Einschalter (eon) ----------------------------- -Device that turns something on as soon as possible. - -Supernintendo Pattern ---------------------- - -Enterprise Root ---------------- -scripts which need root access but are called with lower privileges. The Enterprise Root Pattern provides a Solution for this issue by calling the script itself as sudo. - -if test "${nosudo-false}" != true -a `id -u` != 0; then - echo "we're going sudo..." >&2 - exec sudo "$0" "$@" - exit 23 # go to hell -fi - // enterprise ist, wenn ... trotzdem matcht - -Enterprise Shutdown ------------------- -Mittel der Wahl um einen Shutdown zu erzwingen - -Bsp: das Not-Aus in der Maschinensicherheit - -Enterprise Deep Copy --------------------- -Bsp: var copy = JSON.parse(JSON.stringify(source)) - -Enterprise Thinking -------------------- -Prozess um auf Enterprise Patterns zu kommen - -Bug-Driven Development ---------------------- - -Source-based Documentation / Help ---------------------------------- - - #! /bin/sh - if echo "$*" | grep -q '\(^\| \)-h\( \|$\)'; then - cat "$0" - fi - # [more code] - - -Literate Programming --------------------- -Omit all the comments. - - -- cgit v1.2.3