Skip to content

Commit 6da7b31

Browse files
authored
Merge pull request #449 from Lex-2008/ENT-4079-DC-VSC-migration
ENT-4079 DC-to-VSC migration
2 parents d07a142 + 7061cda commit 6da7b31

File tree

1 file changed

+44
-15
lines changed

1 file changed

+44
-15
lines changed

packaging/common/cfengine-hub/postinstall.sh

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ mv $PREFIX/httpd/htdocs/Apache-htaccess $PREFIX/httpd/htdocs/.htaccess
9797
chmod 755 $PREFIX/httpd
9898
chown -R $MP_APACHE_USER:$MP_APACHE_USER $PREFIX/httpd/htdocs
9999
chmod a+rx $PREFIX/httpd/htdocs/api/dc-scripts/*.sh
100-
chmod a+rx $PREFIX/httpd/htdocs/api/dc-scripts/*.pl
101100

102101
# plugins directory, empty by default
103102
mkdir -p ${PREFIX}/plugins
@@ -121,10 +120,10 @@ chown $MP_APACHE_USER:$MP_APACHE_USER $PREFIX/httpd/logs/application
121120
#
122121
# Do all the prelimenary Design Center setup only on the first install of cfengine package
123122
#
123+
DCWORKDIR=/opt/cfengine
124+
DCPARAMS=$DCWORKDIR/dc-scripts/params.sh
124125
if ! is_upgrade; then
125126
# This folder is required for Design Center and Mission Portal to talk to each other
126-
DCWORKDIR=/opt/cfengine
127-
$PREFIX/design-center/bin/cf-sketch --inputs=$PREFIX/design-center --installsource=$PREFIX/share/NovaBase/sketches/cfsketches.json --install-all
128127
mkdir -p $DCWORKDIR/userworkdir/admin/.ssh
129128
mkdir -p $DCWORKDIR/stage_backup
130129
mkdir -p $DCWORKDIR/dc-scripts
@@ -134,20 +133,23 @@ if ! is_upgrade; then
134133
touch $DCWORKDIR/userworkdir/admin/.ssh/id_rsa.pvt
135134
chmod 600 $DCWORKDIR/userworkdir/admin/.ssh/id_rsa.pvt
136135

137-
cat > $DCWORKDIR/dc-scripts/params.sh <<EOHIPPUS
138-
#!/bin/bash
136+
cat > $DCPARAMS <<EOHIPPUS
139137
ROOT="$DCWORKDIR/masterfiles_staging"
140138
GIT_URL="$DCWORKDIR/masterfiles.git"
141-
GIT_BRANCH="master"
139+
GIT_REFSPEC="master"
140+
GIT_USERNAME=""
141+
GIT_PASSWORD=""
142142
GIT_WORKING_BRANCH="CF_WORKING_BRANCH"
143-
GIT_EMAIL="default-committer@your-cfe-site.com"
144-
GIT_AUTHOR="Default Committer"
145143
PKEY="$DCWORKDIR/userworkdir/admin/.ssh/id_rsa.pvt"
146144
SCRIPT_DIR="$PREFIX/httpd/htdocs/api/dc-scripts"
147145
VCS_TYPE="GIT"
146+
148147
export PATH="\${PATH}:$PREFIX/bin"
149-
export PKEY="\${PKEY}"
148+
export PKEY
149+
export GIT_USERNAME
150+
export GIT_PASSWORD
150151
export GIT_SSH="\${SCRIPT_DIR}/ssh-wrapper.sh"
152+
export GIT_ASKPASS="\${SCRIPT_DIR}/git-askpass.sh"
151153
EOHIPPUS
152154

153155
# The runfile key in the below JSON is not needed anymore, all the
@@ -166,8 +168,6 @@ EOHIPPUS
166168
}
167169
EOHIPPUS
168170

169-
chmod 700 $DCWORKDIR/dc-scripts/params.sh
170-
171171
chown -R $MP_APACHE_USER:$MP_APACHE_USER $DCWORKDIR/userworkdir
172172
chown -R $MP_APACHE_USER:$MP_APACHE_USER $DCWORKDIR/dc-scripts
173173
chown -R $MP_APACHE_USER:$MP_APACHE_USER $DCWORKDIR/stage_backup
@@ -201,6 +201,35 @@ EOHIPPUS
201201
if [ ! -f /usr/bin/curl ]; then
202202
ln -sf $PREFIX/bin/curl /usr/bin/curl
203203
fi
204+
else
205+
# Migrate DC params.sh
206+
# change GIT_BRANCH to GIT_REFSPEC, if it exists
207+
# or add it after first line
208+
if ! grep 'GIT_REFSPEC=' $DCPARAMS >/dev/null; then
209+
if grep 'GIT_BRANCH=' $DCPARAMS >/dev/null; then
210+
sed -i 's/GIT_BRANCH=/GIT_REFSPEC=/' $DCPARAMS
211+
else
212+
sed -i '1a GIT_REFSPEC="master"' $DCPARAMS
213+
fi
214+
fi
215+
# Add git username and password, if they're missing
216+
if ! grep 'GIT_USERNAME=' $DCPARAMS >/dev/null; then
217+
sed -i '1a GIT_USERNAME=""' $DCPARAMS
218+
fi
219+
if ! grep 'GIT_PASSWORD=' $DCPARAMS >/dev/null; then
220+
sed -i '1a GIT_PASSWORD=""' $DCPARAMS
221+
fi
222+
# Add export lines at the end, if they're missing
223+
if ! grep 'export GIT_USERNAME' $DCPARAMS >/dev/null; then
224+
echo 'export GIT_USERNAME' >>$DCPARAMS
225+
fi
226+
if ! grep 'export GIT_PASSWORD' $DCPARAMS >/dev/null; then
227+
echo 'export GIT_PASSWORD' >>$DCPARAMS
228+
fi
229+
if ! grep 'export GIT_ASKPASS' $DCPARAMS >/dev/null; then
230+
echo 'export GIT_ASKPASS="${SCRIPT_DIR}/git-askpass.sh"' >>$DCPARAMS
231+
fi
232+
204233
fi
205234

206235
if [ -f $PREFIX/bin/cf-twin ]; then
@@ -731,12 +760,12 @@ find $PREFIX/httpd/htdocs/application/ -type f -exec chown -R root:$MP_APACHE_US
731760
find $PREFIX/httpd/htdocs/application/ -type f -exec chmod 0440 {} +
732761

733762
# API non-executable
734-
find $PREFIX/httpd/htdocs/api/ -type f ! -name '*.sh' -o ! -name '*.pl' -exec chown -R root:$MP_APACHE_USER {} +
735-
find $PREFIX/httpd/htdocs/api/ -type f ! -name '*.sh' -o ! -name '*.pl' -exec chmod 0440 {} +
763+
find $PREFIX/httpd/htdocs/api/ -type f ! -name '*.sh' -exec chown -R root:$MP_APACHE_USER {} +
764+
find $PREFIX/httpd/htdocs/api/ -type f ! -name '*.sh' -exec chmod 0440 {} +
736765

737766
# API executable
738-
find $PREFIX/httpd/htdocs/api/ -type f -name '*.sh' -o -name '*.pl' -exec chown -R root:$MP_APACHE_USER {} +
739-
find $PREFIX/httpd/htdocs/api/ -type f -name '*.sh' -o -name '*.pl' -exec chmod 0550 {} +
767+
find $PREFIX/httpd/htdocs/api/ -type f -name '*.sh' -exec chown -R root:$MP_APACHE_USER {} +
768+
find $PREFIX/httpd/htdocs/api/ -type f -name '*.sh' -exec chmod 0550 {} +
740769

741770
# API static non htaccess
742771
find $PREFIX/httpd/htdocs/api/static -type f ! -name '.htaccess' -exec chown -R root:$MP_APACHE_USER {} +

0 commit comments

Comments
 (0)