summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorJoerg Jaspert <joerg@debian.org>2008-09-27 00:12:34 +0200
committerJoerg Jaspert <joerg@debian.org>2008-09-27 00:12:34 +0200
commitf861c6d92ef6b9cf4ddaaf5f8205b98be64899be (patch)
treeeef062614820b179c682d0cb988f7b24fda728cf /etc
parentdf7d931779767c6f024ffd19c98757eda5349d85 (diff)
common functions
Add a file for common functions. Currently only holds a (very adapted) version of signal() Signed-off-by: Joerg Jaspert <joerg@debian.org>
Diffstat (limited to 'etc')
-rw-r--r--etc/common31
1 files changed, 31 insertions, 0 deletions
diff --git a/etc/common b/etc/common
new file mode 100644
index 0000000..ee2bd92
--- /dev/null
+++ b/etc/common
@@ -0,0 +1,31 @@
+# Little common functions
+
+# push a mirror attached to us.
+# Arguments:
+# $1 - Name for the mirror, also basename for the logfile
+# $2 - Hostname to push to
+# $3 - Username there
+# $4 - Protocol version, either 1 or 2.
+# $5 - the ssh private key file to use for this push
+# $6 - any other option ssh accepts, passed blindly, be careful
+#
+# This function assumes that the variable LOG is set to a directory where
+# logfiles can be written to.
+# Pushes will be done in background.
+signal () {
+ if [ $# -lt 5 ]; then
+ echo "Called with only $# parameters, expect at least 5"
+ return 2
+ fi
+
+ # Defaults we always want, no matter what
+ SSH_OPTIONS="-o BatchMode=yes -o SetupTimeOut=45 -o ConnectTimeout=45 -o PasswordAuthentication=no"
+
+ if [ $# -eq 6 ]; then
+ # The sixth sense^Wparameter, add it
+ SSH_OPTIONS="$SSH_OPTIONS $6"
+ fi
+
+ # Finally call ssh
+ ssh $SSH_OPTIONS -i "$5" -o"user $3" -$4 "$2" sleep 1 >> ${LOG}/$1.log 2>&1 &
+}