Welcome to mirror list, hosted at ThFree Co, Russian Federation.

020-nextcloud-run.sh « nextcloud « docker-armhf - github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 48076ad26fa97950810c3aa2b7f7d06b5b9bb6c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash

source /usr/local/etc/library.sh

set -e

NCDIR=/var/www/nextcloud
OCC="$NCDIR/occ"

[[ "$1" == "stop" ]] && {
  echo "stopping Cron..."
  killall cron
  echo "stopping Redis..."
  killall redis-server
  echo "stopping Postfix..."
  postfix stop
  exit 0
}

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..."
  source /usr/local/etc/library.sh
  cd     /usr/local/etc/
  activate_script nc-init.sh
}

# Trusted Domain ( local IP )
IFACE=$( ip r | grep "default via" | awk '{ print $5 }' )
IP=$( ip a | grep "global $IFACE" | grep -oP '\d{1,3}(\.\d{1,3}){3}' | head -1 )
sudo -u www-data php "$OCC" config:system:set trusted_domains 1 --value="$IP"

# Trusted Domain ( as an argument )
[[ "$@" != "" ]] && {
  IP=$( grep -oP '\d{1,3}(\.\d{1,3}){3}' <<< "$2" ) # validate that the first argument is a valid IP
  if [[ "$IP" != "" ]]; then
    sudo -u www-data php "$OCC" config:system:set trusted_domains 6 --value="$IP"
  else
    echo "First argument must be an IP address to include as a Trusted domain. Ignoring"
  fi
}

exit 0