~bigkevmcd/landscape-client/vm-info-in-cloud-registration

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
#!/bin/sh

PACKAGE=landscape-client

CONFIGFILE=/etc/landscape/client.conf
set -e
. /usr/share/debconf/confmodule

# This function also exists in the postinst, please keep them in sync
get_var_from_file() {
        var="$1"
        file="$2"
        val=$(grep "^$var\s*=\s*" "$file" 2>/dev/null | tail -n1 | sed "s/^.*=\s*//")
        echo "$val"
}

# Load config file, if it exists.
if [ -e $CONFIGFILE ]; then
	# Config file is "ini" type, not shell, so we cannot source it
	COMPUTER_TITLE=$(get_var_from_file "computer_title" "$CONFIGFILE")
	ACCOUNT_NAME=$(get_var_from_file "account_name" "$CONFIGFILE")
	REGISTRATION_PASSWORD=$(get_var_from_file "registration_password" "$CONFIGFILE")

        # Store values from config file into
        # debconf db.

        db_set $PACKAGE/computer_title $COMPUTER_TITLE
        db_set $PACKAGE/account_name $ACCOUNT_NAME
        db_set $PACKAGE/registration_password $REGISTRATION_PASSWORD

fi

# Ask questions.
# Do debconf configuration
db_get $PACKAGE/register_system
if [ "$RET" = true ]; then
    priority=high
else
    priority=medium
fi
db_input "$priority" $PACKAGE/computer_title || true
db_input "$priority" $PACKAGE/account_name || true
db_input "$priority" $PACKAGE/registration_password || true
db_go || true