Autosox
authorJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Tue, 28 Jun 2011 16:54:03 +0000 (16:54 +0000)
committerJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Tue, 28 Jun 2011 16:54:03 +0000 (16:54 +0000)
12 files changed:
autosox [new file with mode: 0755]
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/copyright [new file with mode: 0644]
debian/dirs [new file with mode: 0644]
debian/init [new file with mode: 0644]
debian/install [new file with mode: 0644]
debian/postinst [new file with mode: 0755]
debian/postrm [new file with mode: 0644]
debian/rules [new file with mode: 0755]
debian/source/format [new file with mode: 0644]

diff --git a/autosox b/autosox
new file mode 100755 (executable)
index 0000000..35b0dcd
--- /dev/null
+++ b/autosox
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+EXT=.ogg
+LOGFILE=/var/log/autosox.log
+#LOGFILE=autosox.log
+
+onSignal() {
+       echo "Received signal. Killing child process...."
+       kill $RECPID
+       exit 0
+}
+trap onSignal INT TERM
+
+umask 007
+
+while true
+do
+       rec --channels 1 --default-device liverecording$EXT silence 1 1 10% 1 0:10 10% >> $LOGFILE 2>&1 &
+       RECPID=$!
+       echo "Process $! started"
+       wait
+       FILENAME="`date '+%Y-%m-%dT%H:%M:%S'`"$EXT
+       mv liverecording$EXT "$FILENAME"
+done
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..06bc084
--- /dev/null
@@ -0,0 +1,5 @@
+autosox (0.1) testing; urgency=low
+
+  * Initial release.
+
+ -- Nirgal Vourgère <jvourger@greenpeace.org>  Tue, 28 Jun 2011 14:23:33 +0200
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7813681
--- /dev/null
@@ -0,0 +1 @@
+5
\ No newline at end of file
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..8c0c92d
--- /dev/null
@@ -0,0 +1,15 @@
+Source: autosox
+Section: sound
+Priority: optional
+Maintainer: Nirgal Vourgère <jvourger@greenpeace.org>
+Build-Depends: debhelper (>= 7.0.50)
+Standards-Version: 3.9.1
+
+Package: autosox
+Architecture: all
+Depends: adduser, sox, ${misc:Depends}
+Description: Automatically save audio input
+ Listen for default alsa input and record any activity.
+ Runs as a daemon.
+ Files will be saved in a common directory.
+ Silence will no be saved.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644 (file)
index 0000000..420f29d
--- /dev/null
@@ -0,0 +1,3 @@
+© 2011 Nirgal Vourgère
+Release under GPL
+See /usr/share/common-licenses/GPL-3
diff --git a/debian/dirs b/debian/dirs
new file mode 100644 (file)
index 0000000..bc9a74b
--- /dev/null
@@ -0,0 +1 @@
+/var/lib/autosox/
diff --git a/debian/init b/debian/init
new file mode 100644 (file)
index 0000000..fdac8be
--- /dev/null
@@ -0,0 +1,56 @@
+#!/bin/sh
+#
+# autosox
+#
+### BEGIN INIT INFO
+# Provides:          autosox
+# Required-Start:    $remote_fs alsa-utils
+# Required-Stop:     $remote_fs alsa-utils
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Start recording the alsa input
+# Description:       See autosox package
+### END INIT INFO
+
+# Don't use set -e; check exit status instead
+
+# Exit silently if package is no longer installed
+[ -x /usr/lib/autosox/ ] || exit 0
+
+PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+MYNAME=/etc/init.d/autosox
+PID=/var/run/autosox.pid
+
+. /lib/lsb/init-functions
+
+case "$1" in
+  start)
+       log_daemon_msg "Starting alsa recording" "autosox"
+       if start-stop-daemon --start --quiet --oknodo --background --pidfile $PID --make-pidfile --chuid root:autosox --chdir /var/lib/autosox --exec /usr/lib/autosox/autosox; then
+           log_end_msg 0
+       else
+           log_end_msg 1
+       fi
+       ;;
+  stop)
+       EXITSTATUS=0
+       log_daemon_msg "Stoping alsa recording" "autosox"
+       if start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/autosox.pid; then
+           log_end_msg 0
+       else
+           log_end_msg 1
+       fi
+       ;;
+  restart|force-reload)
+       EXITSTATUS=0
+       $0 stop || EXITSTATUS=1
+       $0 start || EXITSTATUS=1
+       exit $EXITSTATUS
+       ;;
+  *)
+       echo "Usage: $MYNAME {start|stop|restart}" >&2
+       exit 1
+       ;;
+esac
+
+exit 0
diff --git a/debian/install b/debian/install
new file mode 100644 (file)
index 0000000..91ecf42
--- /dev/null
@@ -0,0 +1 @@
+autosox /usr/lib/autosox/
diff --git a/debian/postinst b/debian/postinst
new file mode 100755 (executable)
index 0000000..7cc620c
--- /dev/null
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+#
+# quoting from the policy:
+#     Any necessary prompting should almost always be confined to the
+#     post-installation script, and should be protected with a conditional
+#     so that unnecessary prompting doesn't happen if a package's
+#     installation fails and the `postinst' is called with `abort-upgrade',
+#     `abort-remove' or `abort-deconfigure'.
+
+
+case "$1" in
+    configure)
+               addgroup --quiet --system autosox
+               chown :autosox /var/lib/autosox
+               chmod g+ws /var/lib/autosox
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst called with unknown argument '$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
diff --git a/debian/postrm b/debian/postrm
new file mode 100644 (file)
index 0000000..23430ba
--- /dev/null
@@ -0,0 +1,37 @@
+#! /bin/sh
+# postrm script for autosox
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#      * <postrm> `remove'
+#      * <postrm> `purge'
+#      * <old-postrm> `upgrade' <new-version>
+#      * <new-postrm> `failed-upgrade' <old-version>
+#      * <new-postrm> `abort-install'
+#      * <new-postrm> `abort-install' <old-version>
+#      * <new-postrm> `abort-upgrade' <old-version>
+#      * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
+# for details, see /usr/share/doc/packaging-manual/
+
+case "$1" in
+       purge)
+               delgroup --quiet autosox > /dev/null || true
+               rm -rf /var/lib/autosox/
+               rm -rf /var/log/autosox.log
+               ;;
+
+       remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+               ;;
+       *)
+               echo "postrm called with unknown argument \`$1'" >&2
+               exit 0
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..cbe925d
--- /dev/null
@@ -0,0 +1,3 @@
+#!/usr/bin/make -f
+%:
+       dh $@
diff --git a/debian/source/format b/debian/source/format
new file mode 100644 (file)
index 0000000..89ae9db
--- /dev/null
@@ -0,0 +1 @@
+3.0 (native)