2018-09-20 22:30:40 -06:00

66 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
source /usr/local/etc/library.sh
set -e
[[ "$1" == "stop" ]] && {
echo "stopping Cron..."
killall cron
echo "stopping Redis..."
killall redis-server
echo "stopping Postfix..."
postfix stop
echo "stopping logs..."
killall tail
exit 0
}
# we want to work in the volume version of the code
rm /var/www/nextcloud
ln -s /data/app /var/www/nextcloud
echo "Provisioning"
DB_PID="$( pidof mysqld )"
bash /usr/local/bin/ncp-provisioning.sh
echo "Starting Redis"
mkdir -p /var/run/redis
chown redis /var/run/redis
sudo -u redis redis-server /etc/redis/redis.conf
echo "Starting Cron"
cron
echo "Starting Postfix"
postfix start
# INIT DATABASE AND NEXTCLOUD CONFIG (first run)
test -f /data/app/config/config.php || {
echo "Uninitialized instance, running nc-init..."
# mariaDB is restarted in the backgroud during provisioning
while kill -0 "$DB_PID" 2>/dev/null; do sleep 0.5; done
while :; do
[[ -S /run/mysqld/mysqld.sock ]] && break
sleep 0.5
done
source /usr/local/etc/library.sh
activate_script /nc-init.sh
mv /index.php /var/www/nextcloud/ # restore this file after init
}
# Trusted Domain ( local IP )
IFACE=$( ip r | grep "default via" | awk '{ print $5 }' | head -1 )
IP=$( ip a show dev "$IFACE" | grep global | grep -oP '\d{1,3}(.\d{1,3}){3}' | head -1 )
ncc config:system:set trusted_domains 1 --value="$IP"
# Trusted Domain ( as an argument )
[[ "$2" != "" ]] && \
ncc config:system:set trusted_domains 6 --value="$2"
# Display NC logs in the docker logs
tail -f -n0 /data/app/data/nextcloud.log &
exit 0