mirror of
https://github.com/hoellen/docker-nextcloud.git
synced 2025-07-01 15:46:13 +00:00
add new image
This commit is contained in:
@ -1,2 +1,2 @@
|
||||
#!/bin/sh
|
||||
su-exec $UID:$GID php -d memory_limit=<MEMORY_LIMIT> -f /nextcloud/occ "$@"
|
||||
php -d memory_limit=<MEMORY_LIMIT> -f /nextcloud/occ "$@"
|
||||
|
@ -1,50 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
sed -i -e "s/<APC_SHM_SIZE>/$APC_SHM_SIZE/g" /php/conf.d/apcu.ini \
|
||||
-e "s/<OPCACHE_MEM_SIZE>/$OPCACHE_MEM_SIZE/g" /php/conf.d/opcache.ini \
|
||||
# Apply environment variables settings
|
||||
sed -i -e "s/<APC_SHM_SIZE>/$APC_SHM_SIZE/g" /usr/local/etc/php/conf.d/apcu.ini \
|
||||
-e "s/<OPCACHE_MEM_SIZE>/$OPCACHE_MEM_SIZE/g" /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini \
|
||||
-e "s/<CRON_MEMORY_LIMIT>/$CRON_MEMORY_LIMIT/g" /etc/s6.d/cron/run \
|
||||
-e "s/<CRON_PERIOD>/$CRON_PERIOD/g" /etc/s6.d/cron/run \
|
||||
-e "s/<MEMORY_LIMIT>/$MEMORY_LIMIT/g" /usr/local/bin/occ \
|
||||
-e "s/<UPLOAD_MAX_SIZE>/$UPLOAD_MAX_SIZE/g" /nginx/conf/nginx.conf /php/etc/php-fpm.conf \
|
||||
-e "s/<MEMORY_LIMIT>/$MEMORY_LIMIT/g" /php/etc/php-fpm.conf
|
||||
-e "s/<UPLOAD_MAX_SIZE>/$UPLOAD_MAX_SIZE/g" /etc/nginx/nginx.conf /usr/local/etc/php-fpm.conf \
|
||||
-e "s/<MEMORY_LIMIT>/$MEMORY_LIMIT/g" /usr/local/etc/php-fpm.conf
|
||||
|
||||
# Put the configuration and apps into volumes
|
||||
ln -sf /config/config.php /nextcloud/config/config.php &>/dev/null
|
||||
ln -sf /apps2 /nextcloud &>/dev/null
|
||||
chown -h $UID:$GID /nextcloud/config/config.php /nextcloud/apps2
|
||||
|
||||
# Create folder for php sessions if not exists
|
||||
if [ ! -d /data/session ]; then
|
||||
mkdir -p /data/session;
|
||||
fi
|
||||
|
||||
echo "Updating permissions..."
|
||||
for dir in /nextcloud /data /config /apps2 /var/log /php /nginx /tmp /etc/s6.d; do
|
||||
if $(find $dir ! -user $UID -o ! -group $GID|egrep '.' -q); then
|
||||
echo "Updating permissions in $dir..."
|
||||
chown -R $UID:$GID $dir
|
||||
else
|
||||
echo "Permissions in $dir are correct."
|
||||
fi
|
||||
done
|
||||
echo "Done updating permissions."
|
||||
|
||||
echo "Check for UserId ${UID}"
|
||||
grep ":${UID}:" /etc/passwd 1>/dev/null 2>&1
|
||||
ERRORCODE=$?
|
||||
|
||||
if [ $ERRORCODE -ne 0 ]; then
|
||||
echo "Creating user nextcloud with UID=${UID} and GID=${GID}"
|
||||
/usr/sbin/adduser -g ${GID} -u ${UID} --disabled-password --gecos "" nextcloud
|
||||
else
|
||||
echo "An existing user with UID=${UID} was found, nothing to do"
|
||||
fi
|
||||
|
||||
if [ ! -f /config/config.php ]; then
|
||||
# New installation, run the setup
|
||||
# If new install, run setup
|
||||
if [ ! -f /nextcloud/config/config.php ]; then
|
||||
touch /nextcloud/config/CAN_INSTALL
|
||||
/usr/local/bin/setup.sh
|
||||
else
|
||||
occ upgrade
|
||||
fi
|
||||
|
||||
exec su-exec $UID:$GID /bin/s6-svscan /etc/s6.d
|
||||
# Run processes
|
||||
exec /bin/s6-svscan /etc/s6.d
|
||||
|
@ -1,11 +1,6 @@
|
||||
#!/bin/sh
|
||||
# Nextcloud
|
||||
##########################
|
||||
|
||||
#source setup/functions.sh # load our functions
|
||||
#source /etc/mailinabox.conf # load global vars
|
||||
CONFIGFILE=/config/config.php
|
||||
|
||||
CONFIGFILE=/nextcloud/config/config.php
|
||||
|
||||
# Create an initial configuration file.
|
||||
instanceid=oc$(openssl rand -hex 6 | head -c 10)
|
||||
@ -13,7 +8,7 @@ instanceid=oc$(openssl rand -hex 6 | head -c 10)
|
||||
cat > $CONFIGFILE <<EOF;
|
||||
<?php
|
||||
\$CONFIG = array (
|
||||
'datadirectory' => '/data',
|
||||
'datadirectory' => '/nextcloud/data',
|
||||
|
||||
"apps_paths" => array (
|
||||
0 => array (
|
||||
@ -22,7 +17,7 @@ cat > $CONFIGFILE <<EOF;
|
||||
"writable" => false,
|
||||
),
|
||||
1 => array (
|
||||
"path" => "/apps2",
|
||||
"path" => "/nextcloud/apps2",
|
||||
"url" => "/apps2",
|
||||
"writable" => true,
|
||||
),
|
||||
@ -36,14 +31,12 @@ cat > $CONFIGFILE <<EOF;
|
||||
EOF
|
||||
|
||||
# Create an auto-configuration file to fill in database settings
|
||||
# when the install script is run. Make an administrator account
|
||||
# here or else the install can't finish.
|
||||
adminpassword=$(dd if=/dev/urandom bs=1 count=40 2>/dev/null | sha1sum | fold -w 30 | head -n 1)
|
||||
cat > /nextcloud/config/autoconfig.php <<EOF;
|
||||
<?php
|
||||
\$AUTOCONFIG = array (
|
||||
# storage/database
|
||||
'directory' => '/data',
|
||||
'directory' => '/nextcloud/data',
|
||||
'dbtype' => '${DB_TYPE:-sqlite3}',
|
||||
'dbname' => '${DB_NAME:-nextcloud}',
|
||||
'dbuser' => '${DB_USER:-nextcloud}',
|
||||
@ -53,8 +46,6 @@ cat > /nextcloud/config/autoconfig.php <<EOF;
|
||||
EOF
|
||||
if [[ ! -z "$ADMIN_USER" ]]; then
|
||||
cat >> /nextcloud/config/autoconfig.php <<EOF;
|
||||
# create an administrator account with a random password so that
|
||||
# the user does not have to enter anything on first load of ownCloud
|
||||
'adminlogin' => '${ADMIN_USER}',
|
||||
'adminpass' => '${ADMIN_PASSWORD}',
|
||||
EOF
|
||||
@ -65,26 +56,15 @@ cat >> /nextcloud/config/autoconfig.php <<EOF;
|
||||
EOF
|
||||
|
||||
echo "Starting automatic configuration..."
|
||||
# Execute ownCloud's setup step, which creates the ownCloud database.
|
||||
# It also wipes it if it exists. And it updates config.php with database
|
||||
# settings and deletes the autoconfig.php file.
|
||||
(cd /nextcloud; php index.php &>/dev/null)
|
||||
# Execute setup
|
||||
(cd /nextcloud; php index.php)
|
||||
echo "Automatic configuration finished."
|
||||
|
||||
# Update config.php.
|
||||
# * trusted_domains is reset to localhost by autoconfig starting with ownCloud 8.1.1,
|
||||
# so set it here. It also can change if the box's PRIMARY_HOSTNAME changes, so
|
||||
# this will make sure it has the right value.
|
||||
# * Some settings weren't included in previous versions of Mail-in-a-Box.
|
||||
# * We need to set the timezone to the system timezone to allow fail2ban to ban
|
||||
# users within the proper timeframe
|
||||
# * We need to set the logdateformat to something that will work correctly with fail2ban
|
||||
# Use PHP to read the settings file, modify it, and write out the new settings array.
|
||||
|
||||
# Update config.php
|
||||
CONFIG_TEMP=$(/bin/mktemp)
|
||||
php <<EOF > $CONFIG_TEMP && mv $CONFIG_TEMP $CONFIGFILE
|
||||
<?php
|
||||
include("/config/config.php");
|
||||
include($CONFIGFILE);
|
||||
|
||||
//\$CONFIG['memcache.local'] = '\\OC\\Memcache\\Memcached';
|
||||
\$CONFIG['mail_from_address'] = 'administrator'; # just the local part, matches our master administrator address
|
||||
@ -98,13 +78,9 @@ echo ";";
|
||||
?>
|
||||
EOF
|
||||
|
||||
sed -i "s/localhost/$DOMAIN/g" /config/config.php
|
||||
sed -i "s/localhost/$DOMAIN/g" $CONFIGFILE
|
||||
|
||||
chown -R $UID:$GID /config /data
|
||||
# Enable/disable apps. Note that this must be done after the ownCloud setup.
|
||||
# The firstrunwizard gave Josh all sorts of problems, so disabling that.
|
||||
# user_external is what allows ownCloud to use IMAP for login. The contacts
|
||||
# and calendar apps are the extensions we really care about here.
|
||||
# Setup is finished, no need for first run wizard
|
||||
if [[ ! -z "$ADMIN_USER" ]]; then
|
||||
occ app:disable firstrunwizard
|
||||
fi
|
||||
|
Reference in New Issue
Block a user