Merge pull request #11353 from kvuorine/fwknop-fixes
[feed/packages.git] / net / etesync-server / files / 81_setup-etesync-server
1 #!/bin/sh
2
3 [ "${PKG_UPGRADE}" = "1" ] && /etc/init.d/etesync-server stop
4
5 cd /usr/share/etesync-server || exit 1
6
7 python3 manage.pyc migrate --noinput || exit 1
8
9 # setup minimal ini for collectstatic:
10 mkdir -p /var/etc/etesync-server/ || exit 1
11 printf "[global]\nSTATIC_ROOT=/www/etesync/static" >etesync-server.ini || exit 1
12 python3 manage.pyc collectstatic --noinput || exit 1
13
14 ETESYNC_HAS_USER_PY3CMD="import sqlite3
15 c = sqlite3.connect('db.sqlite3').cursor()
16 c.execute('select * from auth_user')
17 if c.fetchone()==None: print('0')
18 else: print('1')"
19
20 echo
21
22 if [ "$(python3 -c "$ETESYNC_HAS_USER_PY3CMD" || exit 1)" = "0" ]
23 then
24 echo "===== First, create a superuser of the Webinterface by ====="
25 [ -t 0 ] && python3 manage.pyc createsuperuser ||
26 echo "===== python3 $(pwd)/manage.pyc createsuperuser ====="
27 fi
28
29 chown -Rh etesync:nogroup . /www/etesync/ || exit 1
30
31 [ -x /etc/init.d/nginx ] || exit 1
32
33 /etc/init.d/nginx running && /etc/init.d/nginx reload || /etc/init.d/nginx start
34
35 router_ip() {
36 local ifstat="$(ifstatus "lan")"
37
38 for ip in $(echo "${ifstat}" | jsonfilter -e '@["ipv4-address"].*.address')
39 do echo "${ip}" && return
40 done
41
42 for ip in $(echo "${ifstat}" | jsonfilter -e '@["ipv6-address"].*.address')
43 do echo "[${ip}]" && return
44 done
45
46 for ip in $(echo "${ifstat}" | \
47 jsonfilter -e '@["ipv6-prefix-assignment"].*["local-address"].address')
48 do echo "[${ip}]" && return
49 done
50
51 echo '$ROUTER'
52 }
53
54 echo "===== You can add users by https://$(router_ip)/etesync/admin/login ====="
55
56 exit 0