diff --git a/postgres/Dockerfile b/postgres/Dockerfile index 6b598b8..b29ba7e 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -18,20 +18,11 @@ RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main" > /etc/ # them by prefixing each apt-get statement with DEBIAN_FRONTEND=noninteractive RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get upgrade && apt-get install -y python-software-properties software-properties-common postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3 -# Note: The official Debian and Ubuntu images automatically ``apt-get clean`` -# after each ``apt-get`` +# clear the data dir +RUN rm -rf /var/lib/postgresql/9.3/ -# Only quassel needs to connectm eh? -#RUN echo "host quassel quassel quassel-docker-quassel trust" >> /etc/postgresql/9.3/main/pg_hba.conf -RUN echo "host quassel quassel 172.17.0.0/16 trust" >> /etc/postgresql/9.3/main/pg_hba.conf - -# Well... -RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf - -# prep script -ADD prep.sh /root/prep.sh -# just in case this is a test drive -- production environments will need to re-run prep.sh for the external volume -RUN ls -l /root && /bin/bash /root/prep.sh +# prep script -- will be run each time the container is started +ADD start.sh /var/lib/start # Expose the PostgreSQL port EXPOSE 5432 @@ -39,9 +30,6 @@ EXPOSE 5432 # Add VOLUMEs to allow backup of config, logs and databases VOLUME ["/var/lib/postgresql/"] -# Run the rest of the commands as the ``postgres`` user created by the ``postgres-9.3`` package when it was ``apt-get installed`` -USER postgres - # Set the default command to run when starting the container -CMD [] -ENTRYPOINT ["/usr/lib/postgresql/9.3/bin/postgres", "-D", "/etc/postgresql/9.3/main/"] +CMD ["/var/lib/start"] +ENTRYPOINT ["/bin/bash"] \ No newline at end of file diff --git a/postgres/data/.gitignore b/postgres/data/.gitignore old mode 100644 new mode 100755 diff --git a/postgres/prep.sh b/postgres/prep.sh deleted file mode 100755 index fb6e5f4..0000000 --- a/postgres/prep.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# removing the database cluster if it exists and prepping everything for posgresql operation -# be careful, Will Robinson! - -# we need to be root for this -if [[ `whoami` != 'root' ]]; then - echo "we need to be root for this, quitting" - exit 1 -fi - -# work the directory -cd /var/lib/postgresql -chown postgres:postgres ./ -chmod 0700 ./ - -# initdb as postgres -su -c '/usr/lib/postgresql/9.3/bin/initdb /var/lib/postgresql/9.3/main' postgres - -# let quassel db -/etc/init.d/postgresql start -su -c 'psql --command "CREATE USER quassel;"' postgres -su -c "psql --command \"CREATE DATABASE quassel WITH OWNER quassel TEMPLATE template0 ENCODING 'UTF8';\"" postgres -/etc/init.d/postgresql stop \ No newline at end of file diff --git a/postgres/start.sh b/postgres/start.sh new file mode 100755 index 0000000..b08eb56 --- /dev/null +++ b/postgres/start.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# removing the database cluster if it exists and prepping everything for posgresql operation +# be careful, Will Robinson! + +# we need to be root for this +if [[ `whoami` != 'root' ]]; then + echo "we need to be root for this, quitting" + exit 1 +fi + +# work the directory +cd /var/lib/postgresql +chown -R postgres:postgres ./ +chmod -R 0700 ./ + +# do we need to init the db? +if [ ! -e /var/lib/postgresql/9.3/main ]; then + + # initdb as postgres + su -c '/usr/lib/postgresql/9.3/bin/initdb /var/lib/postgresql/9.3/main' postgres + + # config + echo "host all all `hostname -I | sed 's/ //g'`/16 trust" >> /var/lib/postgresql/9.3/main/pg_hba.conf + echo "listen_addresses='*'" >> /var/lib/postgresql/9.3/main/postgresql.conf + + # let quassel db + /etc/init.d/postgresql start + su -c 'psql --command "CREATE USER quassel;"' postgres + su -c "psql --command \"CREATE DATABASE quassel WITH OWNER quassel TEMPLATE template0 ENCODING 'UTF8';\"" postgres + /etc/init.d/postgresql stop + +fi + +# run postgres as user postgres +su -c '/usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/9.3/main' postgres \ No newline at end of file diff --git a/quassel/Dockerfile b/quassel/Dockerfile index 96215bc..229b68d 100644 --- a/quassel/Dockerfile +++ b/quassel/Dockerfile @@ -9,11 +9,13 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get upgrade && apt-get libqca2-plugin-ossl libicu52 \ postgresql-client +# prep script +ADD start.sh /var/lib/start + +# volume and expose VOLUME ["/var/lib/quassel/quasselcore.conf"] EXPOSE 4242 -USER quasselcore - # use ENTRYPOINT instead of CMD so that we can easily pass additional arguments to the run command -CMD [] -ENTRYPOINT ["quasselcore", "--configdir=/var/lib/quassel/"] +CMD ["/var/lib/start"] +ENTRYPOINT ["/bin/bash"] diff --git a/quassel/quasselcore.conf b/quassel/quasselcore.conf index e69de29..da83bbd 100644 --- a/quassel/quasselcore.conf +++ b/quassel/quasselcore.conf @@ -0,0 +1,6 @@ +[Config] +Version=1 + +[Core] +CoreState=@Variant(\0\0\0\b\0\0\0\x2\0\0\0 \0\x43\0o\0r\0\x65\0S\0t\0\x61\0t\0\x65\0V\0\x65\0r\0s\0i\0o\0n\0\0\0\x2\0\0\0\x1\0\0\0\x1c\0\x41\0\x63\0t\0i\0v\0\x65\0S\0\x65\0s\0s\0i\0o\0n\0s\0\0\0\t\0\0\0\0) +StorageSettings="@Variant(\0\0\0\b\0\0\0\x2\0\0\0(\0\x43\0o\0n\0n\0\x65\0\x63\0t\0i\0o\0n\0P\0r\0o\0p\0\x65\0r\0t\0i\0\x65\0s\0\0\0\b\0\0\0\x5\0\0\0\x10\0U\0s\0\x65\0r\0n\0\x61\0m\0\x65\0\0\0\n\0\0\0\xe\0q\0u\0\x61\0s\0s\0\x65\0l\0\0\0\b\0P\0o\0r\0t\0\0\0\x2\0\0\x15\x38\0\0\0\x10\0P\0\x61\0s\0s\0w\0o\0r\0\x64\0\0\0\n\0\0\0\0\0\0\0\x10\0H\0o\0s\0t\0n\0\x61\0m\0\x65\0\0\0\n\0\0\0,\0q\0u\0\x61\0s\0s\0\x65\0l\0\x64\0o\0\x63\0k\0\x65\0r\0-\0p\0o\0s\0t\0g\0r\0\x65\0s\0\0\0\x10\0\x44\0\x61\0t\0\x61\0\x62\0\x61\0s\0\x65\0\0\0\n\0\0\0\xe\0q\0u\0\x61\0s\0s\0\x65\0l\0\0\0\xe\0\x42\0\x61\0\x63\0k\0\x65\0n\0\x64\0\0\0\n\0\0\0\x14\0P\0o\0s\0t\0g\0r\0\x65\0S\0Q\0L)" diff --git a/quassel/start.sh b/quassel/start.sh new file mode 100644 index 0000000..c7db2e2 --- /dev/null +++ b/quassel/start.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# +# quasseldocker quaselcore wrapper +# + +# we need to be root for this +if [[ `whoami` != 'root' ]]; then + echo "we need to be root for this, quitting" + exit 1 +fi + +# make sure permissions are okay +chown -R quasselcore:quassel /var/lib/quassel/ + +# run the damn thing +su -s /bin/bash -c 'quasselcore --configdir=/var/lib/quassel/' quasselcore \ No newline at end of file diff --git a/quassel_docker.sh b/quassel_docker.sh index 39ea8e8..bd8a0c9 100755 --- a/quassel_docker.sh +++ b/quassel_docker.sh @@ -30,6 +30,7 @@ if [ "$setup_volumes" = true ]; then fi # should we set-up the port forwarding to the host system? +quassel_port="" if [ "$setup_ports" = true ]; then quassel_port="-p 4242:4242" fi @@ -53,10 +54,7 @@ killall="docker kill $quassel_container $postgres_container" rmall="docker rm -v $quassel_container $postgres_container" # info -info="remember to prep both environments if needed (e.g. after clean build): - - docker run --entrypoint /bin/sh -u root -t -i $postgres_volume --rm $postgres_image -c /root/prep.sh - - docker run --entrypoint /bin/sh -u root -t -i $quassel_volume --name $quassel_container --rm $quassel_image -c 'chown quasselcore:quassel /var/lib/quassel/quasselcore.conf' - +info=" root access to both containers: - docker run --entrypoint /bin/sh -u root -h $postgres_container -t -i --name $postgres_container --rm $postgres_image -c /bin/bash - docker run --entrypoint /bin/sh -u root -h $quassel_container --link=$postgres_container:$postgres_container -t -i $quassel_volume --name $quassel_container --rm $quassel_image -c /bin/bash" @@ -149,4 +147,4 @@ if [[ "$1" == "" || "$1" == "--run" ]]; then - $quassel_container (`docker inspect --format '{{ .NetworkSettings.IPAddress }}' $quassel_container`) " -fi \ No newline at end of file +fi