File: postinst

package info (click to toggle)
hddtemp 0.3-beta13-9
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,964 kB
  • ctags: 1,317
  • sloc: ansic: 10,470; sh: 4,470; makefile: 522; yacc: 288; perl: 19; sed: 16
file content (127 lines) | stat: -rw-r--r-- 3,144 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/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 -e "s/^[ ]*DAEMON/RUN_DAEMON/g" $conffile > $conffile.new
	  mv $conffile.new $conffile
	  if ! grep -q SYSLOG $conffile ; then
	    cat << EOF >> $conffile

# Logging period (in seconds) for the temperatures.
SYSLOG="0"
EOF
	  fi
	  if ! grep -q OPTIONS $conffile ; then
	    cat << EOF >> $conffile

# Other options to pass to hddtemp
OPTIONS=""
EOF
	  fi
	else
          cat << EOF > $conffile
# Defaults for hddtemp initscript (/etc/init.d/hddtemp)
# This is a POSIX shell fragment

# Master system-wide hddtemp switch. The initscript will not run if it is not
# set to true. STOP THE SERVICE BEFORE DISABLING IT!

# [automatically edited by postinst, do not change line format or set it to
# anything but false or true ]
RUN_DAEMON="true"

# List of devices you want to use with hddtemp. If none specified,
# hddtemp will probe standard devices.
#DISKS="/dev/hda"

# 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.
SYSLOG="0"

# Other options to pass to hddtemp
OPTIONS=""
EOF
	fi
    
	update_config_file hddtemp/daemon RUN_DAEMON
	update_config_file hddtemp/syslog 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.

#DEBHELPER#

exit 0