summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstartxfr <clarue@startx.fr>2015-12-06 16:41:23 +0100
committerstartxfr <clarue@startx.fr>2015-12-06 16:41:23 +0100
commit7fe1c9cf9f114d40fe3f534a3902f3dff73c602f (patch)
tree5d40c66b09a9eddab90ee209a71aa37eaed787cf
parent6fc395ce332cf2565705b3a36bceaaa6f3948417 (diff)
downloadphpmyadmin-7fe1c9cf9f114d40fe3f534a3902f3dff73c602f.tar.gz
phpmyadmin-7fe1c9cf9f114d40fe3f534a3902f3dff73c602f.tar.bz2
phpmyadmin-7fe1c9cf9f114d40fe3f534a3902f3dff73c602f.tar.xz
phpmyadmin-7fe1c9cf9f114d40fe3f534a3902f3dff73c602f.zip
correcting bug and improve startup display
-rw-r--r--OS/Dockerfile1
-rw-r--r--Services/apache/Dockerfile12
-rw-r--r--Services/apache/httpd.conf1
-rw-r--r--Services/apache/sx-httpd.sh11
-rw-r--r--Services/mariadb/run.sh51
-rw-r--r--Services/nodejs/run.sh16
-rw-r--r--Services/ooconv/run.sh3
-rw-r--r--Services/php/Dockerfile16
-rw-r--r--Services/php/httpd.conf1
-rw-r--r--Services/php/run.sh11
-rw-r--r--Services/postgres/Dockerfile2
-rw-r--r--Services/postgres/run.sh79
12 files changed, 146 insertions, 58 deletions
diff --git a/OS/Dockerfile b/OS/Dockerfile
index 1ed8547..da351a2 100644
--- a/OS/Dockerfile
+++ b/OS/Dockerfile
@@ -11,5 +11,6 @@ COPY *.sh /bin/
RUN chmod 775 /bin/sx-lib.sh /bin/run.sh && \
mkdir /data && \
mkdir /data/logs
+ENV TERM=xterm
CMD ["/bin/run.sh"]
diff --git a/Services/apache/Dockerfile b/Services/apache/Dockerfile
index 620add6..9682a0a 100644
--- a/Services/apache/Dockerfile
+++ b/Services/apache/Dockerfile
@@ -6,20 +6,22 @@ RUN dnf -y install httpd && \
dnf clean all
ENV HTTPDCONF=/etc/httpd/conf.d/app.conf \
STARTUPLOG=/data/logs/apache/startup.log \
- LOG_PATH=/data/logs/apache \
- APP_PATH=/data/apache
+ LOG_PATH=/data/logs/apache \
+ APP_PATH=/data/apache \
+ TMP_APP_PATH=/tmp/apache
COPY httpd.conf $HTTPDCONF
COPY *.sh /bin/
RUN chmod 775 /bin/run.sh /bin/sx-httpd.sh && \
chmod ug+r $HTTPDCONF && \
rm -f /etc/httpd/conf.d/autoindex.conf && \
rm -f /etc/httpd/conf.d/welcome.conf && \
+ mkdir -p $TMP_APP_PATH && \
mkdir -p $APP_PATH && \
mkdir -p $LOG_PATH && \
touch $STARTUPLOG
-COPY ./ $APP_PATH
-RUN rm -f $APP_PATH/Dockerfile $APP_PATH/httpd.conf $APP_PATH/run.sh $APP_PATH/sx-httpd.sh && \
- chown -R apache:apache $APP_PATH $LOG_PATH
+COPY ./ $TMP_APP_PATH
+RUN rm -f $TMP_APP_PATH/Dockerfile $TMP_APP_PATH/httpd.conf $TMP_APP_PATH/run.sh $TMP_APP_PATH/sx-httpd.sh && \
+ chown -R apache:apache $TMP_APP_PATH $APP_PATH $LOG_PATH
EXPOSE 80 443
VOLUME [$APP_PATH,$LOG_PATH]
diff --git a/Services/apache/httpd.conf b/Services/apache/httpd.conf
index 2f9d2fc..97672b4 100644
--- a/Services/apache/httpd.conf
+++ b/Services/apache/httpd.conf
@@ -10,7 +10,6 @@ ErrorLog ${LOG_PATH}/error.log
CustomLog ${LOG_PATH}/access.log combined
</IfModule>
-Alias / ${APP_PATH}
<Directory ${APP_PATH}>
AddDefaultCharset UTF-8
AllowOverride All
diff --git a/Services/apache/sx-httpd.sh b/Services/apache/sx-httpd.sh
index 2b7581d..0344f1e 100644
--- a/Services/apache/sx-httpd.sh
+++ b/Services/apache/sx-httpd.sh
@@ -50,6 +50,17 @@ function display_container_httpd_header {
# and start generating host keys
function begin_config {
echo "=> BEGIN APACHE CONFIGURATION"
+ if [[ -d $TMP_APP_PATH ]]; then
+ if [ "$(ls -A $TMP_APP_PATH)" ]; then
+ echo "COPY application from $TMP_APP_PATH into $APP_PATH"
+ FILE_LIST=$(find $TMP_APP_PATH -maxdepth 1 -mindepth 1 -printf "%f\n")
+ for FILE in $FILE_LIST; do
+ echo -n "adding $APP_PATH/$FILE"
+ cp -r $TMP_APP_PATH/$FILE $APP_PATH/
+ echo " DONE"
+ done
+ fi
+ fi
}
# End configuration process just before starting daemon
diff --git a/Services/mariadb/run.sh b/Services/mariadb/run.sh
index d3bd4c1..4dad331 100644
--- a/Services/mariadb/run.sh
+++ b/Services/mariadb/run.sh
@@ -113,9 +113,12 @@ function config_createadmin {
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION"
echo ""
echo " +------------------------------------------------------"
+ echo " | SUPERADMIN USER CREATED ! "
echo " | You can now connect to this server using:"
+ echo " | "
echo " | user : admin"
echo " | password : $PASS"
+ echo " | "
echo " | shell : mysql -uadmin -p$PASS -h<host> -P<port>"
echo " +------------------------------------------------------"
echo ""
@@ -128,9 +131,12 @@ function config_createuser {
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'%' WITH GRANT OPTION"
echo ""
echo " +------------------------------------------------------"
+ echo " | USER CREATED ! "
echo " | You can now connect to this server using:"
+ echo " | "
echo " | user : $MYSQL_USER"
echo " | password : $MYSQL_PASSWORD"
+ echo " | "
echo " | shell : mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -h<host> -P<port>"
echo " +------------------------------------------------------"
echo ""
@@ -143,7 +149,16 @@ function config_createdatabase {
if [[ ! -d $DIR_DB_DATA/$MYSQL_DATABASE ]]; then
echo "database " $MYSQL_DATABASE " doesn't exist"
mysql -uroot -e "CREATE DATABASE $MYSQL_DATABASE DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;"
- echo "database " $MYSQL_DATABASE " CREATED"
+ echo ""
+ echo " +------------------------------------------------------"
+ echo " | DATABASE CREATED ! "
+ echo " | You can connect to this database using :"
+ echo " | "
+ echo " | database : $MYSQL_DATABASE"
+ echo " | "
+ echo " | shell : mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -h<host> -P<port> $MYSQL_DATABASE"
+ echo " +------------------------------------------------------"
+ echo ""
else
echo "database " $MYSQL_DATABASE " already exist"
fi
@@ -156,20 +171,26 @@ function config_importsql {
if [[ -n "$LOADSQL_PATH" ]]; then
echo "import sql data into " $MYSQL_DATABASE
if [[ -d $LOADSQL_PATH ]]; then
- SCHEMALIST=$(find $LOADSQL_PATH/schema-*.sql -type f -printf "%f\n")
- for SCHEMAFILE in $SCHEMALIST; do
- echo "SET NAMES utf8;"|cat - $LOADSQL_PATH/$SCHEMAFILE > /tmp/out && mv /tmp/out $LOADSQL_PATH/$SCHEMAFILE
- echo -n "Creating schema " $SCHEMAFILE " ... "
- mysql -uroot $MYSQL_DATABASE < $LOADSQL_PATH/$SCHEMAFILE
- echo " DONE"
- done
- DATALIST=$(find $LOADSQL_PATH/data-*.sql -type f -printf "%f\n")
- for DATAFILE in $DATALIST; do
- echo "SET NAMES utf8;"|cat - $LOADSQL_PATH/$DATAFILE > /tmp/out && mv /tmp/out $LOADSQL_PATH/$DATAFILE
- echo -n "Creating data " $DATAFILE " ... "
- mysql -uroot $MYSQL_DATABASE < $LOADSQL_PATH/$DATAFILE
- echo " DONE"
- done
+ if [ "$(ls -A $LOADSQL_PATH/schema-*.sql)" ]; then
+ echo "Importing schema from $LOADSQL_PATH "
+ SCHEMALIST=$(find $LOADSQL_PATH/schema-*.sql -type f -printf "%f\n")
+ for SCHEMAFILE in $SCHEMALIST; do
+ echo "SET NAMES utf8;"|cat - $LOADSQL_PATH/$SCHEMAFILE > /tmp/out && mv /tmp/out $LOADSQL_PATH/$SCHEMAFILE
+ echo -n "Creating schema " $SCHEMAFILE " ... "
+ mysql -uroot $MYSQL_DATABASE < $LOADSQL_PATH/$SCHEMAFILE
+ echo " DONE"
+ done
+ fi
+ if [ "$(ls -A $LOADSQL_PATH/data-*.sql)" ]; then
+ echo "Importing data from $LOADSQL_PATH "
+ DATALIST=$(find $LOADSQL_PATH/data-*.sql -type f -printf "%f\n")
+ for DATAFILE in $DATALIST; do
+ echo "SET NAMES utf8;"|cat - $LOADSQL_PATH/$DATAFILE > /tmp/out && mv /tmp/out $LOADSQL_PATH/$DATAFILE
+ echo -n "Creating data " $DATAFILE " ... "
+ mysql -uroot $MYSQL_DATABASE < $LOADSQL_PATH/$DATAFILE
+ echo " DONE"
+ done
+ fi
fi
else
echo "no sql data to import into " $MYSQL_DATABASE
diff --git a/Services/nodejs/run.sh b/Services/nodejs/run.sh
index 1bd6a50..cc94229 100644
--- a/Services/nodejs/run.sh
+++ b/Services/nodejs/run.sh
@@ -42,13 +42,15 @@ function display_container_nodejs_header {
function begin_config {
echo "=> BEGIN NODEJS CONFIGURATION"
if [[ -d $TMP_APP_PATH ]]; then
- echo "COPY application from $TMP_APP_PATH into $APP_PATH"
- FILE_LIST=$(find $TMP_APP_PATH -maxdepth 1 -mindepth 1 -printf "%f\n")
- for FILE in $FILE_LIST; do
- echo -n "adding $APP_PATH/$FILE"
- cp -r $TMP_APP_PATH/$FILE $APP_PATH/
- echo " DONE"
- done
+ if [ "$(ls -A $TMP_APP_PATH)" ]; then
+ echo "COPY application from $TMP_APP_PATH into $APP_PATH"
+ FILE_LIST=$(find $TMP_APP_PATH -maxdepth 1 -mindepth 1 -printf "%f\n")
+ for FILE in $FILE_LIST; do
+ echo -n "adding $APP_PATH/$FILE"
+ cp -r $TMP_APP_PATH/$FILE $APP_PATH/
+ echo " DONE"
+ done
+ fi
fi
}
diff --git a/Services/ooconv/run.sh b/Services/ooconv/run.sh
index 57b6241..4ed67b7 100644
--- a/Services/ooconv/run.sh
+++ b/Services/ooconv/run.sh
@@ -48,6 +48,9 @@ function end_config {
function start_daemon {
echo "=> Starting ooconv daemon ..." | tee -a $STARTUPLOG
display_container_started | tee -a $STARTUPLOG
+ unoconv --listener -vvv | tee -a $STARTUPLOG
+ sleep 1
+ killall unoconv soffice.bin
exec unoconv --listener
}
diff --git a/Services/php/Dockerfile b/Services/php/Dockerfile
index 51085e9..7cb96b5 100644
--- a/Services/php/Dockerfile
+++ b/Services/php/Dockerfile
@@ -10,19 +10,21 @@ RUN dnf -y install php php-pecl-mongo php-cli php-pear \
&& dnf clean all
ENV LOG_PATH=/data/logs/apache_php \
APP_PATH=/data/apache_php \
- STARTUPLOG=/data/logs/apache_php/startup.log
+ STARTUPLOG=/data/logs/apache_php/startup.log \
+ TMP_APP_PATH=/tmp/apache
COPY httpd.conf $HTTPDCONF
COPY php.ini /etc/php.d/sx.ini
COPY run.sh /bin/
RUN chmod 775 /bin/run.sh && \
chmod ug+r $HTTPDCONF && \
- mkdir $APP_PATH && \
- mkdir $LOG_PATH && \
+ mkdir -p $TMP_APP_PATH && \
+ mkdir -p $APP_PATH && \
+ mkdir -p $LOG_PATH && \
touch $STARTUPLOG
-COPY ./ $APP_PATH
-RUN rm -f $APP_PATH/Dockerfile $APP_PATH/httpd.conf $APP_PATH/run.sh && \
- chown -R apache:apache $APP_PATH $LOG_PATH && \
- chmod ug+r -R $APP_PATH
+COPY ./ $TMP_APP_PATH
+RUN rm -f $TMP_APP_PATH/Dockerfile $TMP_APP_PATH/httpd.conf $TMP_APP_PATH/run.sh && \
+ chown -R apache:apache $TMP_APP_PATH $APP_PATH $LOG_PATH && \
+ chmod ug+r -R $TMP_APP_PATH $APP_PATH
EXPOSE 80 443
VOLUME [$APP_PATH,$LOG_PATH]
diff --git a/Services/php/httpd.conf b/Services/php/httpd.conf
index 1ce768f..9cbe16a 100644
--- a/Services/php/httpd.conf
+++ b/Services/php/httpd.conf
@@ -10,7 +10,6 @@ ErrorLog ${LOG_PATH}/error.log
CustomLog ${LOG_PATH}/access.log combined
</IfModule>
-Alias / ${APP_PATH}
<Directory ${APP_PATH}>
AddDefaultCharset UTF-8
AllowOverride All
diff --git a/Services/php/run.sh b/Services/php/run.sh
index a092c56..657fbba 100644
--- a/Services/php/run.sh
+++ b/Services/php/run.sh
@@ -37,6 +37,17 @@ function display_container_php_header {
# and start generating host keys
function begin_php_config {
echo "=> BEGIN APACHE + PHP CONFIGURATION"
+ if [[ -d $TMP_APP_PATH ]]; then
+ if [ "$(ls -A $TMP_APP_PATH)" ]; then
+ echo "COPY application from $TMP_APP_PATH into $APP_PATH"
+ FILE_LIST=$(find $TMP_APP_PATH -maxdepth 1 -mindepth 1 -printf "%f\n")
+ for FILE in $FILE_LIST; do
+ echo -n "adding $APP_PATH/$FILE"
+ cp -r $TMP_APP_PATH/$FILE $APP_PATH/
+ echo " DONE"
+ done
+ fi
+ fi
}
# End configuration process just before starting daemon
diff --git a/Services/postgres/Dockerfile b/Services/postgres/Dockerfile
index 22e5761..701c127 100644
--- a/Services/postgres/Dockerfile
+++ b/Services/postgres/Dockerfile
@@ -19,5 +19,5 @@ RUN chmod 775 /bin/run.sh && \
chmod -R 0700 $DATA_PATH
EXPOSE 5432
-VOLUME [$DATA_PATH,$LOG_PATH]
+VOLUME [$DATA_PATH, $LOG_PATH]
CMD ["/bin/run.sh"]
diff --git a/Services/postgres/run.sh b/Services/postgres/run.sh
index ff4145d..de130fc 100644
--- a/Services/postgres/run.sh
+++ b/Services/postgres/run.sh
@@ -1,6 +1,15 @@
#!/bin/bash
source /bin/sx-lib.sh
+set -e
+
+set_listen_addresses() {
+ sedEscapedValue="$(echo "$1" | sed 's/[\/&]/\\&/g')"
+ sed -ri "s/^#?(listen_addresses\s*=\s*)\S+/\1'$sedEscapedValue'/" "$POSTGRESQL_CONF"
+}
+
+
+
function check_postgresql_environment {
check_environment
if [ ! -v DATA_PATH ]; then
@@ -51,6 +60,7 @@ function begin_config {
else
echo "data directory $DATA_PATH EXIST"
fi
+ export PGDATA=$DATA_PATH
if [[ ! -d $LOG_PATH ]]; then
echo "log directory $LOG_PATH not found"
mkdir -p $LOG_PATH; chmod 0774 $LOG_PATH
@@ -78,19 +88,23 @@ function begin_config {
echo "log_connections = on" >> $POSTGRESQL_CONF
echo "log_hostname = on" >> $POSTGRESQL_CONF
echo "log_line_prefix = '<%u@%r%%%d>'" >> $POSTGRESQL_CONF
+ { echo; echo "host all all 0.0.0.0/0 md5"; } >> "$DATA_PATH/pg_hba.conf"
echo "Installing PostgreSQL in $DATA_PATH is DONE !"
+ chown root:postgres $STARTUPLOG
+ chmod ug+w $STARTUPLOG
fi
}
function config_startserver {
echo "start database for initial setup"
- su - postgres -c "nohup /usr/bin/postgres -D $DATA_PATH >$STARTUPLOG 2>&1 </dev/null &"
+ su - postgres -c "pg_ctl -D $DATA_PATH -o \"-c listen_addresses=''\" --log=$STARTUPLOG -w start "
sleep 6
}
function config_stopserver {
echo "stop database after initial setup"
- killall postgres
+ su - postgres -c "pg_ctl -D $DATA_PATH -m fast -w stop"
+ set_listen_addresses '*'
sleep 3
}
@@ -99,13 +113,16 @@ function config_createadmin {
PASS=${POSTGRESQL_ROOT_PASSWORD:-$(pwgen -s 12 1)}
_word=$( [ ${POSTGRESQL_ROOT_PASSWORD} ] && echo "preset" || echo "random" )
echo "Creating PostgreSQL admin user with ${_word} password"
- su - postgres -c "psql -U postgres -d postgres -c \"alter user postgres with password '$PASS';\""
+ su - postgres -c "psql -U postgres -c \"ALTER USER postgres WITH SUPERUSER PASSWORD '$PASS';\""
echo ""
echo " +------------------------------------------------------"
+ echo " | SUPERADMIN USER CREATED ! "
echo " | You can now connect to this server using:"
+ echo " | "
echo " | user : postgres"
echo " | password : $PASS"
- echo " | shell : postgres -U postgres -p$PASS -h<host> -P<port>"
+ echo " | "
+ echo " | shell : psql --username=postgres --host=<host> --port=<port>"
echo " +------------------------------------------------------"
echo ""
}
@@ -113,13 +130,16 @@ function config_createadmin {
function config_createuser {
if [[ -n "$POSTGRESQL_USER" ]]; then
echo "Creating PostgreSQL $POSTGRESQL_USER user with preset password"
- su - postgres -c "psql -U postgres -d postgres -c \"CREATE USER '$POSTGRESQL_USER' WITH PASSWORD '$POSTGRESQL_PASSWORD';\""
+ su - postgres -c 'psql -U postgres -c \"CREATE USER \"$POSTGRESQL_USER\" WITH PASSWORD \'$POSTGRESQL_PASSWORD\';\"'
echo ""
echo " +------------------------------------------------------"
+ echo " | USER CREATED ! "
echo " | You can now connect to this server using:"
+ echo " | "
echo " | user : $POSTGRESQL_USER"
echo " | password : $POSTGRESQL_PASSWORD"
- echo " | shell : mysql -u$POSTGRESQL_USER -p$POSTGRESQL_PASSWORD -h<host> -P<port>"
+ echo " | "
+ echo " | shell : psql --username=$POSTGRESQL_USER --host=<host> --port=<port>"
echo " +------------------------------------------------------"
echo ""
fi
@@ -130,8 +150,17 @@ function config_createdatabase {
echo "processing database " $POSTGRESQL_DATABASE
if [[ ! -d $DIR_DB_DATA/$POSTGRESQL_DATABASE ]]; then
echo "database " $POSTGRESQL_DATABASE " doesn't exist"
- su - postgres -c "psql -U postgres -d postgres -c \"CREATE DATABASE $POSTGRESQL_DATABASE;\""
- echo "database " $POSTGRESQL_DATABASE " CREATED"
+ su - postgres -c "psql -U postgres -c \"CREATE DATABASE $POSTGRESQL_DATABASE;\""
+ echo ""
+ echo " +------------------------------------------------------"
+ echo " | DATABASE CREATED ! "
+ echo " | You can connect to this database using :"
+ echo " | "
+ echo " | database : $POSTGRESQL_DATABASE"
+ echo " | "
+ echo " | shell : psql --username=postgres --host=<host> --port=<port> $POSTGRESQL_DATABASE "
+ echo " +------------------------------------------------------"
+ echo ""
else
echo "database " $POSTGRESQL_DATABASE " already exist"
fi
@@ -144,18 +173,24 @@ function config_importsql {
if [[ -n "$LOADSQL_PATH" ]]; then
echo "import sql data into " $POSTGRESQL_DATABASE
if [[ -d $LOADSQL_PATH ]]; then
- SCHEMALIST=$(find $LOADSQL_PATH/schema-*.sql -type f -printf "%f\n")
- for SCHEMAFILE in $SCHEMALIST; do
- echo -n "Creating schema " $SCHEMAFILE " ... "
- su - postgres -c "psql -U postgres -d postgres < $LOADSQL_PATH/$SCHEMAFILE"
- echo " DONE"
- done
- DATALIST=$(find $LOADSQL_PATH/data-*.sql -type f -printf "%f\n")
- for DATAFILE in $DATALIST; do
- echo -n "Creating data " $DATAFILE " ... "
- su - postgres -c "psql -U postgres -d postgres < $LOADSQL_PATH/$DATAFILE"
- echo " DONE"
- done
+ if [ "$(ls -A $LOADSQL_PATH/schema-*.sql)" ]; then
+ echo "Importing schema from $LOADSQL_PATH "
+ SCHEMALIST=$(find $LOADSQL_PATH/schema-*.sql -type f -printf "%f\n")
+ for SCHEMAFILE in $SCHEMALIST; do
+ echo -n "Creating schema " $SCHEMAFILE " ... "
+ su - postgres -c "psql -U postgres -d $POSTGRESQL_DATABASE < $LOADSQL_PATH/$SCHEMAFILE"
+ echo " DONE"
+ done
+ fi
+ if [ "$(ls -A $LOADSQL_PATH/data-*.sql)" ]; then
+ echo "Importing data from $LOADSQL_PATH "
+ DATALIST=$(find $LOADSQL_PATH/data-*.sql -type f -printf "%f\n")
+ for DATAFILE in $DATALIST; do
+ echo -n "Creating data " $DATAFILE " ... "
+ su - postgres -c "psql -U postgres -d $POSTGRESQL_DATABASE < $LOADSQL_PATH/$DATAFILE"
+ echo " DONE"
+ done
+ fi
fi
else
echo "no sql data to import into " $POSTGRESQL_DATABASE
@@ -173,7 +208,9 @@ function end_config {
function start_daemon {
echo "=> Starting postgresql daemon ..." | tee -a $STARTUPLOG
display_container_started | tee -a $STARTUPLOG
- su - postgres -c "/usr/bin/postgres -D $DATA_PATH "
+ su - postgres -c "pg_ctl -D $DATA_PATH -w start "
+ echo "postgres daemon is started" > /tmp/started
+ exec tail -f /tmp/started
}