From 978087148d1165694584385dff4081fb0738ae14 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 12 Nov 2013 11:01:03 +0100 Subject: ship: fix telnet lib --- ship/lib/network | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'ship') diff --git a/ship/lib/network b/ship/lib/network index 0e494514..74edcbac 100644 --- a/ship/lib/network +++ b/ship/lib/network @@ -46,15 +46,16 @@ which_telnet(){ # netcat # busybox telnet if [ -e "${TELNET:-does_not_exist}" ]; then - info"Will be using $TELNET as Telnet Client" + info "Will be using $TELNET as Telnet Client" + echo $TELNET elif exists telnet ;then - TELNET="$(command -v telnet)" + command -v telnet elif exists nc ;then - TELNET="$(command -v nc)" + command -v nc elif exists netcat;then - echo "$(command -v netcat)" + command -v netcat elif exists busybox;then - echo "$(command -v busybox) telnet" + echo `command -v busybox` telnet else error "Cannot find telnet binary, please install either telnet-client or busybox or netcat or provided TELNET environment.\nbailing out!" return 1 @@ -64,7 +65,7 @@ which_telnet(){ run_telnet(){ host="$1" port="$2" - $(which_telnet) $host $port + $(which_telnet) "$host" "$port" } send_irc(){ -- cgit v1.2.3 From 9c37085f71b3fd7dd182813834c6e8017077f08c Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 12 Nov 2013 11:01:24 +0100 Subject: ship:fix esudo --- ship/lib/core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ship') diff --git a/ship/lib/core b/ship/lib/core index 3a6b33ff..e0edc2be 100644 --- a/ship/lib/core +++ b/ship/lib/core @@ -10,7 +10,7 @@ is_root(){ esudo(){ # becomes root with sudo powers # unless nosudo env is set - if test "${nosudo-false}" != true || is_root; then + if test "${nosudo-false}" != true && ! is_root; then echo "we're going sudo..." >&2 exec sudo -E "$0" "$@" exit 23 # go to hell -- cgit v1.2.3 From 16e39cc6a98977cc731abc19069b79aa9918654d Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 12 Nov 2013 11:01:42 +0100 Subject: ship: refactor tor service --- ship/lib/tor | 19 +++++++++++++++++++ ship/src/tor_publish_ssh | 17 +++-------------- 2 files changed, 22 insertions(+), 14 deletions(-) create mode 100644 ship/lib/tor (limited to 'ship') diff --git a/ship/lib/tor b/ship/lib/tor new file mode 100644 index 00000000..8d9e33f1 --- /dev/null +++ b/ship/lib/tor @@ -0,0 +1,19 @@ +# can be set via env: +# torrc - path to torrc (default: /etc/tor/torrc ) +# hidden_service_dir - path to hidden service (default: /var/lib/tor/hidden_service/ ) + + +torrc=${torrc:-/etc/tor/torrc} +hidden_service_dir=${hidden_service_dir:-/var/lib/tor/hidden_service/} + +configure_hidden_service(){ + if ! grep -q '^HiddenService' "$torrc" ;then + info "adding hidden service to $torrc" + cat >> "$torrc" << EOF +HiddenServiceDir ${hidden_service_dir} +HiddenServicePort 22 127.0.0.1:22 +EOF + else + info "HiddenServiceDir or Port already in $torrc, skipping!" + fi +} diff --git a/ship/src/tor_publish_ssh b/ship/src/tor_publish_ssh index df904444..14cb9cb4 100755 --- a/ship/src/tor_publish_ssh +++ b/ship/src/tor_publish_ssh @@ -2,24 +2,13 @@ #@include core #@include network #@include punani -# can be set via env: -# torrc - path to torrc (default: /etc/tor/torrc ) -# hidden_service_dir - path to hidden service (default: /var/lib/tor/hidden_service/ ) +#@include tor + -torrc=${torrc:-/etc/tor/torrc} -hidden_service_dir=${hidden_service_dir:-/var/lib/tor/hidden_service/} punani install tor test -w "$torrc" || ( error "$torrc is not writable!"; exit 1 ) || exit 1 -if ! grep -q '^HiddenService' "$torrc" ;then - info "adding hidden service to $torrc" - cat >> "$torrc" << EOF -HiddenServiceDir ${hidden_service_dir} -HiddenServicePort 22 127.0.0.1:22 -EOF -else - info "HiddenServiceDir or Port already in $torrc, skipping!" -fi +configure_hidden_service cat $hidden_service_dir/hostname | send_irc -- cgit v1.2.3 From 5e85a920a6c9ee68e1171f27d816151d8825b78a Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 12 Nov 2013 12:08:29 +0100 Subject: ship:core contains trap_add --- ship/lib/core | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'ship') diff --git a/ship/lib/core b/ship/lib/core index e0edc2be..80be5d2e 100644 --- a/ship/lib/core +++ b/ship/lib/core @@ -2,9 +2,16 @@ msg() { printf "$@\n" >&2 ;} info() { msg "** $@" ;} error() { msg "!! $@" ;} +die() { error "$@" ;exit 1;} exists(){ type "$1" >/dev/null 2>/dev/null; } is_root(){ test $(id -u) -eq 0 +} + +trap_add(){ + #close enough + trapstr="$1;${trapstr:-exit}" + trap "$trapstr" INT TERM EXIT KILL } esudo(){ -- cgit v1.2.3 From 235cfb673d84dc151aa502f854e5daaf4487feb8 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 12 Nov 2013 14:43:13 +0100 Subject: ship: trap_add -> defer --- ship/lib/core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ship') diff --git a/ship/lib/core b/ship/lib/core index 80be5d2e..1ef1fbf9 100644 --- a/ship/lib/core +++ b/ship/lib/core @@ -8,7 +8,7 @@ is_root(){ test $(id -u) -eq 0 } -trap_add(){ +defer(){ #close enough trapstr="$1;${trapstr:-exit}" trap "$trapstr" INT TERM EXIT KILL -- cgit v1.2.3 From 8ebba4db20b8127e57490eeea95d50d158dc69dd Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 12 Nov 2013 14:43:41 +0100 Subject: ship: add remaster_iso --- ship/src/remaster_iso | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 ship/src/remaster_iso (limited to 'ship') diff --git a/ship/src/remaster_iso b/ship/src/remaster_iso new file mode 100755 index 00000000..a10034c9 --- /dev/null +++ b/ship/src/remaster_iso @@ -0,0 +1,64 @@ +#!/bin/sh +#@include core +set -efu +isofile=${1:-archlinux-2013.06.01-dual.iso} +outfile=$(basename ${isofile%.iso}.krebs.iso) +info "outfile will be at $outfile" +bdir=${bdir:-$HOME/build/arch} +isodir=$bdir/iso +isomnt=$bdir/isomount +rootdir=$bdir/root +outdir=$bdir/out +info "bdir is at $bdir" +[ ! -e "$isofile" ] && die "$isofile does not exist,bailing out" +esudo "$@" + + +#punani install genisoimage + + +info "cleanup root dir" +rm -rf $bdir +mkdir -p $isomnt $rootdir +info "mounting isofile ($isofile)" +if is_root;then + mount -t iso9660 -o loop,ro $isofile $isomnt +else + error "we are not root enough to mount the iso. Bailing Out" + exit 1 + +fi +defer "info 'unmounting $isomnt';umount $isomnt" + +info "copying from '$isomnt' to '$isodir'" +cp -a "$isomnt" "$isodir" +defer "info 'removing $isodir';rm -rf $isodir" +info "extracting root-image squashfs" +# we will not touch the kernel ... yet + +for arch in x86_64 i686;do + info "unpacking $isomnt/arch/$arch/root-image.fs.sfs" + mkdir -p "$outdir/$arch" + defer "info 'removing $outdir/$arch';rm -rf $outdir/$arch" + mkdir -p "$rootdir/$arch" + defer "info 'removing $rootdir/$arch';rm -rf $rootdir/$arch" + unsquashfs -f -d "$outdir/$arch" "$isodir/arch/$arch/root-image.fs.sfs" + + mount "$outdir/$arch/root-image.fs" "$rootdir/$arch" + defer "info 'unmounting $rootdir/$arch';umount $rootdir/$arch" + + info "Starting of the rootdir verkrepelung" + # do the magic here + arch-chroot $rootdir/$arch <