#!/bin/sh
#
# 2010 Nico Schottelius (nico-nsbin at schottelius.org)
#
# This file is part of nsbin.
#
# nsbin is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# nsbin is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with nsbin. If not, see .
#
# Submit solution according to http://edu.panter.ch/FormelleBedingungenUebungenBetriebssysteme
#
################################################################################
# cconf standard vars
__pwd="$(pwd -P)"
__mydir="${0%/*}"; __abs_mydir="$(cd "$__mydir" && pwd -P)"
__myname=${0##*/}; __abs_myname="$__abs_mydir/$__myname"
set -x
if [ $# -ne 2 ]; then
cat << eof
$0:
eof
exit 1
fi
subject_suff="$1"; shift
input="$1"; shift
input_base="${input##*/}"
self="nschotte"
to="bseelige"
domain="@hsz-t.ch"
self_q="${self}${domain}"
to_q="${to}${domain}"
subject_pref="[Betriebssysteme]"
sendmail="/usr/sbin/sendmail"
to_all="${to_q} ${self_q}"
to_all="${self_q}"
# check stuff before sending out
( cd "${input}" && make test && make clean ); ret=$?
if [ "${ret}" -ne 0 ]; then
echo "Task not solved"
exit 1
fi
(
(
cat << eof
To: $to_all
Subject: $subject_pref $subject_suff
From: $self_q
Gesendet mit ${__myname}.
eof
)
cd "${input}/.." && tar c "${input_base}" | gzip -9 | uuencode "${subject_suff}.tar.gz"
) | $sendmail -f "$self_q" $to_all