@@ -187,15 +187,14 @@ EOHIPPUS
187187 (cd $DCWORKDIR /masterfiles_staging && su $MP_APACHE_USER -c " (echo '/cf_promises_*'; echo '.*.sw[po]'; echo '*~'; echo '\\ #*#') >.gitignore" )
188188 (cd $DCWORKDIR /masterfiles_staging && su $MP_APACHE_USER -c " $GIT add .gitignore" )
189189 (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 "
191191 (cd $DCWORKDIR /masterfiles_staging && su $MP_APACHE_USER -c " $GIT commit -m 'Initial pristine masterfiles'" )
192192
193193 (cd $DCWORKDIR / && su $MP_APACHE_USER -c " $GIT clone --no-hardlinks --bare $DCWORKDIR /masterfiles_staging $DCWORKDIR /masterfiles.git" )
194194 find " $DCWORKDIR /masterfiles.git" -type d -exec chmod 700 {} \;
195195 find " $DCWORKDIR /masterfiles.git" -type f -exec chmod 600 {} \;
196196
197197 (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" )
199198 (cd $DCWORKDIR /masterfiles_staging && su $MP_APACHE_USER -c " $GIT remote add origin $DCWORKDIR /masterfiles.git" )
200199
201200 if [ ! -f /usr/bin/curl ]; then
265264
266265if [ -f " $MAN_CONFIG " ];
267266then
268- MAN=` cat " $MAN_CONFIG " | grep cfengine`
269- if [ -z " $MAN " ]; then
267+ if grep cfengine " $MAN_CONFIG " > /dev/null; then
270268 echo " $MAN_PATH $PREFIX /share/man" >> " $MAN_CONFIG "
271269 fi
272270fi
@@ -341,8 +339,7 @@ generate_new_postgres_conf() {
341339 # Otherwise, we use a shared_buffers equal to 25% of total memory
342340 total=` cat /proc/meminfo | grep " ^MemTotal:.*[0-9]\+ kB" | awk ' {print $2}' `
343341
344- echo " $total " | grep -q ' ^[0-9]\+$'
345- if [ $? -ne 0 ] ; then
342+ if ! echo " $total " | grep -q ' ^[0-9]\+$' > /dev/null; then
346343 cf_console echo " Error calculating total memory for setting postgresql shared_buffers" ;
347344 else
348345 upper=$(( 64 * 1024 * 1024 )) # in KB
@@ -573,6 +570,7 @@ migrate_db_using_dump_file() {
573570}
574571
575572if is_upgrade && [ -d " $BACKUP_DIR /data" ]; then
573+ set +e # this block has its own error detection/handling
576574 # DEBUG variable controls which of migration methods fail:
577575 # 0 - do nothing special (usually pg_upgrade, which is first method, succeeds)
578576 # 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
657655 cf_console echo " And now installation will proceed with clean (empty) database"
658656 (cd /tmp && su cfpostgres -c " $PREFIX /bin/initdb -D $PREFIX /state/pg/data" )
659657 fi
658+ set -e
660659fi
661660
662661(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
688687 cf_console echo " Database migration also failed for the above reason. Backups are in $PREFIX /state/pg/*.sql.gz"
689688 fi
690689else
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+ )
696700
697701 # Create the cfengine mission portal postgres user
698702 (cd /tmp && su cfpostgres -c " $PREFIX /bin/psql cfmp" < $PREFIX /share/GUI/phpcfenginenova/create_cfmppostgres_user.sql)
699703
700704 # Ensure cfpostgres can read the sql files it will import. And that they are
701705 # restored to restrictive state after import ENT-2684
702- ( chown cfpostgres " $PREFIX /share/db/*.sql" )
706+ chown cfpostgres $PREFIX /share/db/* .sql
703707 (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" )
704708
705709 # create database for MISSION PORTAL
@@ -708,9 +712,12 @@ else
708712
709713
710714 # 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+ )
714721
715722 # revoke create permission on public schema for cfdb database
716723 (cd /tmp && su cfpostgres -c " $PREFIX /bin/psql cfdb" ) << EOF
@@ -763,9 +770,11 @@ find $PREFIX/httpd/htdocs/scripts/ -type f -exec chmod 0440 {} +
763770find $PREFIX /httpd/htdocs/tmp/ -type f -exec chown -R root:$MP_APACHE_USER {} +
764771find $PREFIX /httpd/htdocs/tmp/ -type f -exec chmod 0660 {} +
765772
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
769778
770779# application
771780find $PREFIX /httpd/htdocs/application/ -type f -exec chown -R root:$MP_APACHE_USER {} +
0 commit comments