--- /dev/null
+#!/bin/sh
+
+###
+### This script is distributed in the terms of GNU GPL v3.0+
+### (c) Andrew Sichevoi, http://thekondor.net
+###
+### Name: install-acpi-call
+### Description: simple installation script of ``acpi_call`` module.
+### Notes:
+### 1. The script is intended for Debian GNU/Linux
+### 2. The script downloads the latest version of ``acpi_call`` from the home repository and
+### installs the built module using DKMS.
+###
+### Arguments:
+### none
+###
+
+SOURCE_DIR=/usr/src
+MODULE_VERSION=42
+MODULE_NAME=acpi_call
+
+DIST_DIR=${MODULE_NAME}-${MODULE_VERSION}
+FULL_DIST_DIR_PATH=${SOURCE_DIR}/${DIST_DIR}
+
+REQUIRED_PACKAGES="dkms build-essential git"
+SOURCE_REPOSITORY="https://github.com/peberlein/acpi_call"
+
+_error()
+{
+ echo "Error: $@"
+ exit 1
+}
+
+_check_permissions()
+{
+ if [ "root" != $(whoami) ]; then
+ _error "Must be run with root privileges"
+ fi
+}
+
+__check_package_availability()
+{
+ /usr/bin/dpkg -s ${1} 2>/dev/null 1>&2
+ return $?
+}
+
+_check_essential_packages()
+{
+ missing_packages=""
+
+ for package in ${REQUIRED_PACKAGES}; do
+ __check_package_availability ${package} || missing_packages="${missing_packages} ${package}"
+ done
+
+ if [ ! -z "${missing_packages}" ]; then
+ extra_msg="Please note that some other packages must be requested during the installation"
+ _error "The following packages are not installed but required: ${missing_packages}\n${extra_msg}"
+ fi
+}
+
+__check_directory_existence()
+{
+ test ! -d $1
+ return $?
+}
+
+_check_if_already_installed()
+{
+ __check_directory_existence ${FULL_DIST_DIR_PATH}
+ if [ ! 0 -eq $? ]; then
+ _error "The module is already installed. Directory '${FULL_DIST_DIR_PATH}' must be removed prior installation"
+ fi
+}
+
+_download_sources()
+{
+ /usr/bin/git clone ${SOURCE_REPOSITORY} ${FULL_DIST_DIR_PATH}
+ if [ ! 0 -eq $? ]; then
+ _error "Sources could not be retrieved"
+ fi
+}
+
+_create_dkms_config()
+{
+ (
+ cat <<EOF
+###
+### Desc: simple DKMS configuration for ACPI_CALL module
+###
+### Author : Andrew Sichevoi, http://thekondor.net
+### License: GNU GPL v3.0+
+###
+
+PACKAGE_NAME="acpi_call"
+PACKAGE_VERSION=${MODULE_VERSION}
+
+AUTOINSTALL=yes
+REMAKE_INITRD=no
+
+BUILT_MODULE_NAME="${MODULE_NAME}"
+BUILT_MODULE_LOCATION="."
+DEST_MODULE_LOCATION="/kernel/misc"
+
+MAKE="make -C . KERNELDIR=/lib/modules/${kernelver}/build"
+CLEAN="make -C ."
+EOF
+ ) > ${FULL_DIST_DIR_PATH}/dkms.conf
+}
+
+_register_dkms_module()
+{
+ dkms add -m ${MODULE_NAME} -v ${MODULE_VERSION}
+ if [ ! 0 -eq $? ]; then
+ _error "DKMS module cannot be registered"
+ fi
+}
+
+_build_dkms_module()
+{
+ dkms build -m ${MODULE_NAME} -v ${MODULE_VERSION}
+ if [ ! 0 -eq $? ]; then
+ _error "DKMS module cannot be built"
+ fi
+}
+
+_install_dkms_module()
+{
+ dkms install -m ${MODULE_NAME} -v ${MODULE_VERSION}
+ if [ ! 0 -eq $? ]; then
+ _error "DKMS module cannot be installed"
+ fi
+}
+
+
+_check_permissions
+_check_if_already_installed
+_check_essential_packages
+_download_sources
+_create_dkms_config
+_register_dkms_module
+_build_dkms_module
+_install_dkms_module
+