This file is indexed.

config is in uswsusp 1.0+20110509-2ubuntu1.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

  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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/bin/bash -e
#
# uswsusp.config -- configure script for uswsusp debian package
#
# Copyright 2006, 2007    Tim Dijkstra <tim@famdijkstra.org>
# Released under GPLv2

. /usr/share/debconf/confmodule

CONFIGFILE=/etc/uswsusp.conf

LOWQ="snapshot_device compute_checksum compress early_writeout image_size suspend_loglevel max_loglevel shutdown_method"
MEDQ="resume_device encrypt splash"
HIGHQ=""
NOTQ="RSA_key_file shutdown_method resume_offset"


# If we don't have /proc or /sys we can't work, this will probably
# be a chroot or so.
mountpoint -q /sys || 
  { echo "/sys not mounted. Can't create uswsusp.conf" >> /dev/stderr; exit 0; }
mountpoint -q /proc || 
  { echo "/proc not mounted. Can't create uswsusp.conf" >> /dev/stderr; exit 0; }

# Reset these flags
db_fset uswsusp/no_swap hit false
db_fset uswsusp/no_snapshot hit false
db_fset uswsusp/continue_without_swap hit false

# Swap file support is from 2.6.20
if dpkg --compare-versions `uname -r` lt 2.6.20; then
    NO_FILE=' && $2!="file"'
fi

# List of swaps, listed by size
SWAPLIST=
SWAPFIRST=
KOMMA=
for I in `sort -nr -k 3 /proc/swaps | awk '$2!="Type" '"$NO_FILE"' {print $1}'`; do
    SWAPLIST=${SWAPLIST}${KOMMA}$I
    if [ -z "$KOMMA" ]; then
	SWAPFIRST=$I
	KOMMA=", "
    fi
done

# Try to detect snapshot support
if [ ! -e /sys/class/misc/snapshot/dev ]; then 
    db_input critical uswsusp/no_snapshot || true
    db_fset uswsusp/no_snapshot hit true
    db_go || true
    exit 0
fi

IMAGESIZE=`awk '$1 == "MemTotal:" {print int($2*1024*0.46)}' /proc/meminfo 2> /dev/null`
if [ -n "$IMAGESIZE" ]; then
    db_set uswsusp/image_size $IMAGESIZE
fi

# Luckily the parser in s2disk is quite strict
if [ -e "$CONFIGFILE" ]; then
    for I in $LOWQ $MEDQ $HIGHQ $NOTQ; do
	VAL=`sed -n 's/^[[:space:]]*'"${I//_/ }"'[[:space:]]*[=:][[:space:]]*\([^[:space:]]*\)/\1/ p' $CONFIGFILE`

	# For boolean values it only checks for [yY]
	db_metaget uswsusp/$I type
	TYPE=$RET
	
	if [ "boolean" = "$TYPE" ]; then
	    if [ "$VAL" = "y" -o "$VAL" = "Y" ];  then
		db_set uswsusp/$I true
	    else
		db_set uswsusp/$I false
	    fi
	else
	    db_set uswsusp/$I "$VAL"
	fi
	    
    done
fi

# Check resume_device and resume_offset from the config file
db_get uswsusp/resume_device
USERSWAP=$RET
db_get uswsusp/resume_offset
USEROFFSET=$RET

if [ -z "$USERSWAP" ]; then
    # The user didn't set one: Set the first as default
    SWAPDEFAULT=$SWAPFIRST
elif echo "$SWAPLIST" | grep -q -e '\(^\|, \)'$USERSWAP'\(,\|$\)'; then
    # Valid swap partition
    SWAPDEFAULT=$USERSWAP
elif [ -n "$USEROFFSET" ] && [ -x /usr/sbin/swap-offset ]; then
    # Offset was specified
    # If we don't have swap-offset, this probably means uswsusp
    # was removed before, leaving the config file. Now we don't
    # have a way to check the offset. Best is to ask if this is OK

    devid=`printf "%02x%02x" $(stat -c "0x%t 0x%T" $USERSWAP 2> /dev/null)`

    while read name type rest; do
	[ "$type" == "file" ]  || continue;
	[ "$(stat -c '%D' $name)" == "$devid" ] || continue;
	[ "$USEROFFSET" == "$(swap-offset $name | cut -c17- )" ] || continue;

        SWAPDEFAULT=$name
	break
    done < /proc/swaps
fi
	
# Some people want to use a swap partition that is only mounted 
# during suspend. This means we can't find it in /proc/swaps, but
# it is a valid option non the less. To not remove their changes
# we add it to the SWAPLIST, but not after we confirmed this is 
# what they want.
if [ -z "$SWAPDEFAULT" ]; then
    # This can be:
    #   Offset is given, no sbin/swap-offset
    #   Offset is given, USERSWAP:USEROFFSET not in /proc/swaps
    #   No offset, USERSWAP not in /proc/swaps
    db_input critical uswsusp/continue_without_swap || true
    db_get uswsusp/continue_without_swap 
    if [ "$RET" = "true" ]; then
	SWAPLIST=${SWAPLIST}${KOMMA}${USERSWAP} ;
	SWAPDEFAULT=${USERSWAP}
	db_fset uswsusp/continue_without_swap hit true
    fi
fi

# If we still do not have a SWAPLIST, something is wrong
if [ -z "$SWAPLIST" ]; then 
    db_input critical uswsusp/no_swap || true
    db_fset uswsusp/no_swap hit true
    db_go || true
    exit 0
fi
db_subst uswsusp/resume_device list $SWAPLIST
db_set uswsusp/resume_device $SWAPDEFAULT

# If we're still here, reset the seen flags on error messages
# Maybe they had problems before, but not anymore...
db_fset uswsusp/no_swap seen false
db_fset uswsusp/no_snapshot seen false


# Stetup questions according to  priority
for I in $LOWQ; do
    db_input low uswsusp/$I || true
done	
    
for I in $MEDQ; do
    db_input medium uswsusp/$I || true
done

for I in $HIGHQ; do
    db_input high uswsusp/$I || true
done

# Ask questions
db_go || true

# Only if they want encryption, ask the RSA question
db_get uswsusp/encrypt
if [ "$RET" = "false" ]; then
    db_set uswsusp/create_RSA_key false
elif [ "$RET" = "true" ]; then
    # First ask filename
    while [ 1 ] ; do
	db_input low uswsusp/RSA_key_file || true
	db_go || true
        db_get uswsusp/RSA_key_file || true
	KEYFILE=$RET

	if [ -n "$KEYFILE" ]; then
	    break
	fi

	db_reset uswsusp/RSA_key_file
    done

    # Then ask if we should generate it, default to yes if they don't have one yet
    if [ -e "$KEYFILE" ]; then
	db_set uswsusp/create_RSA_key false
    else
	db_set uswsusp/create_RSA_key true
    fi

    db_input low uswsusp/create_RSA_key || true
    db_go || true

    # If they want it created, ask nr bits and passphrase (twice)
    db_get uswsusp/create_RSA_key
    if [ "$RET" = "true" ]; then
	while [ 1 ]; do
	    db_input low uswsusp/RSA_key_bits || true
	    db_go || true
	    db_get uswsusp/RSA_key_bits

	    if [ -z "$RET" ] || [ $RET -ge 1024 -a $RET -le 4096 ]; then
		break;
	    fi

	    db_reset uswsusp/RSA_key_bits
	done
	
	P1=A; P2=B;

	while [ "$P1" != "$P2" ]; do

	    db_input critical uswsusp/RSA_passphrase || true
	    db_input critical uswsusp/RSA_passphrase_v || true
	    db_go || true

	    db_get uswsusp/RSA_passphrase
	    if [ -n "$RET" ]; then P1=$RET; fi
	    db_get uswsusp/RSA_passphrase_v
	    if [ -n "$RET" ]; then P2=$RET; fi
	done
    fi
fi