docker/owncloud/run.sh

51 lines
1.2 KiB
Bash
Raw Normal View History

2017-07-09 22:25:40 +00:00
#!/bin/bash
function first_run() {
echo FIRST RUN
2017-07-11 18:27:36 +00:00
mkdir -p /data/owncloud \
/data/owncloud/config \
/data/owncloud/data \
/data/nginx-log
2017-07-12 19:25:50 +00:00
cp -r /provision/owncloud/apps /data/owncloud
cp -r /provision/owncloud/config /data/owncloud
2017-07-11 18:27:36 +00:00
cp -r /var/lib/mysql /data
chown -R www-data:www-data /data/owncloud /var/www
chown -R mysql:mysql /data/mysql
2017-07-09 22:25:40 +00:00
SQL_ROOT_PASSWORD="$(pwgen -s -1 16)"
SQL_OWNCLOUD_PASSWORD="$(pwgen -s -1 16)"
mysqld_safe &
sleep 5
mysql -u root -e "
CREATE USER 'owncloud'@'localhost' IDENTIFIED BY '$SQL_OWNCLOUD_PASSWORD';
CREATE DATABASE owncloud;
GRANT ALL PRIVILEGES ON owncloud . * TO owncloud@localhost;
FLUSH PRIVILEGES;"
mysqladmin -u root password $SQL_ROOT_PASSWORD
cd /var/www
gosu www-data php occ maintenance:install \
--database "mysql" --database-name "owncloud" \
--database-user "owncloud" --database-pass "$SQL_OWNCLOUD_PASSWORD" \
--admin-user "admin" --admin-pass "password"
2017-07-16 20:20:09 +00:00
gosu www-data php occ background:cron
2017-07-09 22:25:40 +00:00
killall mysqld
touch /data/.provisioned
sleep 10
}
2017-07-11 21:23:38 +00:00
if [ ! -f "/data/.provisioned" ];
2017-07-09 22:25:40 +00:00
then
first_run
fi
supervisord -n -c /supervisord.conf