From 850e3e41e2a7c9c9aa5dc32725c2a798ea30efe8 Mon Sep 17 00:00:00 2001 From: kvaps <kvapss@gmail.com> Date: Tue, 16 Aug 2016 16:54:54 +0300 Subject: [PATCH 1/4] add: config coping when exit --- nextcloud/10.0/run.sh | 27 ++++++++++++++++----------- nextcloud/9.0/run.sh | 27 ++++++++++++++++----------- nextcloud/daily/run.sh | 27 ++++++++++++++++----------- 3 files changed, 48 insertions(+), 33 deletions(-) diff --git a/nextcloud/10.0/run.sh b/nextcloud/10.0/run.sh index 9885eb7..9047e92 100644 --- a/nextcloud/10.0/run.sh +++ b/nextcloud/10.0/run.sh @@ -1,19 +1,24 @@ #!/bin/sh addgroup -g ${GID} nextcloud && adduser -h /nextcloud -s /bin/sh -D -G nextcloud -u ${UID} nextcloud -if [ -f /nextcloud/config/config.php ] && [ ! -f /config/config.php ]; then - cp /nextcloud/config/config.php /config/config.php -elif [ -f /config/config.php ]; then - if [ -f /nextcloud/config/config.php ]; then - sed -i "s/.*version.*/`grep "version" \/nextcloud\/config\/config.php`/" /config/config.php - CONFIG=`md5sum /config/config.php | awk '{ print $1 }'` - CONFIGINS=`md5sum /nextcloud/config/config.php | awk '{ print $1 }'` - if [ $CONFIG != $CONFIGINS ]; then - mv /nextcloud/config/config.php /config/config.php.bkp +function copy_config { + if [ -f /nextcloud/config/config.php ] && [ ! -f /config/config.php ]; then + cp /nextcloud/config/config.php /config/config.php + elif [ -f /config/config.php ]; then + if [ -f /nextcloud/config/config.php ]; then + sed -i "s/.*version.*/`grep "version" \/nextcloud\/config\/config.php`/" /config/config.php + CONFIG=`md5sum /config/config.php | awk '{ print $1 }'` + CONFIGINS=`md5sum /nextcloud/config/config.php | awk '{ print $1 }'` + if [ $CONFIG != $CONFIGINS ]; then + mv /nextcloud/config/config.php /config/config.php.bkp + fi fi + cp /config/config.php /nextcloud/config/config.php fi - cp /config/config.php /nextcloud/config/config.php -fi +} + +copy_config +trap copy_config EXIT touch /var/run/php-fpm.sock mkdir /tmp/fastcgi /tmp/client_body diff --git a/nextcloud/9.0/run.sh b/nextcloud/9.0/run.sh index 9885eb7..9047e92 100644 --- a/nextcloud/9.0/run.sh +++ b/nextcloud/9.0/run.sh @@ -1,19 +1,24 @@ #!/bin/sh addgroup -g ${GID} nextcloud && adduser -h /nextcloud -s /bin/sh -D -G nextcloud -u ${UID} nextcloud -if [ -f /nextcloud/config/config.php ] && [ ! -f /config/config.php ]; then - cp /nextcloud/config/config.php /config/config.php -elif [ -f /config/config.php ]; then - if [ -f /nextcloud/config/config.php ]; then - sed -i "s/.*version.*/`grep "version" \/nextcloud\/config\/config.php`/" /config/config.php - CONFIG=`md5sum /config/config.php | awk '{ print $1 }'` - CONFIGINS=`md5sum /nextcloud/config/config.php | awk '{ print $1 }'` - if [ $CONFIG != $CONFIGINS ]; then - mv /nextcloud/config/config.php /config/config.php.bkp +function copy_config { + if [ -f /nextcloud/config/config.php ] && [ ! -f /config/config.php ]; then + cp /nextcloud/config/config.php /config/config.php + elif [ -f /config/config.php ]; then + if [ -f /nextcloud/config/config.php ]; then + sed -i "s/.*version.*/`grep "version" \/nextcloud\/config\/config.php`/" /config/config.php + CONFIG=`md5sum /config/config.php | awk '{ print $1 }'` + CONFIGINS=`md5sum /nextcloud/config/config.php | awk '{ print $1 }'` + if [ $CONFIG != $CONFIGINS ]; then + mv /nextcloud/config/config.php /config/config.php.bkp + fi fi + cp /config/config.php /nextcloud/config/config.php fi - cp /config/config.php /nextcloud/config/config.php -fi +} + +copy_config +trap copy_config EXIT touch /var/run/php-fpm.sock mkdir /tmp/fastcgi /tmp/client_body diff --git a/nextcloud/daily/run.sh b/nextcloud/daily/run.sh index 9885eb7..9047e92 100644 --- a/nextcloud/daily/run.sh +++ b/nextcloud/daily/run.sh @@ -1,19 +1,24 @@ #!/bin/sh addgroup -g ${GID} nextcloud && adduser -h /nextcloud -s /bin/sh -D -G nextcloud -u ${UID} nextcloud -if [ -f /nextcloud/config/config.php ] && [ ! -f /config/config.php ]; then - cp /nextcloud/config/config.php /config/config.php -elif [ -f /config/config.php ]; then - if [ -f /nextcloud/config/config.php ]; then - sed -i "s/.*version.*/`grep "version" \/nextcloud\/config\/config.php`/" /config/config.php - CONFIG=`md5sum /config/config.php | awk '{ print $1 }'` - CONFIGINS=`md5sum /nextcloud/config/config.php | awk '{ print $1 }'` - if [ $CONFIG != $CONFIGINS ]; then - mv /nextcloud/config/config.php /config/config.php.bkp +function copy_config { + if [ -f /nextcloud/config/config.php ] && [ ! -f /config/config.php ]; then + cp /nextcloud/config/config.php /config/config.php + elif [ -f /config/config.php ]; then + if [ -f /nextcloud/config/config.php ]; then + sed -i "s/.*version.*/`grep "version" \/nextcloud\/config\/config.php`/" /config/config.php + CONFIG=`md5sum /config/config.php | awk '{ print $1 }'` + CONFIGINS=`md5sum /nextcloud/config/config.php | awk '{ print $1 }'` + if [ $CONFIG != $CONFIGINS ]; then + mv /nextcloud/config/config.php /config/config.php.bkp + fi fi + cp /config/config.php /nextcloud/config/config.php fi - cp /config/config.php /nextcloud/config/config.php -fi +} + +copy_config +trap copy_config EXIT touch /var/run/php-fpm.sock mkdir /tmp/fastcgi /tmp/client_body From 391b54ca39bde2726f59c2d522c6dd0ee4f7d62c Mon Sep 17 00:00:00 2001 From: kvaps <kvapss@gmail.com> Date: Tue, 16 Aug 2016 17:34:20 +0300 Subject: [PATCH 2/4] mod: symblic link instead coping --- nextcloud/10.0/run.sh | 22 ++++------------------ nextcloud/9.0/run.sh | 22 ++++------------------ nextcloud/daily/run.sh | 22 ++++------------------ 3 files changed, 12 insertions(+), 54 deletions(-) diff --git a/nextcloud/10.0/run.sh b/nextcloud/10.0/run.sh index 9047e92..703e409 100644 --- a/nextcloud/10.0/run.sh +++ b/nextcloud/10.0/run.sh @@ -1,24 +1,10 @@ #!/bin/sh addgroup -g ${GID} nextcloud && adduser -h /nextcloud -s /bin/sh -D -G nextcloud -u ${UID} nextcloud -function copy_config { - if [ -f /nextcloud/config/config.php ] && [ ! -f /config/config.php ]; then - cp /nextcloud/config/config.php /config/config.php - elif [ -f /config/config.php ]; then - if [ -f /nextcloud/config/config.php ]; then - sed -i "s/.*version.*/`grep "version" \/nextcloud\/config\/config.php`/" /config/config.php - CONFIG=`md5sum /config/config.php | awk '{ print $1 }'` - CONFIGINS=`md5sum /nextcloud/config/config.php | awk '{ print $1 }'` - if [ $CONFIG != $CONFIGINS ]; then - mv /nextcloud/config/config.php /config/config.php.bkp - fi - fi - cp /config/config.php /nextcloud/config/config.php - fi -} - -copy_config -trap copy_config EXIT +if [ -f /nextcloud/config/config.php ] && [ ! -f /config/config.php ]; then + mv /nextcloud/config/config.php /config/config.php +fi +ln -s /config/config.php /nextcloud/config/config.php touch /var/run/php-fpm.sock mkdir /tmp/fastcgi /tmp/client_body diff --git a/nextcloud/9.0/run.sh b/nextcloud/9.0/run.sh index 9047e92..703e409 100644 --- a/nextcloud/9.0/run.sh +++ b/nextcloud/9.0/run.sh @@ -1,24 +1,10 @@ #!/bin/sh addgroup -g ${GID} nextcloud && adduser -h /nextcloud -s /bin/sh -D -G nextcloud -u ${UID} nextcloud -function copy_config { - if [ -f /nextcloud/config/config.php ] && [ ! -f /config/config.php ]; then - cp /nextcloud/config/config.php /config/config.php - elif [ -f /config/config.php ]; then - if [ -f /nextcloud/config/config.php ]; then - sed -i "s/.*version.*/`grep "version" \/nextcloud\/config\/config.php`/" /config/config.php - CONFIG=`md5sum /config/config.php | awk '{ print $1 }'` - CONFIGINS=`md5sum /nextcloud/config/config.php | awk '{ print $1 }'` - if [ $CONFIG != $CONFIGINS ]; then - mv /nextcloud/config/config.php /config/config.php.bkp - fi - fi - cp /config/config.php /nextcloud/config/config.php - fi -} - -copy_config -trap copy_config EXIT +if [ -f /nextcloud/config/config.php ] && [ ! -f /config/config.php ]; then + mv /nextcloud/config/config.php /config/config.php +fi +ln -s /config/config.php /nextcloud/config/config.php touch /var/run/php-fpm.sock mkdir /tmp/fastcgi /tmp/client_body diff --git a/nextcloud/daily/run.sh b/nextcloud/daily/run.sh index 9047e92..703e409 100644 --- a/nextcloud/daily/run.sh +++ b/nextcloud/daily/run.sh @@ -1,24 +1,10 @@ #!/bin/sh addgroup -g ${GID} nextcloud && adduser -h /nextcloud -s /bin/sh -D -G nextcloud -u ${UID} nextcloud -function copy_config { - if [ -f /nextcloud/config/config.php ] && [ ! -f /config/config.php ]; then - cp /nextcloud/config/config.php /config/config.php - elif [ -f /config/config.php ]; then - if [ -f /nextcloud/config/config.php ]; then - sed -i "s/.*version.*/`grep "version" \/nextcloud\/config\/config.php`/" /config/config.php - CONFIG=`md5sum /config/config.php | awk '{ print $1 }'` - CONFIGINS=`md5sum /nextcloud/config/config.php | awk '{ print $1 }'` - if [ $CONFIG != $CONFIGINS ]; then - mv /nextcloud/config/config.php /config/config.php.bkp - fi - fi - cp /config/config.php /nextcloud/config/config.php - fi -} - -copy_config -trap copy_config EXIT +if [ -f /nextcloud/config/config.php ] && [ ! -f /config/config.php ]; then + mv /nextcloud/config/config.php /config/config.php +fi +ln -s /config/config.php /nextcloud/config/config.php touch /var/run/php-fpm.sock mkdir /tmp/fastcgi /tmp/client_body From d0dae7fd8e14ce82f5c67f5f9646fb2e6950ed4c Mon Sep 17 00:00:00 2001 From: kvaps <kvapss@gmail.com> Date: Tue, 16 Aug 2016 19:23:31 +0300 Subject: [PATCH 3/4] del: check for distributed config.php --- nextcloud/10.0/run.sh | 6 +----- nextcloud/9.0/run.sh | 6 +----- nextcloud/daily/run.sh | 6 +----- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/nextcloud/10.0/run.sh b/nextcloud/10.0/run.sh index 703e409..e795c4a 100644 --- a/nextcloud/10.0/run.sh +++ b/nextcloud/10.0/run.sh @@ -1,14 +1,10 @@ #!/bin/sh addgroup -g ${GID} nextcloud && adduser -h /nextcloud -s /bin/sh -D -G nextcloud -u ${UID} nextcloud -if [ -f /nextcloud/config/config.php ] && [ ! -f /config/config.php ]; then - mv /nextcloud/config/config.php /config/config.php -fi -ln -s /config/config.php /nextcloud/config/config.php - touch /var/run/php-fpm.sock mkdir /tmp/fastcgi /tmp/client_body chown -R nextcloud:nextcloud /nextcloud /data /config /apps2 /var/run/php-fpm.sock /var/lib/nginx /tmp +ln -s /config/config.php /nextcloud/config/config.php ln -s /apps2 /nextcloud supervisord -c /etc/supervisor/supervisord.conf diff --git a/nextcloud/9.0/run.sh b/nextcloud/9.0/run.sh index 703e409..e795c4a 100644 --- a/nextcloud/9.0/run.sh +++ b/nextcloud/9.0/run.sh @@ -1,14 +1,10 @@ #!/bin/sh addgroup -g ${GID} nextcloud && adduser -h /nextcloud -s /bin/sh -D -G nextcloud -u ${UID} nextcloud -if [ -f /nextcloud/config/config.php ] && [ ! -f /config/config.php ]; then - mv /nextcloud/config/config.php /config/config.php -fi -ln -s /config/config.php /nextcloud/config/config.php - touch /var/run/php-fpm.sock mkdir /tmp/fastcgi /tmp/client_body chown -R nextcloud:nextcloud /nextcloud /data /config /apps2 /var/run/php-fpm.sock /var/lib/nginx /tmp +ln -s /config/config.php /nextcloud/config/config.php ln -s /apps2 /nextcloud supervisord -c /etc/supervisor/supervisord.conf diff --git a/nextcloud/daily/run.sh b/nextcloud/daily/run.sh index 703e409..e795c4a 100644 --- a/nextcloud/daily/run.sh +++ b/nextcloud/daily/run.sh @@ -1,14 +1,10 @@ #!/bin/sh addgroup -g ${GID} nextcloud && adduser -h /nextcloud -s /bin/sh -D -G nextcloud -u ${UID} nextcloud -if [ -f /nextcloud/config/config.php ] && [ ! -f /config/config.php ]; then - mv /nextcloud/config/config.php /config/config.php -fi -ln -s /config/config.php /nextcloud/config/config.php - touch /var/run/php-fpm.sock mkdir /tmp/fastcgi /tmp/client_body chown -R nextcloud:nextcloud /nextcloud /data /config /apps2 /var/run/php-fpm.sock /var/lib/nginx /tmp +ln -s /config/config.php /nextcloud/config/config.php ln -s /apps2 /nextcloud supervisord -c /etc/supervisor/supervisord.conf From 92eae2739b513aed1fd8ec96f0e6355d938a82fe Mon Sep 17 00:00:00 2001 From: kvaps <kvapss@gmail.com> Date: Tue, 16 Aug 2016 20:02:21 +0300 Subject: [PATCH 4/4] add: set default data directory --- nextcloud/10.0/run.sh | 5 +++++ nextcloud/9.0/run.sh | 5 +++++ nextcloud/daily/run.sh | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/nextcloud/10.0/run.sh b/nextcloud/10.0/run.sh index e795c4a..1bf4d50 100644 --- a/nextcloud/10.0/run.sh +++ b/nextcloud/10.0/run.sh @@ -1,6 +1,11 @@ #!/bin/sh addgroup -g ${GID} nextcloud && adduser -h /nextcloud -s /bin/sh -D -G nextcloud -u ${UID} nextcloud +# Set default data directory +if [ ! -f /config/config.php ]; then + echo -e "<?php\n\$CONFIG = array (\n 'datadirectory' => '/data',\n);" > /config/config.php +fi + touch /var/run/php-fpm.sock mkdir /tmp/fastcgi /tmp/client_body chown -R nextcloud:nextcloud /nextcloud /data /config /apps2 /var/run/php-fpm.sock /var/lib/nginx /tmp diff --git a/nextcloud/9.0/run.sh b/nextcloud/9.0/run.sh index e795c4a..1bf4d50 100644 --- a/nextcloud/9.0/run.sh +++ b/nextcloud/9.0/run.sh @@ -1,6 +1,11 @@ #!/bin/sh addgroup -g ${GID} nextcloud && adduser -h /nextcloud -s /bin/sh -D -G nextcloud -u ${UID} nextcloud +# Set default data directory +if [ ! -f /config/config.php ]; then + echo -e "<?php\n\$CONFIG = array (\n 'datadirectory' => '/data',\n);" > /config/config.php +fi + touch /var/run/php-fpm.sock mkdir /tmp/fastcgi /tmp/client_body chown -R nextcloud:nextcloud /nextcloud /data /config /apps2 /var/run/php-fpm.sock /var/lib/nginx /tmp diff --git a/nextcloud/daily/run.sh b/nextcloud/daily/run.sh index e795c4a..1bf4d50 100644 --- a/nextcloud/daily/run.sh +++ b/nextcloud/daily/run.sh @@ -1,6 +1,11 @@ #!/bin/sh addgroup -g ${GID} nextcloud && adduser -h /nextcloud -s /bin/sh -D -G nextcloud -u ${UID} nextcloud +# Set default data directory +if [ ! -f /config/config.php ]; then + echo -e "<?php\n\$CONFIG = array (\n 'datadirectory' => '/data',\n);" > /config/config.php +fi + touch /var/run/php-fpm.sock mkdir /tmp/fastcgi /tmp/client_body chown -R nextcloud:nextcloud /nextcloud /data /config /apps2 /var/run/php-fpm.sock /var/lib/nginx /tmp