File tree Expand file tree Collapse file tree 6 files changed +37
-26
lines changed
Expand file tree Collapse file tree 6 files changed +37
-26
lines changed Original file line number Diff line number Diff line change 1717# start the csv load job
1818#
1919# /pgdata is a volume that gets mapped into this container
20- # $TABLE_TO_LOAD postgres table to copy data into
21- # $CSV_FILE_PATH path to csv file
20+ # $CSV_PATH host we are connecting to
2221# $DB_HOST host we are connecting to
2322# $DB_USER pg user we are connecting with
2423# $DB_PASS pg user password we are connecting with
2524# $DB_PORT pg port we are connecting to
2625#
2726
27+ function create_pgpass() {
28+ cd /tmp
29+ cat >> " .pgpass" << -EOF
30+ *:*:*:*:${DB_PASS}
31+ EOF
32+ chmod 0600 .pgpass
33+ export PGPASSFILE=/tmp/.pgpass
34+ # chown $UID:$UID $PGPASSFILE
35+ cat $PGPASSFILE
36+ }
2837function ose_hack() {
2938 export USER_ID=$( id -u)
3039 export GROUP_ID=$( id -g)
@@ -39,23 +48,10 @@ ose_hack
3948
4049echo $CSVFILE_PATH
4150
42- export PGPASSFILE=/tmp/pgpass
43-
44- echo " *:*:*:" $DB_USER " :" $DB_PASS >> $PGPASSFILE
45-
46- chmod 600 $PGPASSFILE
51+ create_pgpass
4752
48- chown $UID :$UID $PGPASSFILE
4953
50- # cat $PGPASSFILE
5154
52- # pg_basebackup --label=$BACKUP_LABEL --xlog --pgdata $CSVFILE_PATH --host=$DB_HOST --port=$DB_PORT -U $DB_USER
53-
54- # chown -R $UID:$UID $CSVFILE_PATH
55- #
56- # open up permissions for the OSE Dedicated random UID scenario
57- #
58- # chmod -R o+rx $CSVFILE_PATH
5955echo " COPY $TABLE_TO_LOAD FROM '/pgdata/$CSV_FILE_PATH ' WITH (FORMAT csv);" > /tmp/copycommand
6056psql -U $DB_USER -h $DB_HOST $DB_DATABASE -f /tmp/copycommand
6157echo " csvload has ended!"
Original file line number Diff line number Diff line change @@ -20,8 +20,8 @@ ENV PGVERSION="9.6" PGDG_REPO="pgdg-centos96-9.6-3.noarch.rpm"
2020# PGDG Postgres repo
2121RUN rpm -Uvh https://download.postgresql.org/pub/repos/yum/${PGVERSION}/redhat/rhel-7-x86_64/${PGDG_REPO}
2222
23- RUN yum -y update && \
24- yum install -y \
23+ RUN yum -y update && yum -y install epel-release \
24+ && yum install -y \
2525 gettext \
2626 hostname \
2727 nss_wrapper \
@@ -30,11 +30,12 @@ RUN yum -y update && \
3030 && yum -y install postgresql96 \
3131 && yum clean all -y
3232
33- RUN mkdir -p /opt/cpm/bin /opt/cpm/conf
33+ RUN mkdir -p /opt/cpm/bin /opt/cpm/conf
3434ADD bin/csvload/ /opt/cpm/bin
35- #RUN chown -R 26:26 /opt/cpm /pgdata
35+ ADD conf/csvload/ /opt/cpm/conf
36+ RUN chown -R 26:26 /opt/cpm
3637
37- VOLUME [" /pgdata"]
38+ VOLUME /pgdata
3839
3940USER 26
4041
Original file line number Diff line number Diff line change @@ -149,8 +149,8 @@ func getLoadConfigFile() {
149149 if err == nil {
150150 log .Debugf ("Using load config file: %s\n " , viper .ConfigFileUsed ())
151151 } else {
152- log .Debug ("load config file not found" )
153- return
152+ log .Error ("load config file not found" )
153+ os . Exit ( 2 )
154154 }
155155
156156 //LoadConfigTemplate.Name = viper.GetString("Name")
Original file line number Diff line number Diff line change 1+ root:x:0:0:root:/root:/bin/bash
2+ bin:x:1:1:bin:/bin:/sbin/nologin
3+ daemon:x:2:2:daemon:/sbin:/sbin/nologin
4+ adm:x:3:4:adm:/var/adm:/sbin/nologin
5+ lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
6+ sync:x:5:0:sync:/sbin:/bin/sync
7+ shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
8+ halt:x:7:0:halt:/sbin:/sbin/halt
9+ mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
10+ operator:x:11:0:operator:/root:/sbin/nologin
11+ games:x:12:100:games:/usr/games:/sbin/nologin
12+ ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
13+ nobody:x:99:99:Nobody:/:/sbin/nologin
14+ postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash
Original file line number Diff line number Diff line change 11\c userdb;
2- create table xrayapp (id int , key string , value string );
2+ create table xrayapp (id int , key varchar ( 40 ) , value varchar ( 40 ) );
33create table a (id int );
4- create table xraycsvtable (name string , state string , zip string );
4+ create table xraycsvtable (name varchar ( 40 ) , state varchar ( 40 ) , zip varchar ( 40 ) );
55
Original file line number Diff line number Diff line change 11CO_IMAGE_TAG : centos7-1.5.1
22DB_DATABASE : userdb
3- DB_USER : testuser
3+ DB_USER : postgres
44DB_PASS : password
55DB_PORT : 5432
66TABLE_TO_LOAD : xraycsvtable
You can’t perform that action at this time.
0 commit comments