@@ -187,15 +187,14 @@ EOHIPPUS
187
187
(cd $DCWORKDIR /masterfiles_staging && su $MP_APACHE_USER -c " (echo '/cf_promises_*'; echo '.*.sw[po]'; echo '*~'; echo '\\ #*#') >.gitignore" )
188
188
(cd $DCWORKDIR /masterfiles_staging && su $MP_APACHE_USER -c " $GIT add .gitignore" )
189
189
(cd $DCWORKDIR /masterfiles_staging && su $MP_APACHE_USER -c " $GIT commit -m 'Ignore cf_promise_*'" )
190
- (cd $DCWORKDIR /masterfiles_staging && su $MP_APACHE_USER -c " $GIT add *" )
190
+ (cd $DCWORKDIR /masterfiles_staging && su $MP_APACHE_USER -c " $GIT add *" ) || true " Ignoring warning about ignored files not being added "
191
191
(cd $DCWORKDIR /masterfiles_staging && su $MP_APACHE_USER -c " $GIT commit -m 'Initial pristine masterfiles'" )
192
192
193
193
(cd $DCWORKDIR / && su $MP_APACHE_USER -c " $GIT clone --no-hardlinks --bare $DCWORKDIR /masterfiles_staging $DCWORKDIR /masterfiles.git" )
194
194
find " $DCWORKDIR /masterfiles.git" -type d -exec chmod 700 {} \;
195
195
find " $DCWORKDIR /masterfiles.git" -type f -exec chmod 600 {} \;
196
196
197
197
(cd $DCWORKDIR /masterfiles_staging && su $MP_APACHE_USER -c " $GIT branch CF_WORKING_BRANCH" )
198
- (cd $DCWORKDIR /masterfiles_staging && su $MP_APACHE_USER -c " $GIT remote rm origin" )
199
198
(cd $DCWORKDIR /masterfiles_staging && su $MP_APACHE_USER -c " $GIT remote add origin $DCWORKDIR /masterfiles.git" )
200
199
201
200
if [ ! -f /usr/bin/curl ]; then
265
264
266
265
if [ -f " $MAN_CONFIG " ];
267
266
then
268
- MAN=` cat " $MAN_CONFIG " | grep cfengine`
269
- if [ -z " $MAN " ]; then
267
+ if grep cfengine " $MAN_CONFIG " > /dev/null; then
270
268
echo " $MAN_PATH $PREFIX /share/man" >> " $MAN_CONFIG "
271
269
fi
272
270
fi
@@ -341,8 +339,7 @@ generate_new_postgres_conf() {
341
339
# Otherwise, we use a shared_buffers equal to 25% of total memory
342
340
total=` cat /proc/meminfo | grep " ^MemTotal:.*[0-9]\+ kB" | awk ' {print $2}' `
343
341
344
- echo " $total " | grep -q ' ^[0-9]\+$'
345
- if [ $? -ne 0 ] ; then
342
+ if ! echo " $total " | grep -q ' ^[0-9]\+$' > /dev/null; then
346
343
cf_console echo " Error calculating total memory for setting postgresql shared_buffers" ;
347
344
else
348
345
upper=$(( 64 * 1024 * 1024 )) # in KB
@@ -573,6 +570,7 @@ migrate_db_using_dump_file() {
573
570
}
574
571
575
572
if is_upgrade && [ -d " $BACKUP_DIR /data" ]; then
573
+ set +e # this block has its own error detection/handling
576
574
# DEBUG variable controls which of migration methods fail:
577
575
# 0 - do nothing special (usually pg_upgrade, which is first method, succeeds)
578
576
# 1 - fail first method (so we get a chance to run second method, migration via pipe)
@@ -657,6 +655,7 @@ if is_upgrade && [ -d "$BACKUP_DIR/data" ]; then
657
655
cf_console echo " And now installation will proceed with clean (empty) database"
658
656
(cd /tmp && su cfpostgres -c " $PREFIX /bin/initdb -D $PREFIX /state/pg/data" )
659
657
fi
658
+ set -e
660
659
fi
661
660
662
661
(cd /tmp && su cfpostgres -c " $PREFIX /bin/pg_ctl -w -D $PREFIX /state/pg/data -l /var/log/postgresql.log start" )
@@ -688,18 +687,23 @@ then
688
687
cf_console echo " Database migration also failed for the above reason. Backups are in $PREFIX /state/pg/*.sql.gz"
689
688
fi
690
689
else
691
- (cd /tmp && su cfpostgres -c " $PREFIX /bin/createdb -E SQL_ASCII --lc-collate=C --lc-ctype=C -T template0 cfdb" )
692
- (cd /tmp && su cfpostgres -c " $PREFIX /bin/createuser -S -D -R -w $MP_APACHE_USER " )
693
- (cd /tmp && su cfpostgres -c " $PREFIX /bin/createuser -d -a -w root" )
694
- (cd /tmp && su cfpostgres -c " $PREFIX /bin/createdb -E SQL_ASCII --lc-collate=C --lc-ctype=C -T template0 cfmp" )
695
- (cd /tmp && su cfpostgres -c " $PREFIX /bin/createdb -E SQL_ASCII --lc-collate=C --lc-ctype=C -T template0 cfsettings" )
690
+ (
691
+ cd /tmp
692
+ set +e
693
+ su cfpostgres -c " $PREFIX /bin/createdb -E SQL_ASCII --lc-collate=C --lc-ctype=C -T template0 cfdb"
694
+ su cfpostgres -c " $PREFIX /bin/createuser -S -D -R -w $MP_APACHE_USER "
695
+ su cfpostgres -c " $PREFIX /bin/createuser -d -a -w root"
696
+ su cfpostgres -c " $PREFIX /bin/createdb -E SQL_ASCII --lc-collate=C --lc-ctype=C -T template0 cfmp"
697
+ su cfpostgres -c " $PREFIX /bin/createdb -E SQL_ASCII --lc-collate=C --lc-ctype=C -T template0 cfsettings"
698
+ exit 0
699
+ )
696
700
697
701
# Create the cfengine mission portal postgres user
698
702
(cd /tmp && su cfpostgres -c " $PREFIX /bin/psql cfmp" < $PREFIX /share/GUI/phpcfenginenova/create_cfmppostgres_user.sql)
699
703
700
704
# Ensure cfpostgres can read the sql files it will import. And that they are
701
705
# restored to restrictive state after import ENT-2684
702
- ( chown cfpostgres " $PREFIX /share/db/*.sql" )
706
+ chown cfpostgres $PREFIX /share/db/* .sql
703
707
(cd /tmp && chown cfpostgres " $PREFIX /share/db/schema.sql" && su cfpostgres -c " $PREFIX /bin/psql cfdb -f $PREFIX /share/db/schema.sql" && chown root " $PREFIX /share/db/schema.sql" )
704
708
705
709
# create database for MISSION PORTAL
@@ -708,9 +712,12 @@ else
708
712
709
713
710
714
# create database for hub internal data
711
- (cd /tmp && chown cfpostgres " $PREFIX /share/db/schema_settings.sql" && su cfpostgres -c " $PREFIX /bin/psql cfsettings -f $PREFIX /share/db/schema_settings.sql" && chown root " $PREFIX /share/db/schema_settings.sql" )
712
- (cd /tmp && chown cfpostgres " $PREFIX /share/db/ootb_settings.sql" && su cfpostgres -c " $PREFIX /bin/psql cfsettings -f $PREFIX /share/db/ootb_settings.sql" && chown root " $PREFIX /share/db/ootb_settings.sql" )
713
- (cd /tmp && chown cfpostgres " $PREFIX /share/db/ootb_import.sql" && su cfpostgres -c " $PREFIX /bin/psql cfdb -f $PREFIX /share/db/ootb_import.sql" && chown root " $PREFIX /share/db/ootb_import.sql" )
715
+ (
716
+ cd /tmp
717
+ chown cfpostgres " $PREFIX /share/db/schema_settings.sql" && su cfpostgres -c " $PREFIX /bin/psql cfsettings -f $PREFIX /share/db/schema_settings.sql" && chown root " $PREFIX /share/db/schema_settings.sql"
718
+ chown cfpostgres " $PREFIX /share/db/ootb_settings.sql" && su cfpostgres -c " $PREFIX /bin/psql cfsettings -f $PREFIX /share/db/ootb_settings.sql" && chown root " $PREFIX /share/db/ootb_settings.sql"
719
+ chown cfpostgres " $PREFIX /share/db/ootb_import.sql" && su cfpostgres -c " $PREFIX /bin/psql cfdb -f $PREFIX /share/db/ootb_import.sql" && chown root " $PREFIX /share/db/ootb_import.sql"
720
+ )
714
721
715
722
# revoke create permission on public schema for cfdb database
716
723
(cd /tmp && su cfpostgres -c " $PREFIX /bin/psql cfdb" ) << EOF
@@ -763,9 +770,11 @@ find $PREFIX/httpd/htdocs/scripts/ -type f -exec chmod 0440 {} +
763
770
find $PREFIX /httpd/htdocs/tmp/ -type f -exec chown -R root:$MP_APACHE_USER {} +
764
771
find $PREFIX /httpd/htdocs/tmp/ -type f -exec chmod 0660 {} +
765
772
766
- # logs
767
- find $PREFIX /httpd/htdocs/logs/ -type f -exec chown -R $MP_APACHE_USER :$MP_APACHE_USER {} +
768
- find $PREFIX /httpd/htdocs/logs/ -type f -exec chmod 0640 {} +
773
+ # logs (if any)
774
+ if [ -d $PREFIX /httpd/htdocs/logs/ ]; then
775
+ find $PREFIX /httpd/htdocs/logs/ -type f -exec chown -R $MP_APACHE_USER :$MP_APACHE_USER {} +
776
+ find $PREFIX /httpd/htdocs/logs/ -type f -exec chmod 0640 {} +
777
+ fi
769
778
770
779
# application
771
780
find $PREFIX /httpd/htdocs/application/ -type f -exec chown -R root:$MP_APACHE_USER {} +
0 commit comments