~tribaal/+junk/landscape-client-14.12-0ubuntu1.15.04

« back to all changes in this revision

Viewing changes to debian/landscape-client.config

  • Committer: Chris Glass
  • Date: 2014-12-12 15:02:18 UTC
  • Revision ID: chris.glass@canonical.com-20141212150218-pryod8v4nr262b00
Initial import of released debian/ subdir.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
PACKAGE=landscape-client
 
4
 
 
5
CONFIGFILE=/etc/landscape/client.conf
 
6
set -e
 
7
. /usr/share/debconf/confmodule
 
8
 
 
9
var_in_file() {
 
10
    var="$1"
 
11
    file="$2"
 
12
    line=$(grep "^$var\s*=\s*" "$file" 2>/dev/null || true)
 
13
    echo "$line"
 
14
}
 
15
 
 
16
get_var_from_file() {
 
17
    var="$1"
 
18
    file="$2"
 
19
    val=$(grep "^$var\s*=\s*" "$file" 2>/dev/null | tail -n1 | sed "s/^.*=\s*//")
 
20
    echo "$val"
 
21
}
 
22
 
 
23
update_var() {
 
24
    var="$1"
 
25
    file="$2"
 
26
    line=$(var_in_file $var $file)
 
27
    if [ -n "$line" ]; then
 
28
        val=$(get_var_from_file $var $file)
 
29
        # Store value from config file in debconf.
 
30
        db_set $PACKAGE/$var $val
 
31
    fi
 
32
}
 
33
 
 
34
# Load config file, if it exists.
 
35
if [ -e $CONFIGFILE ]; then
 
36
    # Replace old registration_password to registration_key
 
37
    sed -i -r 's/^registration_password[[:blank:]]*=/registration_key =/' $CONFIGFILE
 
38
    # Config file is "ini" type, not shell, so we cannot source it
 
39
    # If a setting is defined in the config file, update it in debconf
 
40
    # db.
 
41
    update_var "computer_title" "$CONFIGFILE"
 
42
    update_var "account_name" "$CONFIGFILE"
 
43
    update_var "registration_key" "$CONFIGFILE"
 
44
    update_var "url" "$CONFIGFILE"
 
45
    update_var "exchange_interval" "$CONFIGFILE"
 
46
    update_var "urgent_exchange_interval" "$CONFIGFILE"
 
47
    update_var "ping_url" "$CONFIGFILE"
 
48
    update_var "ping_interval" "$CONFIGFILE"
 
49
    update_var "http_proxy" "$CONFIGFILE"
 
50
    update_var "https_proxy" "$CONFIGFILE"
 
51
    update_var "tags" "$CONFIGFILE"
 
52
fi
 
53
 
 
54
# Ask questions.
 
55
# Do debconf configuration
 
56
db_get $PACKAGE/register_system
 
57
if [ "$RET" = true ]; then
 
58
    priority=high
 
59
else
 
60
    priority=medium
 
61
fi
 
62
db_input "$priority" $PACKAGE/computer_title || true
 
63
db_input "$priority" $PACKAGE/account_name || true
 
64
db_input "$priority" $PACKAGE/registration_key || true
 
65
 
 
66
db_go || true