#!/bin/sh # postinst script for hddtemp set -e conffile="/etc/default/hddtemp" update_config_file() { db_field=$1 config_field=$2 RET=false db_get $db_field if [ -n "$RET" ] ; then if grep -q "^$config_field" $conffile ; then # keep any admin changes, while replacing the variable content sed "s/^[ ]*$config_field=\".*\"/$config_field=\"$RET\"/" < $conffile > $conffile.new && mv $conffile.new $conffile else echo "$config_field=\"$RET\"" >> $conffile fi fi } # Source debconf library -- we have a Depends line # to make sure it is there... . /usr/share/debconf/confmodule db_version 2.0 case "$1" in configure) if [ -f $conffile ] ; then sed -i -e 's/^[ ]*DAEMON/RUN_DAEMON/g' \ -e 's/^[ ]*SYSLOG/RUN_SYSLOG/g' \ -e 's/^# Master system-wide hddtemp switch.*/# hddtemp network daemon switch. If set to true, hddtemp will listen/' \ -e 's/^# set to true. STOP THE SERVICE.*/# for incoming connections./' \ -e 's/^# Logging period.*temperatures.$/# Logging period (in seconds) for the temperatures. If set to a value\n# different than 0, hddtemp will run as a daemon periodically logging\n# the temperatures through syslog/' \ $conffile if ! grep -q RUN_SYSLOG $conffile ; then cat << EOF >> $conffile # Logging period (in seconds) for the temperatures. If set to a value # different than 0, hddtemp will run as a daemon periodically logging # the temperatures through syslog RUN_SYSLOG="0" EOF fi if ! grep -q OPTIONS $conffile ; then cat << EOF >> $conffile # Other options to pass to hddtemp OPTIONS="" EOF fi if ! grep -q DISKS_NOPROBE $conffile ; then cat << EOF >> $conffile # List of devices you want to use with hddtemp, but that would not be # probed for a working sensor. DISKS_NOPROBE="" EOF fi else cat << EOF > $conffile # Defaults for hddtemp initscript (/etc/init.d/hddtemp) # This is a POSIX shell fragment # [automatically edited by postinst, do not change line format ] # hddtemp network daemon switch. If set to true, hddtemp will listen # for incoming connections. RUN_DAEMON="true" # List of devices you want to use with hddtemp. If none specified, # hddtemp will probe standard devices. #DISKS="/dev/hda" # List of devices you want to use with hddtemp, but that would not be # probed for a working sensor. DISKS_NOPROBE="" # IP address of the interface on which you want hddtemp to be bound # on. If none specified, goes to 127.0.0.1. Use 0.0.0.0 to bind hddtemp # on all interfaces. INTERFACE="127.0.0.1" # Port number on which you want hddtemp to listen on. If none specified, # the port 7634 is used. PORT="7634" # Database file to use. If none specified, /etc/hddtemp.db is used. #DATABASE="/etc/hddtemp.db" # Separator to use between fields. The default separator is '|'. #SEPARATOR="|" # Logging period (in seconds) for the temperatures. If set to a value # different than 0, hddtemp will run as a daemon periodically logging # the temperatures through syslog RUN_SYSLOG="0" # Other options to pass to hddtemp OPTIONS="" EOF fi update_config_file hddtemp/daemon RUN_DAEMON update_config_file hddtemp/syslog RUN_SYSLOG update_config_file hddtemp/interface INTERFACE update_config_file hddtemp/port PORT if ! dpkg-statoverride --list /usr/sbin/hddtemp 1>/dev/null 2>&1; then # check if we are installing suid or not RET=false db_get hddtemp/SUID_bit if [ "$RET" = "true" ]; then chmod 4755 /usr/sbin/hddtemp ln -sf /usr/sbin/hddtemp /usr/bin/hddtemp ln -sf ../man8/hddtemp.8.gz /usr/share/man/man1/hddtemp.1.gz else chmod 0755 /usr/sbin/hddtemp rm -f /usr/bin/hddtemp rm -f /usr/share/man/man8/hddtemp.1.gz fi fi db_stop rm -f /etc/logcheck/ignore.d.workstation/hddtemp ;; 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. # Automatically added by dh_installinit/11.1.2ubuntu1 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then if [ -x "/etc/init.d/hddtemp" ]; then update-rc.d hddtemp defaults >/dev/null if [ -n "$2" ]; then _dh_action=restart else _dh_action=start fi invoke-rc.d hddtemp $_dh_action || exit 1 fi fi # End automatically added section exit 0