Merge lp:~milner/landscape-client/enable-preseed into lp:~landscape/landscape-client/trunk

Proposed by Mike Milner
Status: Merged
Approved by: Alberto Donato
Approved revision: 369
Merged at revision: 370
Proposed branch: lp:~milner/landscape-client/enable-preseed
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 175 lines (+73/-28)
4 files modified
debian/landscape-client.config (+19/-16)
debian/landscape-client.postinst (+14/-9)
debian/landscape-client.templates (+12/-0)
debian/po/templates.pot (+28/-3)
To merge this branch: bzr merge lp:~milner/landscape-client/enable-preseed
Reviewer Review Type Date Requested Status
Alberto Donato (community) Approve
Free Ekanayaka (community) Approve
Review via email: mp+77994@code.launchpad.net

Description of the change

Add the server url and the pingserver url into debconf to allow preseeding the landscape-client package.

To test:

# Clean out existing install
sudo apt-get purge landscape-common landscape-client
sudo rm -f /etc/landscape/client.conf

# Use debconf-set-selections to simulate preseeding
cat > temp.debconf <<EOF
landscape-client landscape-client/register_system boolean true
landscape-client landscape-client/computer_title string my-computer-title
landscape-client landscape-client/account_name string my-account-name
landscape-client landscape-client/registration_password password my-password
landscape-client landscape-client/url string https://landscape.ubuntu.com/my-message-server
landscape-client landscape-client/ping_url string http://landscape.ubuntu.com/my-ping-server
EOF
sudo debconf-set-selections temp.debconf

# Now install the package
sudo dpkg -i landscape-*

# Verify config file was set up correctly
sudo cat /etc/landscape/client.conf

To post a comment you must log in.
Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

Looks good! +1

[1]

  REGISTRATION_PASSWORD=$(get_var_from_file "registration_password" "$CONFIGFILE")
+ URL=$(get_var_from_file "url" "$CONFIGFILE")
+ PING_URL=$(get_var_from_file "ping_url" "$CONFIG_FILE")

The files uses a mix of tabs and spaces for indentation, it'd be nice to clean it up (maybe as a separate [trivial]).

[2]

+url = ${URL}
+ping_url = ${PING_URL}

Any particular reason to not write also the computer_title, registration_password and account_name fields to the file?

review: Approve
Revision history for this message
Alberto Donato (ack) wrote :

Good! +1

review: Approve
370. By Mike Milner

Make indentaion 4 spaces instead of a mix of tabs and spaces.
This is consistent with the rest of the project.

Revision history for this message
Mike Milner (milner) wrote :

> Looks good! +1
>
> [1]
>
> REGISTRATION_PASSWORD=$(get_var_from_file "registration_password"
> "$CONFIGFILE")
> + URL=$(get_var_from_file "url" "$CONFIGFILE")
> + PING_URL=$(get_var_from_file "ping_url" "$CONFIG_FILE")
>
> The files uses a mix of tabs and spaces for indentation, it'd be nice to clean
> it up (maybe as a separate [trivial]).

This was only a few extra lines so I just fixed it here.

>
> [2]
>
> +url = ${URL}
> +ping_url = ${PING_URL}
>
> Any particular reason to not write also the computer_title,
> registration_password and account_name fields to the file?

Under the existing code the script relies on landscape-config to write the computer_title, account_name, and registration_password to the config file. Looking through the code, it doesn't seem like it does anything special to validate the data. I'll leave it for now but I may refactor in future preseed branches.

Thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/landscape-client.config' (properties changed: -x to +x)
--- debian/landscape-client.config 2008-09-11 18:39:18 +0000
+++ debian/landscape-client.config 2011-10-04 11:39:25 +0000
@@ -8,26 +8,29 @@
88
9# This function also exists in the postinst, please keep them in sync9# This function also exists in the postinst, please keep them in sync
10get_var_from_file() {10get_var_from_file() {
11 var="$1"11 var="$1"
12 file="$2"12 file="$2"
13 val=$(grep "^$var\s*=\s*" "$file" 2>/dev/null | tail -n1 | sed "s/^.*=\s*//")13 val=$(grep "^$var\s*=\s*" "$file" 2>/dev/null | tail -n1 | sed "s/^.*=\s*//")
14 echo "$val"14 echo "$val"
15}15}
1616
17# Load config file, if it exists.17# Load config file, if it exists.
18if [ -e $CONFIGFILE ]; then18if [ -e $CONFIGFILE ]; then
19 # Config file is "ini" type, not shell, so we cannot source it19 # Config file is "ini" type, not shell, so we cannot source it
20 COMPUTER_TITLE=$(get_var_from_file "computer_title" "$CONFIGFILE")20 COMPUTER_TITLE=$(get_var_from_file "computer_title" "$CONFIGFILE")
21 ACCOUNT_NAME=$(get_var_from_file "account_name" "$CONFIGFILE")21 ACCOUNT_NAME=$(get_var_from_file "account_name" "$CONFIGFILE")
22 REGISTRATION_PASSWORD=$(get_var_from_file "registration_password" "$CONFIGFILE")22 REGISTRATION_PASSWORD=$(get_var_from_file "registration_password" "$CONFIGFILE")
2323 URL=$(get_var_from_file "url" "$CONFIGFILE")
24 # Store values from config file into24 PING_URL=$(get_var_from_file "ping_url" "$CONFIG_FILE")
25 # debconf db.25
2626 # Store values from config file into
27 db_set $PACKAGE/computer_title $COMPUTER_TITLE27 # debconf db.
28 db_set $PACKAGE/account_name $ACCOUNT_NAME28
29 db_set $PACKAGE/registration_password $REGISTRATION_PASSWORD29 db_set $PACKAGE/computer_title $COMPUTER_TITLE
3030 db_set $PACKAGE/account_name $ACCOUNT_NAME
31 db_set $PACKAGE/registration_password $REGISTRATION_PASSWORD
32 db_set $PACKAGE/url $URL
33 db_set $PACKAGE/ping_url $PING_URL
31fi34fi
3235
33# Ask questions.36# Ask questions.
3437
=== modified file 'debian/landscape-client.postinst'
--- debian/landscape-client.postinst 2010-06-10 15:34:26 +0000
+++ debian/landscape-client.postinst 2011-10-04 11:39:25 +0000
@@ -28,25 +28,30 @@
2828
29 CONFIG_FILE=/etc/landscape/client.conf29 CONFIG_FILE=/etc/landscape/client.conf
30 if [ ! -f $CONFIG_FILE ]; then30 if [ ! -f $CONFIG_FILE ]; then
31 # Get configuration values from debconf
32 db_get $PACKAGE/computer_title
33 COMPUTER_TITLE="${RET}"
34 db_get $PACKAGE/account_name
35 ACCOUNT_NAME="${RET}"
36 db_get $PACKAGE/registration_password
37 REGISTRATION_PASSWORD="${RET}"
38 db_get $PACKAGE/url
39 URL="${RET}"
40 db_get $PACKAGE/ping_url
41 PING_URL="${RET}"
42
31 # Create new configuration, with private mode43 # Create new configuration, with private mode
32 TEMPFILE=$(mktemp -p /etc/landscape)44 TEMPFILE=$(mktemp -p /etc/landscape)
33 cat > $TEMPFILE <<END45 cat > $TEMPFILE <<END
34[client]46[client]
35log_level = info47log_level = info
36url = https://landscape.canonical.com/message-system48url = ${URL}
37ping_url = http://landscape.canonical.com/ping49ping_url = ${PING_URL}
38data_path = /var/lib/landscape/client50data_path = /var/lib/landscape/client
39END51END
40 chown landscape $TEMPFILE52 chown landscape $TEMPFILE
41 mv $TEMPFILE $CONFIG_FILE53 mv $TEMPFILE $CONFIG_FILE
4254
43 db_get $PACKAGE/computer_title
44 COMPUTER_TITLE="${RET}"
45 db_get $PACKAGE/account_name
46 ACCOUNT_NAME="${RET}"
47 db_get $PACKAGE/registration_password
48 REGISTRATION_PASSWORD="${RET}"
49
50 # If we got the needed information, actually do the registration.55 # If we got the needed information, actually do the registration.
51 if [ -n "$ACCOUNT_NAME" -a -n "$COMPUTER_TITLE" ]; then56 if [ -n "$ACCOUNT_NAME" -a -n "$COMPUTER_TITLE" ]; then
52 landscape-config --silent --ok-no-register -a "$ACCOUNT_NAME" \57 landscape-config --silent --ok-no-register -a "$ACCOUNT_NAME" \
5358
=== modified file 'debian/landscape-client.templates'
--- debian/landscape-client.templates 2008-09-11 18:45:30 +0000
+++ debian/landscape-client.templates 2011-10-04 11:39:25 +0000
@@ -17,6 +17,18 @@
17 needed if the given account is requesting a client registration17 needed if the given account is requesting a client registration
18 password.18 password.
1919
20Template: landscape-client/url
21Type: string
22Default: https://landscape.ubuntu.com/message-system
23_Description: Landscape Server URL:
24 The server URL to connect to.
25
26Template: landscape-client/ping_url
27Type: string
28Default: http://landscape.ubuntu.com/ping
29_Description: Landscape PingServer URL:
30 The URL to perform lightweight exchange initiation with.
31
20Template: landscape-client/register_system32Template: landscape-client/register_system
21Type: boolean33Type: boolean
22Default: false34Default: false
2335
=== modified file 'debian/po/templates.pot'
--- debian/po/templates.pot 2008-10-03 20:15:21 +0000
+++ debian/po/templates.pot 2011-10-04 11:39:25 +0000
@@ -8,10 +8,11 @@
8msgstr ""8msgstr ""
9"Project-Id-Version: PACKAGE VERSION\n"9"Project-Id-Version: PACKAGE VERSION\n"
10"Report-Msgid-Bugs-To: landscape-client@packages.debian.org\n"10"Report-Msgid-Bugs-To: landscape-client@packages.debian.org\n"
11"POT-Creation-Date: 2008-10-03 15:08-0400\n"11"POT-Creation-Date: 2011-09-30 11:01-0300\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"14"Language-Team: LANGUAGE <LL@li.org>\n"
15"Language: \n"
15"MIME-Version: 1.0\n"16"MIME-Version: 1.0\n"
16"Content-Type: text/plain; charset=CHARSET\n"17"Content-Type: text/plain; charset=CHARSET\n"
17"Content-Transfer-Encoding: 8bit\n"18"Content-Transfer-Encoding: 8bit\n"
@@ -58,15 +59,39 @@
58"if the given account is requesting a client registration password."59"if the given account is requesting a client registration password."
59msgstr ""60msgstr ""
6061
62#. Type: string
63#. Description
64#: ../landscape-client.templates:4001
65msgid "Landscape Server URL:"
66msgstr ""
67
68#. Type: string
69#. Description
70#: ../landscape-client.templates:4001
71msgid "The server URL to connect to."
72msgstr ""
73
74#. Type: string
75#. Description
76#: ../landscape-client.templates:5001
77msgid "Landscape PingServer URL:"
78msgstr ""
79
80#. Type: string
81#. Description
82#: ../landscape-client.templates:5001
83msgid "The URL to perform lightweight exchange initiation with."
84msgstr ""
85
61#. Type: boolean86#. Type: boolean
62#. Description87#. Description
63#: ../landscape-client.templates:400188#: ../landscape-client.templates:6001
64msgid "Register this system with the Landscape server?"89msgid "Register this system with the Landscape server?"
65msgstr ""90msgstr ""
6691
67#. Type: boolean92#. Type: boolean
68#. Description93#. Description
69#: ../landscape-client.templates:400194#: ../landscape-client.templates:6001
70msgid ""95msgid ""
71"Register this system with a preexisting Landscape account. Please\n"96"Register this system with a preexisting Landscape account. Please\n"
72" go to http://landscape.canonical.com if you need a Landscape account."97" go to http://landscape.canonical.com if you need a Landscape account."

Subscribers

People subscribed via source and target branches

to all changes: