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
1=== modified file 'debian/landscape-client.config' (properties changed: -x to +x)
2--- debian/landscape-client.config 2008-09-11 18:39:18 +0000
3+++ debian/landscape-client.config 2011-10-04 11:39:25 +0000
4@@ -8,26 +8,29 @@
5
6 # This function also exists in the postinst, please keep them in sync
7 get_var_from_file() {
8- var="$1"
9- file="$2"
10- val=$(grep "^$var\s*=\s*" "$file" 2>/dev/null | tail -n1 | sed "s/^.*=\s*//")
11- echo "$val"
12+ var="$1"
13+ file="$2"
14+ val=$(grep "^$var\s*=\s*" "$file" 2>/dev/null | tail -n1 | sed "s/^.*=\s*//")
15+ echo "$val"
16 }
17
18 # Load config file, if it exists.
19 if [ -e $CONFIGFILE ]; then
20- # Config file is "ini" type, not shell, so we cannot source it
21- COMPUTER_TITLE=$(get_var_from_file "computer_title" "$CONFIGFILE")
22- ACCOUNT_NAME=$(get_var_from_file "account_name" "$CONFIGFILE")
23- REGISTRATION_PASSWORD=$(get_var_from_file "registration_password" "$CONFIGFILE")
24-
25- # Store values from config file into
26- # debconf db.
27-
28- db_set $PACKAGE/computer_title $COMPUTER_TITLE
29- db_set $PACKAGE/account_name $ACCOUNT_NAME
30- db_set $PACKAGE/registration_password $REGISTRATION_PASSWORD
31-
32+ # Config file is "ini" type, not shell, so we cannot source it
33+ COMPUTER_TITLE=$(get_var_from_file "computer_title" "$CONFIGFILE")
34+ ACCOUNT_NAME=$(get_var_from_file "account_name" "$CONFIGFILE")
35+ REGISTRATION_PASSWORD=$(get_var_from_file "registration_password" "$CONFIGFILE")
36+ URL=$(get_var_from_file "url" "$CONFIGFILE")
37+ PING_URL=$(get_var_from_file "ping_url" "$CONFIG_FILE")
38+
39+ # Store values from config file into
40+ # debconf db.
41+
42+ db_set $PACKAGE/computer_title $COMPUTER_TITLE
43+ db_set $PACKAGE/account_name $ACCOUNT_NAME
44+ db_set $PACKAGE/registration_password $REGISTRATION_PASSWORD
45+ db_set $PACKAGE/url $URL
46+ db_set $PACKAGE/ping_url $PING_URL
47 fi
48
49 # Ask questions.
50
51=== modified file 'debian/landscape-client.postinst'
52--- debian/landscape-client.postinst 2010-06-10 15:34:26 +0000
53+++ debian/landscape-client.postinst 2011-10-04 11:39:25 +0000
54@@ -28,25 +28,30 @@
55
56 CONFIG_FILE=/etc/landscape/client.conf
57 if [ ! -f $CONFIG_FILE ]; then
58+ # Get configuration values from debconf
59+ db_get $PACKAGE/computer_title
60+ COMPUTER_TITLE="${RET}"
61+ db_get $PACKAGE/account_name
62+ ACCOUNT_NAME="${RET}"
63+ db_get $PACKAGE/registration_password
64+ REGISTRATION_PASSWORD="${RET}"
65+ db_get $PACKAGE/url
66+ URL="${RET}"
67+ db_get $PACKAGE/ping_url
68+ PING_URL="${RET}"
69+
70 # Create new configuration, with private mode
71 TEMPFILE=$(mktemp -p /etc/landscape)
72 cat > $TEMPFILE <<END
73 [client]
74 log_level = info
75-url = https://landscape.canonical.com/message-system
76-ping_url = http://landscape.canonical.com/ping
77+url = ${URL}
78+ping_url = ${PING_URL}
79 data_path = /var/lib/landscape/client
80 END
81 chown landscape $TEMPFILE
82 mv $TEMPFILE $CONFIG_FILE
83
84- db_get $PACKAGE/computer_title
85- COMPUTER_TITLE="${RET}"
86- db_get $PACKAGE/account_name
87- ACCOUNT_NAME="${RET}"
88- db_get $PACKAGE/registration_password
89- REGISTRATION_PASSWORD="${RET}"
90-
91 # If we got the needed information, actually do the registration.
92 if [ -n "$ACCOUNT_NAME" -a -n "$COMPUTER_TITLE" ]; then
93 landscape-config --silent --ok-no-register -a "$ACCOUNT_NAME" \
94
95=== modified file 'debian/landscape-client.templates'
96--- debian/landscape-client.templates 2008-09-11 18:45:30 +0000
97+++ debian/landscape-client.templates 2011-10-04 11:39:25 +0000
98@@ -17,6 +17,18 @@
99 needed if the given account is requesting a client registration
100 password.
101
102+Template: landscape-client/url
103+Type: string
104+Default: https://landscape.ubuntu.com/message-system
105+_Description: Landscape Server URL:
106+ The server URL to connect to.
107+
108+Template: landscape-client/ping_url
109+Type: string
110+Default: http://landscape.ubuntu.com/ping
111+_Description: Landscape PingServer URL:
112+ The URL to perform lightweight exchange initiation with.
113+
114 Template: landscape-client/register_system
115 Type: boolean
116 Default: false
117
118=== modified file 'debian/po/templates.pot'
119--- debian/po/templates.pot 2008-10-03 20:15:21 +0000
120+++ debian/po/templates.pot 2011-10-04 11:39:25 +0000
121@@ -8,10 +8,11 @@
122 msgstr ""
123 "Project-Id-Version: PACKAGE VERSION\n"
124 "Report-Msgid-Bugs-To: landscape-client@packages.debian.org\n"
125-"POT-Creation-Date: 2008-10-03 15:08-0400\n"
126+"POT-Creation-Date: 2011-09-30 11:01-0300\n"
127 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
128 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
129 "Language-Team: LANGUAGE <LL@li.org>\n"
130+"Language: \n"
131 "MIME-Version: 1.0\n"
132 "Content-Type: text/plain; charset=CHARSET\n"
133 "Content-Transfer-Encoding: 8bit\n"
134@@ -58,15 +59,39 @@
135 "if the given account is requesting a client registration password."
136 msgstr ""
137
138+#. Type: string
139+#. Description
140+#: ../landscape-client.templates:4001
141+msgid "Landscape Server URL:"
142+msgstr ""
143+
144+#. Type: string
145+#. Description
146+#: ../landscape-client.templates:4001
147+msgid "The server URL to connect to."
148+msgstr ""
149+
150+#. Type: string
151+#. Description
152+#: ../landscape-client.templates:5001
153+msgid "Landscape PingServer URL:"
154+msgstr ""
155+
156+#. Type: string
157+#. Description
158+#: ../landscape-client.templates:5001
159+msgid "The URL to perform lightweight exchange initiation with."
160+msgstr ""
161+
162 #. Type: boolean
163 #. Description
164-#: ../landscape-client.templates:4001
165+#: ../landscape-client.templates:6001
166 msgid "Register this system with the Landscape server?"
167 msgstr ""
168
169 #. Type: boolean
170 #. Description
171-#: ../landscape-client.templates:4001
172+#: ../landscape-client.templates:6001
173 msgid ""
174 "Register this system with a preexisting Landscape account. Please\n"
175 " go to http://landscape.canonical.com if you need a Landscape account."

Subscribers

People subscribed via source and target branches

to all changes: