summaryrefslogtreecommitdiff
path: root/system/hdapsd
diff options
context:
space:
mode:
authoralkos333 <me@alkso333.net>2010-05-12 23:33:37 +0200
committerRobby Workman <rworkman@slackbuilds.org>2010-05-12 23:33:37 +0200
commit4db878070ac8636be9cad28bdeae6ecf168ff662 (patch)
treee43d809a944368434f339579ecd192c338e0ddba /system/hdapsd
parenta4f48c6e2036f6636a786f85bbbd41f023230042 (diff)
downloadslackbuilds-4db878070ac8636be9cad28bdeae6ecf168ff662.tar.gz
system/hdapsd: Added to 12.2 repository
Diffstat (limited to 'system/hdapsd')
-rw-r--r--system/hdapsd/README16
-rw-r--r--system/hdapsd/README.SLACKWARE17
-rw-r--r--system/hdapsd/doinst.sh23
-rw-r--r--system/hdapsd/hdapsd-mksrctarball.sh26
-rw-r--r--system/hdapsd/hdapsd.SlackBuild111
-rw-r--r--system/hdapsd/hdapsd.conf22
-rw-r--r--system/hdapsd/hdapsd.info8
-rw-r--r--system/hdapsd/rc.hdapsd86
-rw-r--r--system/hdapsd/slack-desc19
9 files changed, 328 insertions, 0 deletions
diff --git a/system/hdapsd/README b/system/hdapsd/README
new file mode 100644
index 0000000000..620eb61375
--- /dev/null
+++ b/system/hdapsd/README
@@ -0,0 +1,16 @@
+This is a disk protection user-space daemon for IBM/Lenovo ThinkPads.
+It monitors the acceleration values through the HDAPS interface and
+automatically initiates disk head parking if a fall or sliding of the
+laptop is detected.
+
+If you would like to use the latest source when building your
+hdapsd package, you will need to get it from their git server.
+In order to do that, use the included hdapsd-mksrctarball.sh
+script, which will download the source code and will create
+a compressed tarball using today's date (YYYYMMDD) as its version string.
+To use your newly download source, you will need to tell the SlackBuild
+to use it like so: VERSION=YYYYMMDD ./hdapsd.SlackBuild
+
+Be sure to see README.SLACKWARE for usage information.
+
+This requires tp_smapi.
diff --git a/system/hdapsd/README.SLACKWARE b/system/hdapsd/README.SLACKWARE
new file mode 100644
index 0000000000..1146b3b74f
--- /dev/null
+++ b/system/hdapsd/README.SLACKWARE
@@ -0,0 +1,17 @@
+hdapsd README.SLACKWARE - 20090329 <rworkman@slackbuilds.org>
+
+We have added a custom /etc/hdapsd.conf file in which you can specify
+various details about your system without editing the installed init
+script; however, the init script has sane defaults for most systems.
+In particular, if your Thinkpad's primary disk drive is not /dev/sda,
+then you will need to edit the config file.
+
+To run hdapsd at boot, add the following to /etc/rc.d/rc.local:
+
+ if [ -x /etc/rc.d/rc.hdapsd ]; then
+ /etc/rc.d/rc.hdapsd start
+ fi
+
+Then you can simply start the HDAPS daemon without rebooting:
+ /etc/rc.d/rc.hdapsd start
+
diff --git a/system/hdapsd/doinst.sh b/system/hdapsd/doinst.sh
new file mode 100644
index 0000000000..bfb1617ab2
--- /dev/null
+++ b/system/hdapsd/doinst.sh
@@ -0,0 +1,23 @@
+config() {
+ NEW="$1"
+ OLD="$(dirname $NEW)/$(basename $NEW .new)"
+ # If there's no config file by that name, mv it over:
+ if [ ! -r $OLD ]; then
+ mv $NEW $OLD
+ elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
+ # toss the redundant copy
+ rm $NEW
+ fi
+ # Otherwise, we leave the .new copy for the admin to consider...
+}
+
+# Keep same perms on rc.hdapsd.new:
+if [ -e etc/rc.d/rc.hdapsd ]; then
+ cp -a etc/rc.d/rc.hdapsd etc/rc.d/rc.hdapsd.new.incoming
+ cat etc/rc.d/rc.hdapsd.new > etc/rc.d/rc.hdapsd.new.incoming
+ mv etc/rc.d/rc.hdapsd.new.incoming etc/rc.d/rc.hdapsd.new
+fi
+
+config /etc/rc.d/rc.hdapsd.new
+config /etc/hdapsd.conf.new
+
diff --git a/system/hdapsd/hdapsd-mksrctarball.sh b/system/hdapsd/hdapsd-mksrctarball.sh
new file mode 100644
index 0000000000..7431d82648
--- /dev/null
+++ b/system/hdapsd/hdapsd-mksrctarball.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# This script helps you to download and compress the
+# sourcecode for ffmpeg from its svn server.
+# Copyright (c) 2008 alkos333 <me@alkos333.net>
+
+# Based on ffmpeg-mksrctarball.sh (SlackBuilds.org, Slackware 12.0)
+
+# Thanks to Antonio Hernández Blas for a suggestion on SBo mailing list
+
+set -e
+
+PRGNAM=hdapsd
+VERSION=$(date +"%Y%m%d")
+GITSERVER=git://repo.or.cz/hdapsd.git
+
+echo "--> Downloading sourcecode from $GITSERVER"
+git clone $GITSERVER $PRGNAM-$VERSION 2>&1
+
+echo "--> Making the sourcecode tarball: $PRGNAM-$VERSION.tar.bz2 "
+tar -c $PRGNAM-$VERSION/ | bzip2 -9 > $PRGNAM-$VERSION.tar.bz2
+
+echo "--> Erasing the sourcecode directory: $PRGNAM-$VERSION/"
+rm -rf $PRGNAM-$VERSION/
+
+echo "--> Sourcecode tarball for $PRGNAM: $PRGNAM-$VERSION.tar.bz2"
diff --git a/system/hdapsd/hdapsd.SlackBuild b/system/hdapsd/hdapsd.SlackBuild
new file mode 100644
index 0000000000..5922b826b9
--- /dev/null
+++ b/system/hdapsd/hdapsd.SlackBuild
@@ -0,0 +1,111 @@
+#!/bin/sh
+
+# Slackware build script for hdapsd
+
+# Copyright (c) 2008 alkos333 <me@alkos333.net>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Modified by Robby Workman <rworkman@slackbuilds.org>
+
+PRGNAM=hdapsd
+VERSION=${VERSION:-20090328}
+ARCH=${ARCH:-i486}
+BUILD=${BUILD:-1}
+TAG=${TAG:-_SBo}
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp/SBo}
+PKG=$TMP/package-$PRGNAM
+OUTPUT=${OUTPUT:-/tmp}
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+elif [ "$ARCH" = "i686" ]; then
+ SLKCFLAGS="-O2 -march=i686 -mtune=i686"
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+fi
+
+set -e
+
+rm -rf $PKG
+mkdir -p $TMP $PKG $OUTPUT
+cd $TMP
+rm -rf $PRGNAM-$VERSION
+tar xvf $CWD/$PRGNAM-$VERSION.tar.bz2
+cd $PRGNAM-$VERSION
+chown -R root:root .
+chmod -R u+w,go+r-w,a-s .
+
+./autogen.sh
+
+CFLAGS="$SLKCFLAGS" \
+CXXFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --localstatedir=/var \
+ --mandir=/usr/man \
+ --docdir=/usr/doc/$PRGNAM-$VERSION \
+ --build=$ARCH-slackware-linux
+
+make
+make install DESTDIR=$PKG
+
+( cd $PKG
+ find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | \
+ xargs strip --strip-unneeded 2> /dev/null || true
+ find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | \
+ xargs strip --strip-unneeded 2> /dev/null
+)
+
+( cd $PKG/usr/man
+find . -type f -exec gzip -9 {} \;
+for i in $( find . -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
+)
+
+# Install a sample config file and init script
+mkdir -p $PKG/etc/rc.d
+cat $CWD/hdapsd.conf > $PKG/etc/hdapsd.conf.new
+cat $CWD/rc.hdapsd > $PKG/etc/rc.d/rc.hdapsd.new
+chmod 0755 $PKG/etc/rc.d/rc.hdapsd.new
+
+# Put udev rules in the right place and prefix them with a number
+# 51 is more or less arbitrary, but should be fine
+# If anyone has a link to what other distributions are doing, let us know
+#mkdir -p $PKG/lib
+#mv $PKG/etc/udev $PKG/lib
+#mv $PKG/lib/udev/rules.d/hdapsd.rules $PKG/lib/udev/rules.d/51-hdapsd.rules
+
+mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
+# ChangeLog NEWS README are empty
+cp -a AUTHORS COPYING $PKG/usr/doc/$PRGNAM-$VERSION
+cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
+cat $CWD/README.SLACKWARE > $PKG/usr/doc/$PRGNAM-$VERSION/README.SLACKWARE
+find $PKG/usr/doc -type f -exec chmod 644 {} \;
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+cat $CWD/doinst.sh > $PKG/install/doinst.sh
+
+cd $PKG
+/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.tgz
diff --git a/system/hdapsd/hdapsd.conf b/system/hdapsd/hdapsd.conf
new file mode 100644
index 0000000000..46c900a124
--- /dev/null
+++ b/system/hdapsd/hdapsd.conf
@@ -0,0 +1,22 @@
+# This file contains system-specific variables for hdapsd
+# Edit it as needed for your system
+
+# See also /etc/rc.d/rc.hdapsd
+
+# Primary hard disk's device node
+# This defaults to "/dev/sda" in the init script if undefined here
+#HD_DEV="/dev/sda"
+
+# Sensitivity
+# This defaults to "15" if undefined here
+#SENSITIVITY="15"
+
+# Turn on logging to syslog instead of stdout
+# Default is yes if undefined here
+# 0=no 1=yes
+#USE_SYSLOG="1"
+
+# Location of pid file
+# This defaults to /var/run/hdapsd.pid if undefined here
+#PIDFILE="/var/run/hdapsd.pid"
+
diff --git a/system/hdapsd/hdapsd.info b/system/hdapsd/hdapsd.info
new file mode 100644
index 0000000000..9e681fd04e
--- /dev/null
+++ b/system/hdapsd/hdapsd.info
@@ -0,0 +1,8 @@
+PRGNAM="hdapsd"
+VERSION="20090328"
+HOMEPAGE="http://repo.or.cz/w/hdapsd.git"
+DOWNLOAD="http://slackbuilds.org/sources/12.2/hdapsd-20090328.tar.bz2"
+MD5SUM="1f70f3cc8f1d89dfa8b166f6dc4158a8"
+MAINTAINER="alkos333"
+EMAIL="me@alkso333.net"
+APPROVED="rworkman"
diff --git a/system/hdapsd/rc.hdapsd b/system/hdapsd/rc.hdapsd
new file mode 100644
index 0000000000..50ea4ce266
--- /dev/null
+++ b/system/hdapsd/rc.hdapsd
@@ -0,0 +1,86 @@
+#!/bin/sh
+
+# /etc/rc.d/rc.hdapsd
+# Start/stop the HDAPS deamon
+# Copyright (c) 2008 alkos333 <me@alkos333.net>
+
+# Define a quick function to alert that the expected config file is bad
+bad_config() {
+ printf "Error: /etc/hdapsd.conf either is not readable\n"
+ printf " or contains a syntax error. Exiting...\n"
+ exit 1
+}
+
+# Source in the config file
+if [ -r /etc/hdapsd.conf ]; then
+ . /etc/hdapsd.conf 2>/dev/null || bad_config
+fi
+
+HD_DEV=${HD_DEV:-/dev/sda} # Defaults to /dev/sda
+SENSITIVITY=${SENSITIVITY:-15} # Defaults to 15
+PIDFILE=${PIDFILE:-"/var/run/hdapsd.pid"} # Default
+USE_SYSLOG=${USE_SYSLOG:-1} # 0=no 1=yes Defaults to yes
+
+if [ "$USE_SYSLOG" = "1" ]; then
+ ENABLESYSLOG="-l"
+else
+ ENABLESYSLOG=""
+fi
+
+hdapsd_start() {
+ if [ -f ${PIDFILE} ]; then
+ printf "HDAPS appears to already be running...\n"
+ printf "If that's not the case, then remove $PIDFILE and try again...\n"
+ exit 1
+ else
+ # Sanity check, just in case
+ if [ ! -b ${HD_DEV} ]; then
+ printf "${HD_DEV} either does not exist or is not a block device.\n"
+ printf "Check your configuration. Exiting.\n"
+ exit 1
+ else
+ printf "Starting HDAPS daemon... \n"
+ /usr/sbin/hdapsd -v -d $(basename ${HD_DEV}) -s ${SENSITIVITY} ${ENABLESYSLOG} \
+ -a -b --pidfile=${PIDFILE} 1> /dev/null
+ fi
+ fi
+}
+
+hdapsd_stop() {
+ printf "Stopping HDAPS daemon...\n"
+ if [ -f ${PIDFILE} ]; then
+ kill $(cat ${PIDFILE}) 2> /dev/null
+ rm -f ${PIDFILE}
+ else
+ killall hdapsd 2>/dev/null
+ fi
+}
+
+hdapsd_status() {
+ if [ -f ${PIDFILE} ]; then
+ printf "HDAPS daemon is running...\n"
+ else
+ printf "HDAPS daemon is stopped...\n"
+ fi
+}
+
+case $1 in
+ start)
+ hdapsd_start
+ ;;
+ stop)
+ hdapsd_stop
+ ;;
+ restart)
+ hdapsd_stop
+ hdapsd_start
+ ;;
+ status)
+ hdapsd_status
+ ;;
+ *)
+ printf "Usage $0 {start|stop|restart|status}\n"
+ exit 1
+ ;;
+esac
+
diff --git a/system/hdapsd/slack-desc b/system/hdapsd/slack-desc
new file mode 100644
index 0000000000..4897cd8229
--- /dev/null
+++ b/system/hdapsd/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+hdapsd: hdapsd (HDAPS Daemon for Thinkpad Laptops)
+hdapsd:
+hdapsd: This is a disk protection userspace daemon for IBM/Lenovo ThinkPads.
+hdapsd: It monitors the acceleration values through the HDAPS interface and
+hdapsd: automatically initiates disk head parking if a fall or sliding of the
+hdapsd: laptop is detected.
+hdapsd:
+hdapsd: Homepage: http://repo.or.cz/w/hdapsd.git
+hdapsd:
+hdapsd:
+hdapsd: