summaryrefslogtreecommitdiff
path: root/community/hdapsd
diff options
context:
space:
mode:
authorroot <root@rshg054.dnsready.net>2012-07-28 00:02:21 +0000
committerroot <root@rshg054.dnsready.net>2012-07-28 00:02:21 +0000
commita5c2e73ba30c769148056635676165a4265eac83 (patch)
treee9a7043a5fc46bc7021cfb8503fc9245bbee4057 /community/hdapsd
parent2c30604c9ff749660a4b8507eec99e679cf19508 (diff)
Sat Jul 28 00:02:21 UTC 2012
Diffstat (limited to 'community/hdapsd')
-rw-r--r--community/hdapsd/PKGBUILD42
-rw-r--r--community/hdapsd/hdapsd.conf.d22
-rw-r--r--community/hdapsd/hdapsd.rc.d60
-rw-r--r--community/hdapsd/hdapsd.systemd12
-rw-r--r--community/hdapsd/hdapsd.wrapper20
5 files changed, 156 insertions, 0 deletions
diff --git a/community/hdapsd/PKGBUILD b/community/hdapsd/PKGBUILD
new file mode 100644
index 000000000..74aa528f0
--- /dev/null
+++ b/community/hdapsd/PKGBUILD
@@ -0,0 +1,42 @@
+# Maintainer: Lukas Fleischer <archlinux at cryptocrack dot de>
+# Contributor: Emil Renner Berthing <esmil@mailme.dk>
+# Contributor: Xiao-Long Chen <chenxiaolong@cxl.epac.to>
+
+pkgname=hdapsd
+pkgver=20090401
+pkgrel=5
+pkgdesc='HDAPS userspace hard drive protection daemon'
+arch=('i686' 'x86_64')
+url='http://sourceforge.net/projects/hdaps/'
+license=('GPL')
+depends=('glibc')
+backup=('etc/conf.d/hdapsd')
+source=("http://downloads.sourceforge.net/hdaps/hdapsd-${pkgver}.tar.gz"
+ 'hdapsd.conf.d'
+ 'hdapsd.rc.d'
+ 'hdapsd.systemd'
+ 'hdapsd.wrapper')
+md5sums=('897cee8b0192febd127470f3e9506aeb'
+ '07fc036c8717bf5a38bbc269ed38ad19'
+ '9ab70348da9751810a2bbac51e18ac75'
+ '4b1378d43dc9431982f6605265c24f3b'
+ '11270661f3a543268786a68bbe74a6bb')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+
+ ./configure --prefix=/usr --sysconfdir=/etc
+ make ${MAKEFLAGS}
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+
+ make DESTDIR="${pkgdir}/" install
+
+ # install rc script and its configuration file
+ install -Dm0644 "${srcdir}/hdapsd.conf.d" "${pkgdir}/etc/conf.d/hdapsd"
+ install -Dm0755 "${srcdir}/hdapsd.rc.d" "${pkgdir}/etc/rc.d/hdapsd"
+ install -Dm0644 "${srcdir}/hdapsd.systemd" "${pkgdir}/usr/lib/systemd/system/hdapsd.service"
+ install -Dm0755 "${srcdir}/hdapsd.wrapper" "${pkgdir}/usr/sbin/hdapsd-wrapper"
+}
diff --git a/community/hdapsd/hdapsd.conf.d b/community/hdapsd/hdapsd.conf.d
new file mode 100644
index 000000000..eb99fdc2c
--- /dev/null
+++ b/community/hdapsd/hdapsd.conf.d
@@ -0,0 +1,22 @@
+# DEVICE specifies the device to monitor, defaults to "sda".
+#DEVICE='sda'
+
+# If an ultrabay hard drive is inserted, the following can be used:
+#DEVICE=('sda' 'sdb')
+
+# SENSITIVITY is self explanatory, defaults to "15".
+#SENSITIVITY='15'
+
+# Set ADAPTIVE to "yes" to enable adaptive threshold (automatically increase
+# when the built-in keyboard/mouse is used).
+#ADAPTIVE='yes'
+
+# Set SYSLOG to "yes" to have the daemon report errors to syslog (instead of
+# stderr/stdout).
+SYSLOG='yes'
+
+# Set FORCE to "yes" to force the kernel to use the unload heads feature on
+# some old hard drives for which support cannot be autodetected (don't use this
+# unless you're absolutely sure your hard drive really supports unloading
+# heads).
+#FORCE='yes'
diff --git a/community/hdapsd/hdapsd.rc.d b/community/hdapsd/hdapsd.rc.d
new file mode 100644
index 000000000..f4e8a6b99
--- /dev/null
+++ b/community/hdapsd/hdapsd.rc.d
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+[ -f /etc/conf.d/hdapsd ] && . /etc/conf.d/hdapsd
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+PIDFILE=/var/run/hdapsd.pid
+PID=`cat ${PIDFILE} 2> /dev/null`
+
+case "$1" in
+ start)
+ stat_busy "Starting hdapsd"
+
+ ## The daemon will try to autoload the kernel module
+ #if [ ! -d /sys/devices/platform/hdaps ]; then
+ # stat_fail
+ # echo "You need to load the hdaps kernel module."
+ # exit 1
+ #fi
+
+ ## Set up options to the hdapsd daemon
+ HDAPSD_OPTS="-bp"
+ if [ -z "${DEVICE}" ]; then
+ HDAPSD_OPTS="${HDAPSD_OPTS} -d sda"
+ else
+ for i in ${DEVICE[@]}; do
+ HDAPSD_OPTS="${HDAPSD_OPTS} -d ${i}"
+ done
+ fi
+ [ ! -z "${SENSITIVITY}" ] && HDAPSD_OPTS="${HDAPSD_OPTS} -s ${SENSITIVITY}"
+ [ "${ADAPTIVE}" = "yes" ] && HDAPSD_OPTS="${HDAPSD_OPTS} -a"
+ [ "${SYSLOG}" = "yes" ] && HDAPSD_OPTS="${HDAPSD_OPTS} -l"
+ [ "${FORCE}" = "yes" ] && HDAPSD_OPTS="${HDAPSD_OPTS} -f"
+ [ -z "${PID}" ] && /usr/sbin/hdapsd ${HDAPSD_OPTS}
+ if [ ${?} -gt 0 ]; then
+ stat_fail
+ else
+ add_daemon hdapsd
+ stat_done
+ fi
+ ;;
+ stop)
+ stat_busy "Stopping hdapsd"
+ [ ! -z "${PID}" ] && kill $PID &> /dev/null
+ if [ ${?} -gt 0 ]; then
+ stat_fail
+ else
+ rm_daemon hdapsd
+ stat_done
+ fi
+ ;;
+ restart)
+ ${0} stop
+ sleep 1
+ ${0} start
+ ;;
+ *)
+ echo "usage: ${0} {start|stop|restart}"
+esac
diff --git a/community/hdapsd/hdapsd.systemd b/community/hdapsd/hdapsd.systemd
new file mode 100644
index 000000000..328699bc7
--- /dev/null
+++ b/community/hdapsd/hdapsd.systemd
@@ -0,0 +1,12 @@
+[Unit]
+Description=HDAPS userspace hard drive protection daemon
+After=syslog.target
+
+[Service]
+Type=forking
+PIDFile=/var/run/hdapsd.pid
+ExecStart=/usr/sbin/hdapsd-wrapper
+ExecReload=/bin/kill -HUP ${MAINPID}
+
+[Install]
+WantedBy=multi-user.target
diff --git a/community/hdapsd/hdapsd.wrapper b/community/hdapsd/hdapsd.wrapper
new file mode 100644
index 000000000..d74fd272d
--- /dev/null
+++ b/community/hdapsd/hdapsd.wrapper
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+[ -f /etc/conf.d/hdapsd ] && source /etc/conf.d/hdapsd
+
+OPTS="-bp"
+
+if [ -z "${DEVICE}" ]; then
+ OPTS="${OPTS} -d sda"
+else
+ for i in ${DEVICE[@]}; do
+ OPTS="${OPTS} -d ${i}"
+ done
+fi
+
+[ ! -z "${SENSITIVITY}" ] && OPTS="${OPTS} -s ${SENSITIVITY}"
+[ "${ADAPTIVE}" == "yes" ] && OPTS="${OPTS} -a"
+[ "${SYSLOG}" == "yes" ] && OPTS="${OPTS} -l"
+[ "${FORCE}" == "yes" ] && OPTS="${OPTS} -f"
+
+/usr/sbin/hdapsd ${OPTS}