483dfbbfc8e65ca05d970c943e0dd89d037e9c82
[lhc/ateliers.git] / etc / sv / openerp7_burette / local.sh
1 home=/home/"$sv"
2 version=7.0
3
4 "$tool"/local/apt-get-install openerp --force-yes --no-upgrade
5 # XXX: --force-yes car les paquets de nightly.openerp.com
6 # ne sont pas sign├ęs par OpenPGP..
7 "$tool"/local/insserv-remove openerp
8
9 "$tool"/local/adduser "$sv" \
10 --disabled-login \
11 --disabled-password \
12 --group \
13 --home "$home" \
14 --shell /bin/false \
15 --system
16 "$tool"/local/adduser "$sv"-addon \
17 --disabled-login \
18 --disabled-password \
19 --group \
20 --home "$home"/addon.d \
21 --shell /bin/sh \
22 --system
23
24 sudo install -d -m 1777 -o root -g root \
25 /etc/openerp \
26 /etc/openerp/$version
27 sudo install -d -m 3771 -o "$sv" -g "$sv" \
28 "$home" \
29 "$home"/etc
30 sudo install -d -m 2750 -o "$sv"-addon -g "$sv"-addon \
31 "$home"/addon.d \
32 "$home"/addon.d/etc
33 sudo ln -fns \
34 /etc/openerp/$version \
35 "$home"/etc/openerp
36 sudo ln -s \
37 "$home"/var/filestore/ /usr/lib/pymodules/python2.7/openerp/filestore
38
39 while ! sudo -u postgres psql </dev/null
40 do sleep 1; done
41 "$tool"/local/postgresql-user-create "$sv"
42 for db in \
43 atelieretincelle \
44 autourducycle \
45 bretzselle \
46 changedechaine \
47 choisir \
48 convibicy \
49 cyclamaine \
50 cyclesetmanivelles \
51 cyclo_ivry \
52 cyclo_pantin \
53 cyclo_paris_est \
54 cyclofficine_angouleme \
55 dynamo \
56 etudesetchantiersidf \
57 etudesetchantiersidf_test \
58 eturecup \
59 heureuxcyclage \
60 labecaneajules \
61 lapetiterennes \
62 laptiterustine \
63 larouelibre \
64 lechatperche \
65 lesjantesdunord \
66 letriseratop \
67 mobilidees \
68 ocivelo \
69 ohcyclo \
70 placeauvelo \
71 ptitvelo \
72 recupr \
73 repeyre \
74 rouepet \
75 tousdeuxroues \
76 txirrindola \
77 velocampus_nantes \
78 velorution_idf \
79 velorution_toulouse \
80 velosenville \
81 vieuxbiclou
82 do
83 #"$tool"/local/postgresql-role-create "${sv}_$db"
84 "$tool"/local/postgresql-database-create "${sv}_$db" "$sv"
85 sudo -u postgres psql -AqtX "${sv}_$db" <<-EOF
86 \set ON_ERROR_STOP on
87 GRANT USAGE ON SCHEMA pg_catalog TO $sv;
88 GRANT SELECT ON TABLE pg_catalog.pg_attribute TO $sv;
89 GRANT SELECT ON TABLE pg_catalog.pg_class TO $sv;
90 GRANT SELECT ON TABLE pg_catalog.pg_constraint TO $sv;
91 GRANT SELECT ON TABLE pg_catalog.pg_indexes TO $sv;
92 GRANT SELECT ON TABLE pg_catalog.pg_proc TO $sv;
93 GRANT SELECT ON TABLE pg_catalog.pg_type TO $sv;
94 EOF
95 done
96
97 sudo adduser git "$sv"-addon
98 sudo adduser "$sv" "$sv"-addon
99 sudo adduser "$sv" postgres-data
100
101 for addon in \
102 account_analytic_improvement \
103 account_export_csv \
104 account_financial_report_webkit \
105 account_move_line_nofilters \
106 account_move_line_no_default_search \
107 analytic_point_of_sale \
108 atelieretincelle \
109 bikecoop \
110 bikecoop_l10n_fr \
111 bikecoop_translations \
112 bretzselle \
113 changedechaine \
114 choisir \
115 cyclamaine \
116 cyclesetmanivelles \
117 cyclofficine_angouleme \
118 cyclofficine_ivry \
119 cyclofficine_paris_est \
120 cyclofficine_pantin \
121 dynamo \
122 etudesetchantiersidf \
123 eturecup \
124 lapetiterennes \
125 laptiterustine \
126 larouelibre \
127 lechatperche \
128 lesjantesdunord \
129 letriseratop \
130 lhc \
131 mobilidees \
132 nrt_point_of_sale \
133 no_db_management \
134 ohcyclo \
135 pos_membership \
136 ptitvelo \
137 recupr \
138 repeyre \
139 tousdeuxroues \
140 txirrindola \
141 remembership \
142 velocampus_nantes \
143 velorution_idf \
144 velosenville
145 #vieuxbiclou_mpt
146 do
147 sudo install -d -m 2771 -o "$sv" -g "$sv"-addon \
148 "$home"/addon.d/"$addon"
149 sudo -u git git \
150 --git-dir ~git-data/burette/"$addon".git \
151 --work-tree="$home"/addon.d/"$addon" \
152 checkout -f 7.0
153 sudo -u git git \
154 --git-dir ~git-data/burette/"$addon".git \
155 --work-tree="$home"/addon.d/"$addon" \
156 clean -d -e sec/ -f -f -x
157 sudo chmod a-x \
158 /home/git/data/burette/"$addon".git/hooks/post-update.sample
159 sudo install -m 550 -o git -g git /dev/stdin \
160 /home/git/data/burette/"$addon".git/hooks/post-update <<-EOF
161 #!/bin/sh -efux
162 find . -type f -perm /+x -name 'post-update.*' |
163 while IFS= read -r hook
164 do "\$hook" "\$@"
165 done
166 EOF
167 sudo install -m 550 -o git -g git /dev/stdin \
168 /home/git/data/burette/"$addon".git/hooks/post-update."$sv" <<-EOF
169 #!/bin/sh -efux
170 case \$1 in
171 (refs/heads/7.0)
172 git \\
173 --git-dir ~git-data/burette/"$addon".git \\
174 --work-tree="$home"/addon.d/"$addon" \\
175 checkout -f 7.0
176 git \\
177 --git-dir ~git-data/burette/"$addon".git \\
178 --work-tree="$home"/addon.d/"$addon" \\
179 clean -d -e sec/ -f -f -x
180 #sv restart "$sv"
181 ;;
182 esac
183 EOF
184 done