Merge lp:~andreserl/maas/packaging_simplify_postinst into lp:~maas-maintainers/maas/packaging

Proposed by Andres Rodriguez
Status: Merged
Approved by: Andres Rodriguez
Approved revision: 345
Merged at revision: 344
Proposed branch: lp:~andreserl/maas/packaging_simplify_postinst
Merge into: lp:~maas-maintainers/maas/packaging
Diff against target: 219 lines (+39/-96)
3 files modified
debian/changelog (+2/-1)
debian/maas-region-controller-min.postinst (+37/-24)
debian/maas-region-controller.postinst (+0/-71)
To merge this branch: bzr merge lp:~andreserl/maas/packaging_simplify_postinst
Reviewer Review Type Date Requested Status
Raphaël Badin (community) Approve
Review via email: mp+247044@code.launchpad.net

Commit message

Simplify postinst to not do the same configuration in the same places.

To post a comment you must log in.
345. By Andres Rodriguez

debian/maas-region-controller{-min}.postinst: Simplify postinsts.

Revision history for this message
Raphaël Badin (rvb) wrote :

Looks good… seems you've cleaned up a fair amount of duplication…

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2015-01-17 18:44:56 +0000
3+++ debian/changelog 2015-01-20 17:05:18 +0000
4@@ -1,4 +1,4 @@
5-maas (1.8.0~alpha1+bzr3463-0ubuntu1) UNRELEASED; urgency=medium
6+maas (1.8.0~alpha1+bzr3480-0ubuntu1) UNRELEASED; urgency=medium
7
8 [ Blake Rouse ]
9 * debian/control: added python-pyscss as a build dependency.
10@@ -16,6 +16,7 @@
11 * debian/control: Tighten Dependency versioning of some packages.
12 * debian/maas-region-controller-min.preinst: Handle upgrades to remove
13 legacy files.
14+ * debian/maas-region-controller{-min}.postinst: Simplify postinsts.
15
16 [ Gavin Panella ]
17 * debian/maas-region-controller-min.maas-regiond.upstart
18
19=== modified file 'debian/maas-region-controller-min.postinst'
20--- debian/maas-region-controller-min.postinst 2015-01-17 18:44:56 +0000
21+++ debian/maas-region-controller-min.postinst 2015-01-20 17:05:18 +0000
22@@ -30,6 +30,37 @@
23 a2enmod rewrite
24 }
25
26+configure_logging() {
27+ # Give appropriate permissions
28+ if [ ! -f /var/log/maas/regiond.log ]; then
29+ touch /var/log/maas/regiond.log
30+ fi
31+ chown -R maas:maas /var/log/maas
32+ chmod -R 775 /var/log/maas/oops
33+
34+ # Main syslog file.
35+ if [ ! -f /var/log/maas/maas.log ]; then
36+ touch /var/log/maas/maas.log
37+ fi
38+ chown syslog:syslog /var/log/maas/maas.log
39+
40+ # Create log directory base
41+ mkdir -p /var/log/maas/rsyslog
42+ chown -R syslog:syslog /var/log/maas/rsyslog
43+ # Make sure rsyslog reads our config
44+ invoke-rc.d rsyslog restart
45+
46+ # If proxy log dir exists, set correct permissions
47+ if [ -d /var/log/maas/proxy ]; then
48+ chown -R proxy:proxy /var/log/maas/proxy
49+ fi
50+}
51+
52+
53+configure_third_party_log_symlinks() {
54+ ln -sf /var/log/apache2 /var/log/maas/
55+}
56+
57 configure_maas_default_url() {
58 local ipaddr="$1"
59
60@@ -86,30 +117,8 @@
61 #########################################################
62 ################ Configure Logging ####################
63 #########################################################
64-
65- # Give appropriate permissions
66- if [ ! -f /var/log/maas/regiond.log ]; then
67- touch /var/log/maas/regiond.log
68- fi
69- chown -R maas:maas /var/log/maas
70- chmod -R 775 /var/log/maas/oops
71-
72- # Main syslog file.
73- if [ ! -f /var/log/maas/maas.log ]; then
74- touch /var/log/maas/maas.log
75- fi
76- chown syslog:syslog /var/log/maas/maas.log
77-
78- # Create log directory base
79- mkdir -p /var/log/maas/rsyslog
80- chown -R syslog:syslog /var/log/maas/rsyslog
81- # Make sure rsyslog reads our config
82- invoke-rc.d rsyslog restart
83-
84- # If proxy log dir exists, set correct permissions
85- if [ -d /var/log/maas/proxy ]; then
86- chown -R proxy:proxy /var/log/maas/proxy
87- fi
88+ configure_logging
89+ configure_third_party_log_symlinks
90
91 elif [ -n "$DEBCONF_RECONFIGURE" ]; then
92 # Set the IP address of the interface with default route
93@@ -120,6 +129,10 @@
94 fi
95
96 elif [ "$1" = "configure" ] && dpkg --compare-versions "$2" gt 0.1+bzr266+dfsg-0ubuntu1; then
97+ # Logging changed at r2611, ensure it is set up.
98+ configure_logging
99+ configure_third_party_log_symlinks
100+
101 # If upgrading to any later package version, then upgrade db.
102 invoke-rc.d apache2 stop || true
103
104
105=== modified file 'debian/maas-region-controller.postinst'
106--- debian/maas-region-controller.postinst 2015-01-17 18:44:56 +0000
107+++ debian/maas-region-controller.postinst 2015-01-20 17:05:18 +0000
108@@ -21,29 +21,6 @@
109 invoke-rc.d --force postgresql restart || true
110 }
111
112-configure_region_http() {
113- case $RELEASE in
114- 12.04|12.10|13.04)
115- # handle apache configs
116- if [ -e /etc/maas/maas-http.conf -a \
117- ! -e /etc/apache2/conf.d/maas-http.conf ]; then
118- ln -sf /etc/maas/maas-http.conf /etc/apache2/conf.d/maas-http.conf
119- fi
120- ;;
121- *)
122- # handle apache configs
123- if [ -e /etc/maas/maas-http.conf -a \
124- ! -e /etc/apache2/conf-enabled/maas-http.conf ]; then
125- ln -sf /etc/maas/maas-http.conf /etc/apache2/conf-enabled/maas-http.conf
126- fi
127- ;;
128- esac
129- # enable apache modules needed
130- a2enmod proxy_http
131- a2enmod expires
132- a2enmod rewrite
133-}
134-
135 configure_maas_database() {
136 local dbc_dbpass="$1"
137 if grep -qs "^\ \{1,\} 'PASSWORD': '[a-zA-Z0-9]\{0,\}',$" /etc/maas/maas_local_settings.py; then
138@@ -72,35 +49,6 @@
139 echo $ipaddr
140 }
141
142-configure_logging() {
143- # Give appropriate permissions
144- if [ ! -f /var/log/maas/regiond.log ]; then
145- touch /var/log/maas/regiond.log
146- fi
147- chown -R maas:maas /var/log/maas
148- chmod -R 775 /var/log/maas/oops
149-
150- # Main syslog file.
151- if [ ! -f /var/log/maas/maas.log ]; then
152- touch /var/log/maas/maas.log
153- fi
154- chown syslog:syslog /var/log/maas/maas.log
155-
156- # Create log directory base
157- mkdir -p /var/log/maas/rsyslog
158- chown -R syslog:syslog /var/log/maas/rsyslog
159- # Make sure rsyslog reads our config
160- invoke-rc.d rsyslog restart
161-
162- # If proxy log dir exists, set correct permissions
163- if [ -d /var/log/maas/proxy ]; then
164- chown -R proxy:proxy /var/log/maas/proxy
165- fi
166-}
167-
168-configure_third_party_log_symlinks() {
169- ln -sf /var/log/apache2 /var/log/maas/
170-}
171
172 if [ "$1" = "configure" ] && [ -z "$2" ]; then
173 #########################################################
174@@ -115,11 +63,6 @@
175 chmod 0640 /etc/maas/maas_local_settings.py
176
177 #########################################################
178- ################ Configure Apache2 ####################
179- #########################################################
180- configure_region_http
181-
182- #########################################################
183 ########## Configure DEFAULT_MAAS_URL #################
184 #########################################################
185
186@@ -138,13 +81,6 @@
187 fi
188
189 #########################################################
190- ################ Configure Logging ####################
191- #########################################################
192-
193- configure_logging
194- configure_third_party_log_symlinks
195-
196- #########################################################
197 ################ Configure Database ###################
198 #########################################################
199
200@@ -174,19 +110,12 @@
201 fi
202
203 elif [ "$1" = "configure" ] && dpkg --compare-versions "$2" gt 0.1+bzr266+dfsg-0ubuntu1; then
204- # Logging changed at r2611, ensure it is set up.
205- configure_logging
206- configure_third_party_log_symlinks
207-
208 # If upgrading to any later package version, then upgrade db.
209 invoke-rc.d apache2 stop || true
210
211 # make sure postgresql is running
212 restart_postgresql
213
214- # make sure maas http config is symlinked
215- configure_region_http
216-
217 # we need to regenerate the passwords and update configs.
218 db_get maas/default-maas-url
219 ipaddr="$RET"

Subscribers

People subscribed via source and target branches

to all changes: