Browse Source

added frontend; api; database

tags/v2.0.0^0
Robin Thoni 7 years ago
parent
commit
b97c588690

+ 6
- 0
.gitmodules View File

@@ -1,3 +1,9 @@
1 1
 [submodule "backend/backend"]
2 2
 	path = backend/backend
3 3
 	url = https://git.rthoni.com/camotion/backend
4
+[submodule "api/api"]
5
+	path = api/api
6
+	url = https://git.rthoni.com/camotion/camotion-api
7
+[submodule "frontend/frontend"]
8
+	path = frontend/frontend
9
+	url = https://git.rthoni.com/camotion/front

+ 56
- 0
api/Dockerfile View File

@@ -0,0 +1,56 @@
1
+FROM robinthoni/debian-multiarch:jessie
2
+
3
+# FROM https://github.com/ZHAJOR/Docker-Apache-2.4-Php-5.6-for-Laravel
4
+MAINTAINER Robin Thoni <robin@rthoni.com>
5
+
6
+ARG CONFIG_DIR=/etc/default/config-files/
7
+
8
+RUN apt-get update && apt-get -y install\
9
+        curl\
10
+        git\
11
+        apache2=2.4.*\
12
+        libapache2-mod-php5\
13
+        php5\
14
+        php5-mcrypt\
15
+        php5-pgsql\
16
+        php5-gd\
17
+        php5-curl &&\
18
+        apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
19
+
20
+RUN curl https://getcomposer.org/composer.phar -o /usr/local/bin/composer \
21
+        && chmod +x /usr/local/bin/composer
22
+
23
+RUN /usr/sbin/a2enmod rewrite &&\
24
+    rm -rf /var/www/html &&\
25
+    mkdir -p /var/lock/apache2 /var/run/apache2 /var/log/apache2 /var/www/html &&\
26
+    chown -R www-data:www-data /var/lock/apache2 /var/run/apache2 /var/log/apache2 /var/www/html
27
+
28
+RUN rm -rf /var/log/* &&\
29
+    mkdir -p /var/log/apache2 &&\
30
+    ln -s /dev/stderr /var/log/apache2/error.log &&\
31
+    ln -s /dev/stdout /var/log/apache2/access.log &&\
32
+    ln -s /dev/stdout /var/log/apache2/other_vhosts_access.log
33
+
34
+COPY apache2.conf /etc/apache2/apache2.conf
35
+
36
+COPY ./api/ /var/www/html/
37
+
38
+RUN cd /var/www/html && composer install
39
+
40
+RUN mkdir "${CONFIG_DIR}"
41
+
42
+COPY env "${CONFIG_DIR}"
43
+
44
+RUN chmod -R 777 /var/www/html/storage/
45
+
46
+COPY ./vars-vars /etc/vars-vars
47
+
48
+COPY ./vars-files /etc/vars-files
49
+
50
+COPY ./common.sh /common.sh
51
+
52
+COPY ./run.sh /run.sh
53
+
54
+EXPOSE 80
55
+
56
+CMD ["/run.sh"]

+ 60
- 0
api/apache2.conf View File

@@ -0,0 +1,60 @@
1
+# see http://sources.debian.net/src/apache2/2.4.10-1/debian/config-dir/apache2.conf
2
+
3
+ServerName poweradmin
4
+Mutex file:/var/lock/apache2 default
5
+PidFile /var/run/apache2/apache2.pid
6
+Timeout 300
7
+KeepAlive On
8
+MaxKeepAliveRequests 100
9
+KeepAliveTimeout 5
10
+User www-data
11
+Group www-data
12
+HostnameLookups Off
13
+ErrorLog /var/log/apache2/error.log
14
+LogLevel warn
15
+
16
+IncludeOptional mods-enabled/*.load
17
+IncludeOptional mods-enabled/*.conf
18
+
19
+# ports.conf
20
+Listen 80
21
+<IfModule ssl_module>
22
+    Listen 443
23
+</IfModule>
24
+<IfModule mod_gnutls.c>
25
+    Listen 443
26
+</IfModule>
27
+
28
+DocumentRoot "/var/www/html/public/"
29
+
30
+<Directory />
31
+    Options FollowSymLinks
32
+    AllowOverride None
33
+    Require all denied
34
+</Directory>
35
+
36
+<Directory /var/www/html/public/>
37
+    Options FollowSymLinks
38
+    AllowOverride All
39
+    Require all granted
40
+</Directory>
41
+
42
+
43
+
44
+LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
45
+LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
46
+LogFormat "%h %l %u %t \"%r\" %>s %O" common
47
+LogFormat "%{Referer}i -> %U" referer
48
+LogFormat "%{User-agent}i" agent
49
+
50
+CustomLog /var/log/apache2/access.log combined
51
+
52
+<FilesMatch \.php$>
53
+    SetHandler application/x-httpd-php
54
+</FilesMatch>
55
+
56
+# Multiple DirectoryIndex directives within the same context will add
57
+# to the list of resources to look for rather than replace
58
+# https://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex
59
+DirectoryIndex disabled
60
+DirectoryIndex index.php index.html

+ 1
- 0
api/api

@@ -0,0 +1 @@
1
+Subproject commit fd5e0bf4712ec4b71aa37103fcd4c51cf6d7c33f

+ 41
- 0
api/common.sh View File

@@ -0,0 +1,41 @@
1
+export CONFIG_DIR="/etc/default/config-files/"
2
+
3
+resolv_host()
4
+{
5
+  hostname="${1}"
6
+  ip=$(getent hosts "${hostname}" | cut -d' ' -f1)
7
+  echo "${ip}"
8
+}
9
+
10
+replace_var()
11
+{
12
+  file="${1}"
13
+  var="${2}"
14
+  sed -e "s?${var}?${!var}?g" -i "${file}"
15
+}
16
+
17
+replace_vars()
18
+{
19
+  file="${1}"
20
+  for var in $(cat /etc/vars-vars)
21
+  do
22
+    replace_var "${file}" "${var}"
23
+  done
24
+}
25
+
26
+replace_files()
27
+{
28
+  cat /etc/vars-files | while read line
29
+  do
30
+    filesrc="${CONFIG_DIR}$(echo "${line}" | awk '{print $1}')"
31
+    filedst=$(echo "${line}" | awk '{print $2}')
32
+    if [ -f "${filesrc}" ]
33
+    then
34
+      echo "Expanding file ${filesrc} to ${filedst}"
35
+      cp "${filesrc}" "${filedst}"
36
+      replace_vars "${filedst}"
37
+    else
38
+      echo "File ${filesrc} does not exist. Skipping."
39
+    fi
40
+  done
41
+}

+ 9
- 0
api/env View File

@@ -0,0 +1,9 @@
1
+DB_CONNECTION=pgsql
2
+DB_HOST=POSTGRES_HOST
3
+DB_PORT=5432
4
+DB_DATABASE=POSTGRES_DB
5
+DB_USERNAME=POSTGRES_USER
6
+DB_PASSWORD=POSTGRES_PASSWORD
7
+
8
+MCRYPT_KEY=CM_API_MCRYPT_KEY
9
+JWT_KEY=CM_API_JWT_KEY

+ 8
- 0
api/run.sh View File

@@ -0,0 +1,8 @@
1
+#! /usr/bin/env bash
2
+
3
+. /common.sh
4
+
5
+replace_files
6
+
7
+rm -f /run/apache2/apache2.pid
8
+exec /usr/sbin/apache2ctl -D FOREGROUND

+ 1
- 0
api/vars-files View File

@@ -0,0 +1 @@
1
+env /var/www/html/.env

+ 17
- 0
api/vars-vars View File

@@ -0,0 +1,17 @@
1
+POSTGRES_MASTER_MODE
2
+POSTGRES_HOST
3
+POSTGRES_USER
4
+POSTGRES_PASSWORD
5
+POSTGRES_DB
6
+POSTGRES_REP_USER
7
+POSTGRES_REP_PASSWORD
8
+POSTGRES_REP_ALLOWED_HOST
9
+POSTGRES_RO_USER
10
+POSTGRES_RO_PASSWORD
11
+
12
+CM_BACKEND_TOKEN
13
+
14
+CM_API_HOST
15
+CM_API_PORT
16
+CM_API_MCRYPT_KEY
17
+CM_API_JWT_KEY

+ 16
- 0
backend/vars-vars View File

@@ -1 +1,17 @@
1
+POSTGRES_MASTER_MODE
2
+POSTGRES_HOST
3
+POSTGRES_USER
4
+POSTGRES_PASSWORD
5
+POSTGRES_DB
6
+POSTGRES_REP_USER
7
+POSTGRES_REP_PASSWORD
8
+POSTGRES_REP_ALLOWED_HOST
9
+POSTGRES_RO_USER
10
+POSTGRES_RO_PASSWORD
11
+
1 12
 CM_BACKEND_TOKEN
13
+
14
+CM_API_HOST
15
+CM_API_PORT
16
+CM_API_MCRYPT_KEY
17
+CM_API_JWT_KEY

+ 65
- 0
docker-compose.base.yml View File

@@ -0,0 +1,65 @@
1
+version: '2'
2
+
3
+services:
4
+    database:
5
+        build: ./postgresql
6
+        container_name: camotion-postgresql
7
+#        restart: unless-stopped
8
+        networks:
9
+            camotion.internal.docker:
10
+                aliases:
11
+                    - postgresql.camotion.internal.docker
12
+        volumes:
13
+            - ./data/postgresql/data:/var/lib/postgresql/data
14
+            - ./data/postgresql/backup:/var/lib/postgresql/backup
15
+        ports:
16
+            - "127.0.0.1:35000:5432"
17
+        env_file:
18
+            - env
19
+
20
+    backend:
21
+        build:
22
+            context: ./backend
23
+            args:
24
+                SPI_USER_UID: 999
25
+        container_name: camotion-backend
26
+#        restart: unless-stopped
27
+#        devices:
28
+#            - "/dev/spidev0.0:/dev/spidev0.0"
29
+        networks:
30
+            camotion.internal.docker:
31
+                aliases:
32
+                    - backend.camotion.internal.docker
33
+        ports:
34
+            - "127.0.0.1:35001:80"
35
+        env_file:
36
+            - env
37
+
38
+    frontend:
39
+        build: ./frontend
40
+        container_name: camotion-frontend
41
+#        restart: unless-stopped
42
+        networks:
43
+            camotion.internal.docker:
44
+                aliases:
45
+                    - frontend.camotion.internal.docker
46
+        ports:
47
+            - "127.0.0.1:35002:80"
48
+        env_file:
49
+            - env
50
+
51
+    api:
52
+        build: ./api
53
+        container_name: camotion-api
54
+#        restart: unless-stopped
55
+        networks:
56
+            camotion.internal.docker:
57
+                aliases:
58
+                    - api.camotion.internal.docker
59
+        ports:
60
+            - "127.0.0.1:35003:80"
61
+        env_file:
62
+            - env
63
+
64
+networks:
65
+    camotion.internal.docker:

+ 16
- 0
env View File

@@ -1 +1,17 @@
1
+POSTGRES_MASTER_MODE=1
2
+POSTGRES_HOST=postgresql.camotion.internal.docker
3
+POSTGRES_USER=camotion
4
+POSTGRES_PASSWORD=change_it
5
+POSTGRES_DB=camotion
6
+POSTGRES_REP_USER=replicator
7
+POSTGRES_REP_PASSWORD=change_it
8
+POSTGRES_REP_ALLOWED_HOST=127.0.0.1/32
9
+POSTGRES_RO_USER=camotion_ro
10
+POSTGRES_RO_PASSWORD=change_it
11
+
1 12
 CM_BACKEND_TOKEN=change_it
13
+
14
+CM_API_HOST=api.camotion.internal.docker
15
+CM_API_PORT=80
16
+CM_API_MCRYPT_KEY=ffffffffffffffffffffffff
17
+CM_API_JWT_KEY=ffffffffffffffffffffffffffffffffffffffff

+ 41
- 0
frontend/Dockerfile View File

@@ -0,0 +1,41 @@
1
+FROM robinthoni/debian-multiarch:jessie
2
+
3
+ARG CONFIG_DIR=/etc/default/config-files/
4
+
5
+# FROM https://github.com/ZHAJOR/Docker-Apache-2.4-Php-5.6-for-Laravel
6
+MAINTAINER Robin Thoni <robin@rthoni.com>
7
+
8
+RUN apt-get update && apt-get -y install\
9
+        apache2=2.4.* &&\
10
+        apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
11
+
12
+RUN /usr/sbin/a2enmod rewrite &&\
13
+    rm -rf /var/www/html &&\
14
+    mkdir -p /var/lock/apache2 /var/run/apache2 /var/log/apache2 /var/www/html &&\
15
+    chown -R www-data:www-data /var/lock/apache2 /var/run/apache2 /var/log/apache2 /var/www/html
16
+
17
+RUN rm -rf /var/log/* &&\
18
+    mkdir -p /var/log/apache2 &&\
19
+    ln -s /dev/stderr /var/log/apache2/error.log &&\
20
+    ln -s /dev/stdout /var/log/apache2/access.log &&\
21
+    ln -s /dev/stdout /var/log/apache2/other_vhosts_access.log
22
+
23
+RUN a2enmod proxy_http
24
+
25
+RUN mkdir "${CONFIG_DIR}"
26
+
27
+COPY apache2.conf "${CONFIG_DIR}"/apache2.conf
28
+
29
+COPY ./frontend/ /var/www/html/
30
+
31
+COPY ./vars-vars /etc/vars-vars
32
+
33
+COPY ./vars-files /etc/vars-files
34
+
35
+COPY ./common.sh /common.sh
36
+
37
+COPY ./run.sh /run.sh
38
+
39
+EXPOSE 80
40
+
41
+CMD ["/run.sh"]

+ 63
- 0
frontend/apache2.conf View File

@@ -0,0 +1,63 @@
1
+# see http://sources.debian.net/src/apache2/2.4.10-1/debian/config-dir/apache2.conf
2
+
3
+ServerName poweradmin
4
+Mutex file:/var/lock/apache2 default
5
+PidFile /var/run/apache2/apache2.pid
6
+Timeout 300
7
+KeepAlive On
8
+MaxKeepAliveRequests 100
9
+KeepAliveTimeout 5
10
+User www-data
11
+Group www-data
12
+HostnameLookups Off
13
+ErrorLog /var/log/apache2/error.log
14
+LogLevel warn
15
+
16
+IncludeOptional mods-enabled/*.load
17
+IncludeOptional mods-enabled/*.conf
18
+
19
+# ports.conf
20
+Listen 80
21
+<IfModule ssl_module>
22
+    Listen 443
23
+</IfModule>
24
+<IfModule mod_gnutls.c>
25
+    Listen 443
26
+</IfModule>
27
+
28
+DocumentRoot "/var/www/html/"
29
+
30
+<Directory />
31
+    Options FollowSymLinks
32
+    AllowOverride None
33
+    Require all denied
34
+</Directory>
35
+
36
+<Directory /var/www/html/>
37
+    Options FollowSymLinks
38
+    AllowOverride All
39
+    Require all granted
40
+</Directory>
41
+
42
+<Location "/api/">
43
+  ProxyPass http://CM_API_HOST:CM_API_PORT/ retry=0
44
+  ProxyPassReverse http://CM_API_HOST:CM_API_PORT/
45
+</Location>
46
+
47
+LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
48
+LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
49
+LogFormat "%h %l %u %t \"%r\" %>s %O" common
50
+LogFormat "%{Referer}i -> %U" referer
51
+LogFormat "%{User-agent}i" agent
52
+
53
+CustomLog /var/log/apache2/access.log combined
54
+
55
+<FilesMatch \.php$>
56
+    SetHandler application/x-httpd-php
57
+</FilesMatch>
58
+
59
+# Multiple DirectoryIndex directives within the same context will add
60
+# to the list of resources to look for rather than replace
61
+# https://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex
62
+DirectoryIndex disabled
63
+DirectoryIndex index.php index.html

+ 41
- 0
frontend/common.sh View File

@@ -0,0 +1,41 @@
1
+export CONFIG_DIR="/etc/default/config-files/"
2
+
3
+resolv_host()
4
+{
5
+  hostname="${1}"
6
+  ip=$(getent hosts "${hostname}" | cut -d' ' -f1)
7
+  echo "${ip}"
8
+}
9
+
10
+replace_var()
11
+{
12
+  file="${1}"
13
+  var="${2}"
14
+  sed -e "s?${var}?${!var}?g" -i "${file}"
15
+}
16
+
17
+replace_vars()
18
+{
19
+  file="${1}"
20
+  for var in $(cat /etc/vars-vars)
21
+  do
22
+    replace_var "${file}" "${var}"
23
+  done
24
+}
25
+
26
+replace_files()
27
+{
28
+  cat /etc/vars-files | while read line
29
+  do
30
+    filesrc="${CONFIG_DIR}$(echo "${line}" | awk '{print $1}')"
31
+    filedst=$(echo "${line}" | awk '{print $2}')
32
+    if [ -f "${filesrc}" ]
33
+    then
34
+      echo "Expanding file ${filesrc} to ${filedst}"
35
+      cp "${filesrc}" "${filedst}"
36
+      replace_vars "${filedst}"
37
+    else
38
+      echo "File ${filesrc} does not exist. Skipping."
39
+    fi
40
+  done
41
+}

+ 1
- 0
frontend/frontend

@@ -0,0 +1 @@
1
+Subproject commit fcf571cd2e94138346372b149a6b09eef8258be0

+ 8
- 0
frontend/run.sh View File

@@ -0,0 +1,8 @@
1
+#! /usr/bin/env bash
2
+
3
+. /common.sh
4
+
5
+replace_files
6
+
7
+rm -f /run/apache2/apache2.pid
8
+exec /usr/sbin/apache2ctl -D FOREGROUND

+ 1
- 0
frontend/vars-files View File

@@ -0,0 +1 @@
1
+apache2.conf /etc/apache2/apache2.conf

+ 17
- 0
frontend/vars-vars View File

@@ -0,0 +1,17 @@
1
+POSTGRES_MASTER_MODE
2
+POSTGRES_HOST
3
+POSTGRES_USER
4
+POSTGRES_PASSWORD
5
+POSTGRES_DB
6
+POSTGRES_REP_USER
7
+POSTGRES_REP_PASSWORD
8
+POSTGRES_REP_ALLOWED_HOST
9
+POSTGRES_RO_USER
10
+POSTGRES_RO_PASSWORD
11
+
12
+CM_BACKEND_TOKEN
13
+
14
+CM_API_HOST
15
+CM_API_PORT
16
+CM_API_MCRYPT_KEY
17
+CM_API_JWT_KEY

+ 5
- 0
postgresql/Dockerfile View File

@@ -0,0 +1,5 @@
1
+FROM robinthoni/postgres-backup:9.6
2
+
3
+RUN rm -rf /var/log/*
4
+
5
+COPY ./docker-entrypoint-initdb.d/ /docker-entrypoint-initdb.d

+ 692
- 0
postgresql/docker-entrypoint-initdb.d/0.1.0_01_struct_init.sql View File

@@ -0,0 +1,692 @@
1
+--
2
+-- PostgreSQL database dump
3
+--
4
+--
5
+-- Name: camera_types; Type: TABLE; Schema: public; Owner: dev; Tablespace: 
6
+--
7
+
8
+CREATE TABLE camera_types (
9
+    id integer NOT NULL,
10
+    name character varying(128) NOT NULL,
11
+    class character varying(128) NOT NULL,
12
+    default_data text NOT NULL
13
+);
14
+
15
+
16
+--
17
+-- Name: camera_types_id_seq; Type: SEQUENCE; Schema: public; Owner: dev
18
+--
19
+
20
+CREATE SEQUENCE camera_types_id_seq
21
+    START WITH 1
22
+    INCREMENT BY 1
23
+    NO MINVALUE
24
+    NO MAXVALUE
25
+    CACHE 1;
26
+
27
+
28
+--
29
+-- Name: camera_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dev
30
+--
31
+
32
+ALTER SEQUENCE camera_types_id_seq OWNED BY camera_types.id;
33
+
34
+
35
+--
36
+-- Name: cameras; Type: TABLE; Schema: public; Owner: dev; Tablespace: 
37
+--
38
+
39
+CREATE TABLE cameras (
40
+    id integer NOT NULL,
41
+    name character varying(128) NOT NULL,
42
+    description character varying(256) NOT NULL,
43
+    host_id integer NOT NULL,
44
+    camera_type_id integer NOT NULL,
45
+    data text NOT NULL
46
+);
47
+
48
+
49
+--
50
+-- Name: cameras_id_seq; Type: SEQUENCE; Schema: public; Owner: dev
51
+--
52
+
53
+CREATE SEQUENCE cameras_id_seq
54
+    START WITH 1
55
+    INCREMENT BY 1
56
+    NO MINVALUE
57
+    NO MAXVALUE
58
+    CACHE 1;
59
+
60
+
61
+--
62
+-- Name: cameras_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dev
63
+--
64
+
65
+ALTER SEQUENCE cameras_id_seq OWNED BY cameras.id;
66
+
67
+
68
+--
69
+-- Name: command_types; Type: TABLE; Schema: public; Owner: dev; Tablespace: 
70
+--
71
+
72
+CREATE TABLE command_types (
73
+    id integer NOT NULL,
74
+    name character varying(128) NOT NULL,
75
+    class character varying(128) NOT NULL,
76
+    default_data text NOT NULL
77
+);
78
+
79
+
80
+--
81
+-- Name: command_types_id_seq; Type: SEQUENCE; Schema: public; Owner: dev
82
+--
83
+
84
+CREATE SEQUENCE command_types_id_seq
85
+    START WITH 1
86
+    INCREMENT BY 1
87
+    NO MINVALUE
88
+    NO MAXVALUE
89
+    CACHE 1;
90
+
91
+
92
+--
93
+-- Name: command_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dev
94
+--
95
+
96
+ALTER SEQUENCE command_types_id_seq OWNED BY command_types.id;
97
+
98
+
99
+--
100
+-- Name: commands; Type: TABLE; Schema: public; Owner: dev; Tablespace: 
101
+--
102
+
103
+CREATE TABLE commands (
104
+    id integer NOT NULL,
105
+    name character varying(128) NOT NULL,
106
+    description character varying(256) NOT NULL,
107
+    host_id integer NOT NULL,
108
+    command_type_id integer NOT NULL,
109
+    data text NOT NULL
110
+);
111
+
112
+
113
+--
114
+-- Name: commands_id_seq; Type: SEQUENCE; Schema: public; Owner: dev
115
+--
116
+
117
+CREATE SEQUENCE commands_id_seq
118
+    START WITH 1
119
+    INCREMENT BY 1
120
+    NO MINVALUE
121
+    NO MAXVALUE
122
+    CACHE 1;
123
+
124
+
125
+--
126
+-- Name: commands_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dev
127
+--
128
+
129
+ALTER SEQUENCE commands_id_seq OWNED BY commands.id;
130
+
131
+
132
+--
133
+-- Name: hosts; Type: TABLE; Schema: public; Owner: dev; Tablespace: 
134
+--
135
+
136
+CREATE TABLE hosts (
137
+    id integer NOT NULL,
138
+    name character varying(128) NOT NULL,
139
+    url character varying(256) NOT NULL,
140
+    token character varying(128) NOT NULL
141
+);
142
+
143
+
144
+--
145
+-- Name: hosts_id_seq; Type: SEQUENCE; Schema: public; Owner: dev
146
+--
147
+
148
+CREATE SEQUENCE hosts_id_seq
149
+    START WITH 1
150
+    INCREMENT BY 1
151
+    NO MINVALUE
152
+    NO MAXVALUE
153
+    CACHE 1;
154
+
155
+
156
+--
157
+-- Name: hosts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dev
158
+--
159
+
160
+ALTER SEQUENCE hosts_id_seq OWNED BY hosts.id;
161
+
162
+
163
+--
164
+-- Name: luticate_groups_id_seq; Type: SEQUENCE; Schema: public; Owner: dev
165
+--
166
+
167
+CREATE SEQUENCE luticate_groups_id_seq
168
+    START WITH 1
169
+    INCREMENT BY 1
170
+    NO MINVALUE
171
+    NO MAXVALUE
172
+    CACHE 1;
173
+
174
+
175
+--
176
+-- Name: luticate_groups; Type: TABLE; Schema: public; Owner: dev; Tablespace: 
177
+--
178
+
179
+CREATE TABLE luticate_groups (
180
+    id integer DEFAULT nextval('luticate_groups_id_seq'::regclass) NOT NULL,
181
+    name character varying NOT NULL
182
+);
183
+
184
+
185
+--
186
+-- Name: luticate_permissions; Type: TABLE; Schema: public; Owner: dev; Tablespace: 
187
+--
188
+
189
+CREATE TABLE luticate_permissions (
190
+    name character varying(128) NOT NULL,
191
+    value boolean NOT NULL
192
+);
193
+
194
+
195
+--
196
+-- Name: luticate_permissions_groups; Type: TABLE; Schema: public; Owner: dev; Tablespace: 
197
+--
198
+
199
+CREATE TABLE luticate_permissions_groups (
200
+    name character varying(128) NOT NULL,
201
+    value boolean NOT NULL,
202
+    group_id integer NOT NULL
203
+);
204
+
205
+
206
+--
207
+-- Name: luticate_permissions_users; Type: TABLE; Schema: public; Owner: dev; Tablespace: 
208
+--
209
+
210
+CREATE TABLE luticate_permissions_users (
211
+    name character varying(128) NOT NULL,
212
+    value boolean,
213
+    user_id integer NOT NULL
214
+);
215
+
216
+
217
+--
218
+-- Name: luticate_users_id_seq; Type: SEQUENCE; Schema: public; Owner: dev
219
+--
220
+
221
+CREATE SEQUENCE luticate_users_id_seq
222
+    START WITH 1
223
+    INCREMENT BY 1
224
+    NO MINVALUE
225
+    NO MAXVALUE
226
+    CACHE 1;
227
+
228
+
229
+--
230
+-- Name: luticate_users; Type: TABLE; Schema: public; Owner: dev; Tablespace: 
231
+--
232
+
233
+CREATE TABLE luticate_users (
234
+    id integer DEFAULT nextval('luticate_users_id_seq'::regclass) NOT NULL,
235
+    username character varying(255) NOT NULL,
236
+    email character varying(255) NOT NULL,
237
+    password character varying(255) NOT NULL,
238
+    salt character varying(10) NOT NULL,
239
+    profile_id integer,
240
+    firstname character varying(255) NOT NULL,
241
+    lastname character varying(255) NOT NULL
242
+);
243
+
244
+
245
+--
246
+-- Name: luticate_users_groups; Type: TABLE; Schema: public; Owner: dev; Tablespace: 
247
+--
248
+
249
+CREATE TABLE luticate_users_groups (
250
+    user_id integer NOT NULL,
251
+    group_id integer NOT NULL
252
+);
253
+
254
+
255
+--
256
+-- Name: sensor_types; Type: TABLE; Schema: public; Owner: dev; Tablespace: 
257
+--
258
+
259
+CREATE TABLE sensor_types (
260
+    id integer NOT NULL,
261
+    name character varying(128) NOT NULL,
262
+    class character varying(128) NOT NULL,
263
+    default_data text NOT NULL
264
+);
265
+
266
+
267
+--
268
+-- Name: sensor_types_id_seq; Type: SEQUENCE; Schema: public; Owner: dev
269
+--
270
+
271
+CREATE SEQUENCE sensor_types_id_seq
272
+    START WITH 1
273
+    INCREMENT BY 1
274
+    NO MINVALUE
275
+    NO MAXVALUE
276
+    CACHE 1;
277
+
278
+
279
+--
280
+-- Name: sensor_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dev
281
+--
282
+
283
+ALTER SEQUENCE sensor_types_id_seq OWNED BY sensor_types.id;
284
+
285
+
286
+--
287
+-- Name: sensors; Type: TABLE; Schema: public; Owner: dev; Tablespace: 
288
+--
289
+
290
+CREATE TABLE sensors (
291
+    id integer NOT NULL,
292
+    name character varying(128) NOT NULL,
293
+    description character varying(256) NOT NULL,
294
+    host_id integer NOT NULL,
295
+    sensor_type_id integer NOT NULL,
296
+    data text NOT NULL
297
+);
298
+
299
+
300
+--
301
+-- Name: sensors_id_seq; Type: SEQUENCE; Schema: public; Owner: dev
302
+--
303
+
304
+CREATE SEQUENCE sensors_id_seq
305
+    START WITH 1
306
+    INCREMENT BY 1
307
+    NO MINVALUE
308
+    NO MAXVALUE
309
+    CACHE 1;
310
+
311
+
312
+--
313
+-- Name: sensors_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: dev
314
+--
315
+
316
+ALTER SEQUENCE sensors_id_seq OWNED BY sensors.id;
317
+
318
+
319
+--
320
+-- Name: id; Type: DEFAULT; Schema: public; Owner: dev
321
+--
322
+
323
+ALTER TABLE ONLY camera_types ALTER COLUMN id SET DEFAULT nextval('camera_types_id_seq'::regclass);
324
+
325
+
326
+--
327
+-- Name: id; Type: DEFAULT; Schema: public; Owner: dev
328
+--
329
+
330
+ALTER TABLE ONLY cameras ALTER COLUMN id SET DEFAULT nextval('cameras_id_seq'::regclass);
331
+
332
+
333
+--
334
+-- Name: id; Type: DEFAULT; Schema: public; Owner: dev
335
+--
336
+
337
+ALTER TABLE ONLY command_types ALTER COLUMN id SET DEFAULT nextval('command_types_id_seq'::regclass);
338
+
339
+
340
+--
341
+-- Name: id; Type: DEFAULT; Schema: public; Owner: dev
342
+--
343
+
344
+ALTER TABLE ONLY commands ALTER COLUMN id SET DEFAULT nextval('commands_id_seq'::regclass);
345
+
346
+
347
+--
348
+-- Name: id; Type: DEFAULT; Schema: public; Owner: dev
349
+--
350
+
351
+ALTER TABLE ONLY hosts ALTER COLUMN id SET DEFAULT nextval('hosts_id_seq'::regclass);
352
+
353
+
354
+--
355
+-- Name: id; Type: DEFAULT; Schema: public; Owner: dev
356
+--
357
+
358
+ALTER TABLE ONLY sensor_types ALTER COLUMN id SET DEFAULT nextval('sensor_types_id_seq'::regclass);
359
+
360
+
361
+--
362
+-- Name: id; Type: DEFAULT; Schema: public; Owner: dev
363
+--
364
+
365
+ALTER TABLE ONLY sensors ALTER COLUMN id SET DEFAULT nextval('sensors_id_seq'::regclass);
366
+
367
+
368
+--
369
+-- Name: camera_types_name_key; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
370
+--
371
+
372
+ALTER TABLE ONLY camera_types
373
+    ADD CONSTRAINT camera_types_name_key UNIQUE (name);
374
+
375
+
376
+--
377
+-- Name: camera_types_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
378
+--
379
+
380
+ALTER TABLE ONLY camera_types
381
+    ADD CONSTRAINT camera_types_pkey PRIMARY KEY (id);
382
+
383
+
384
+--
385
+-- Name: cameras_name_key; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
386
+--
387
+
388
+ALTER TABLE ONLY cameras
389
+    ADD CONSTRAINT cameras_name_key UNIQUE (name);
390
+
391
+
392
+--
393
+-- Name: cameras_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
394
+--
395
+
396
+ALTER TABLE ONLY cameras
397
+    ADD CONSTRAINT cameras_pkey PRIMARY KEY (id);
398
+
399
+
400
+--
401
+-- Name: command_types_name_key; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
402
+--
403
+
404
+ALTER TABLE ONLY command_types
405
+    ADD CONSTRAINT command_types_name_key UNIQUE (name);
406
+
407
+
408
+--
409
+-- Name: command_types_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
410
+--
411
+
412
+ALTER TABLE ONLY command_types
413
+    ADD CONSTRAINT command_types_pkey PRIMARY KEY (id);
414
+
415
+
416
+--
417
+-- Name: commands_name_key; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
418
+--
419
+
420
+ALTER TABLE ONLY commands
421
+    ADD CONSTRAINT commands_name_key UNIQUE (name);
422
+
423
+
424
+--
425
+-- Name: commands_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
426
+--
427
+
428
+ALTER TABLE ONLY commands
429
+    ADD CONSTRAINT commands_pkey PRIMARY KEY (id);
430
+
431
+
432
+--
433
+-- Name: hosts_name_key; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
434
+--
435
+
436
+ALTER TABLE ONLY hosts
437
+    ADD CONSTRAINT hosts_name_key UNIQUE (name);
438
+
439
+
440
+--
441
+-- Name: hosts_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
442
+--
443
+
444
+ALTER TABLE ONLY hosts
445
+    ADD CONSTRAINT hosts_pkey PRIMARY KEY (id);
446
+
447
+
448
+--
449
+-- Name: luticate_groups_name_key; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
450
+--
451
+
452
+ALTER TABLE ONLY luticate_groups
453
+    ADD CONSTRAINT luticate_groups_name_key UNIQUE (name);
454
+
455
+
456
+--
457
+-- Name: luticate_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
458
+--
459
+
460
+ALTER TABLE ONLY luticate_groups
461
+    ADD CONSTRAINT luticate_groups_pkey PRIMARY KEY (id);
462
+
463
+
464
+--
465
+-- Name: luticate_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
466
+--
467
+
468
+ALTER TABLE ONLY luticate_permissions
469
+    ADD CONSTRAINT luticate_permissions_pkey PRIMARY KEY (name);
470
+
471
+
472
+--
473
+-- Name: luticate_permissions_users_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
474
+--
475
+
476
+ALTER TABLE ONLY luticate_permissions_users
477
+    ADD CONSTRAINT luticate_permissions_users_pkey PRIMARY KEY (name, user_id);
478
+
479
+
480
+--
481
+-- Name: luticate_users_email_key; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
482
+--
483
+
484
+ALTER TABLE ONLY luticate_users
485
+    ADD CONSTRAINT luticate_users_email_key UNIQUE (email);
486
+
487
+
488
+--
489
+-- Name: luticate_users_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
490
+--
491
+
492
+ALTER TABLE ONLY luticate_users_groups
493
+    ADD CONSTRAINT luticate_users_groups_pkey PRIMARY KEY (user_id, group_id);
494
+
495
+
496
+--
497
+-- Name: luticate_users_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
498
+--
499
+
500
+ALTER TABLE ONLY luticate_users
501
+    ADD CONSTRAINT luticate_users_pkey PRIMARY KEY (id);
502
+
503
+
504
+--
505
+-- Name: luticate_users_username_key; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
506
+--
507
+
508
+ALTER TABLE ONLY luticate_users
509
+    ADD CONSTRAINT luticate_users_username_key UNIQUE (username);
510
+
511
+
512
+--
513
+-- Name: pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
514
+--
515
+
516
+ALTER TABLE ONLY luticate_permissions_groups
517
+    ADD CONSTRAINT pkey PRIMARY KEY (name, group_id);
518
+
519
+
520
+--
521
+-- Name: sensor_types_name_key; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
522
+--
523
+
524
+ALTER TABLE ONLY sensor_types
525
+    ADD CONSTRAINT sensor_types_name_key UNIQUE (name);
526
+
527
+
528
+--
529
+-- Name: sensor_types_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
530
+--
531
+
532
+ALTER TABLE ONLY sensor_types
533
+    ADD CONSTRAINT sensor_types_pkey PRIMARY KEY (id);
534
+
535
+
536
+--
537
+-- Name: sensors_name_key; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
538
+--
539
+
540
+ALTER TABLE ONLY sensors
541
+    ADD CONSTRAINT sensors_name_key UNIQUE (name);
542
+
543
+
544
+--
545
+-- Name: sensors_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace: 
546
+--
547
+
548
+ALTER TABLE ONLY sensors
549
+    ADD CONSTRAINT sensors_pkey PRIMARY KEY (id);
550
+
551
+
552
+--
553
+-- Name: cameras_camera_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: dev
554
+--
555
+
556
+ALTER TABLE ONLY cameras
557
+    ADD CONSTRAINT cameras_camera_type_id_fkey FOREIGN KEY (camera_type_id) REFERENCES camera_types(id);
558
+
559
+
560
+--
561
+-- Name: cameras_host_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: dev
562
+--
563
+
564
+ALTER TABLE ONLY cameras
565
+    ADD CONSTRAINT cameras_host_id_fkey FOREIGN KEY (host_id) REFERENCES hosts(id) ON DELETE CASCADE;
566
+
567
+
568
+--
569
+-- Name: commands_command_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: dev
570
+--
571
+
572
+ALTER TABLE ONLY commands
573
+    ADD CONSTRAINT commands_command_type_id_fkey FOREIGN KEY (command_type_id) REFERENCES command_types(id) ON DELETE CASCADE;
574
+
575
+
576
+--
577
+-- Name: commands_host_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: dev
578
+--
579
+
580
+ALTER TABLE ONLY commands
581
+    ADD CONSTRAINT commands_host_id_fkey FOREIGN KEY (host_id) REFERENCES hosts(id) ON DELETE CASCADE;
582
+
583
+
584
+--
585
+-- Name: foreign_group; Type: FK CONSTRAINT; Schema: public; Owner: dev
586
+--
587
+
588
+ALTER TABLE ONLY luticate_permissions_groups
589
+    ADD CONSTRAINT foreign_group FOREIGN KEY (group_id) REFERENCES luticate_groups(id) ON DELETE CASCADE;
590
+
591
+
592
+--
593
+-- Name: foreign_group; Type: FK CONSTRAINT; Schema: public; Owner: dev
594
+--
595
+
596
+ALTER TABLE ONLY luticate_users_groups
597
+    ADD CONSTRAINT foreign_group FOREIGN KEY (group_id) REFERENCES luticate_groups(id) ON DELETE CASCADE;
598
+
599
+
600
+--
601
+-- Name: foreign_name; Type: FK CONSTRAINT; Schema: public; Owner: dev
602
+--
603
+
604
+ALTER TABLE ONLY luticate_permissions_groups
605
+    ADD CONSTRAINT foreign_name FOREIGN KEY (name) REFERENCES luticate_permissions(name) ON DELETE CASCADE;
606
+
607
+
608
+--
609
+-- Name: foreign_name; Type: FK CONSTRAINT; Schema: public; Owner: dev
610
+--
611
+
612
+ALTER TABLE ONLY luticate_permissions_users
613
+    ADD CONSTRAINT foreign_name FOREIGN KEY (name) REFERENCES luticate_permissions(name) ON DELETE CASCADE;
614
+
615
+
616
+--
617
+-- Name: foreign_user; Type: FK CONSTRAINT; Schema: public; Owner: dev
618
+--
619
+
620
+ALTER TABLE ONLY luticate_permissions_users
621
+    ADD CONSTRAINT foreign_user FOREIGN KEY (user_id) REFERENCES luticate_users(id) ON DELETE CASCADE;
622
+
623
+
624
+--
625
+-- Name: foreign_user; Type: FK CONSTRAINT; Schema: public; Owner: dev
626
+--
627
+
628
+ALTER TABLE ONLY luticate_users_groups
629
+    ADD CONSTRAINT foreign_user FOREIGN KEY (user_id) REFERENCES luticate_users(id) ON DELETE CASCADE;
630
+
631
+
632
+--
633
+-- Name: sensors_host_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: dev
634
+--
635
+
636
+ALTER TABLE ONLY sensors
637
+    ADD CONSTRAINT sensors_host_id_fkey FOREIGN KEY (host_id) REFERENCES hosts(id) ON DELETE CASCADE;
638
+
639
+
640
+--
641
+-- Name: sensors_sensor_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: dev
642
+--
643
+
644
+ALTER TABLE ONLY sensors
645
+    ADD CONSTRAINT sensors_sensor_type_id_fkey FOREIGN KEY (sensor_type_id) REFERENCES sensor_types(id) ON DELETE CASCADE;
646
+
647
+--
648
+-- Name: sp_lu_get_user_permission(integer, character varying); Type: FUNCTION; Schema: public; Owner: dev
649
+--
650
+
651
+CREATE FUNCTION sp_lu_get_user_permission(_user_id integer, _permisson_name character varying, OUT val boolean) RETURNS boolean
652
+LANGUAGE plpgsql IMMUTABLE SECURITY DEFINER COST 10
653
+AS $$
654
+DECLARE
655
+    groups int[];
656
+    g INT;
657
+BEGIN
658
+    SELECT "value" INTO val FROM luticate_permissions_users WHERE "user_id" = _user_id AND "name" = _permisson_name;
659
+    IF val is null THEN
660
+        SELECT lpg."value" into val FROM luticate_permissions_groups lpg
661
+            INNER JOIN luticate_groups lg ON lg."id" = lpg."group_id"
662
+            INNER JOIN luticate_users_groups lug ON lug."user_id" = _user_id AND lug."group_id" = lg."id"
663
+        WHERE lpg."name" = _permisson_name and lpg."value" = FALSE;
664
+        IF val is null then
665
+            SELECT lpg."value" into val FROM luticate_permissions_groups lpg
666
+                INNER JOIN luticate_groups lg ON lg."id" = lpg."group_id"
667
+                INNER JOIN luticate_users_groups lug ON lug."user_id" = _user_id AND lug."group_id" = lg."id"
668
+            WHERE lpg."name" = _permisson_name and lpg."value" = TRUE;
669
+            IF val is null then
670
+                SELECT "value" INTO val FROM luticate_permissions WHERE "name" = _permisson_name;
671
+            END IF;
672
+        end if;
673
+    END IF;
674
+END;
675
+$$;
676
+
677
+--
678
+-- Name: sp_lu_get_all_user_permission(integer); Type: FUNCTION; Schema: public; Owner: dev
679
+--
680
+
681
+CREATE FUNCTION sp_lu_get_all_user_permission(_user_id integer, OUT _permisson_name character varying, OUT val boolean) RETURNS SETOF record
682
+LANGUAGE sql IMMUTABLE SECURITY DEFINER COST 10
683
+AS $$
684
+SELECT p.name, sp_lu_get_user_permission(_user_id, p.name) FROM luticate_permissions p ORDER bY p.name
685
+$$;
686
+
687
+--
688
+-- Name: public; Type: ACL; Schema: -; Owner: postgres
689
+--
690
+--
691
+-- PostgreSQL database dump complete
692
+--

+ 365
- 0
postgresql/docker-entrypoint-initdb.d/0.1.0_10_data_init.sql View File

@@ -0,0 +1,365 @@
1
+--
2
+-- PostgreSQL database dump
3
+--
4
+--
5
+-- Data for Name: camera_types; Type: TABLE DATA; Schema: public; Owner: dev
6
+--
7
+
8
+INSERT INTO camera_types VALUES (3, 'Trendnet TV-IP311PI', 'App\Http\Business\Cameras\Trendnet\TVIP311PI', '{"Host": "http://camX.example.com","Port":6080, "Username": "user", "Password": "PA$$W0RD"}');
9
+INSERT INTO camera_types VALUES (1, 'Dummy', '\App\Http\Business\Cameras\DummyCamera', '{}');
10
+
11
+
12
+--
13
+-- Name: camera_types_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dev
14
+--
15
+
16
+SELECT pg_catalog.setval('camera_types_id_seq', 3, true);
17
+
18
+
19
+--
20
+-- Data for Name: hosts; Type: TABLE DATA; Schema: public; Owner: dev
21
+--
22
+
23
+INSERT INTO hosts VALUES (9, 'Test.', 'http://backend.camotion.internal.docker/', 'change_it');
24
+
25
+
26
+--
27
+-- Data for Name: cameras; Type: TABLE DATA; Schema: public; Owner: dev
28
+--
29
+
30
+INSERT INTO cameras VALUES (9, 'Test.', 'Test. description', 9, 1, '{}');
31
+INSERT INTO cameras VALUES (6, 'Test.2', 'Test.2 description', 9, 1, '{}');
32
+INSERT INTO cameras VALUES (7, 'Test.3', 'Test.3 description', 9, 1, '{}');
33
+INSERT INTO cameras VALUES (8, 'Test.4', 'Test.4 description', 9, 1, '{}');
34
+
35
+
36
+--
37
+-- Name: cameras_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dev
38
+--
39
+
40
+SELECT pg_catalog.setval('cameras_id_seq', 11, true);
41
+
42
+
43
+--
44
+-- Data for Name: command_types; Type: TABLE DATA; Schema: public; Owner: dev
45
+--
46
+
47
+INSERT INTO command_types VALUES (1, 'Dummy command', 'App\Http\Business\Commands\DummyCommand', '{"Success": true}');
48
+INSERT INTO command_types VALUES (2, 'Wake on LAN', 'App\Http\Business\Commands\WakeOnLanCommand', '{"IP": "255.255.255.255", "Port": 9, "MACs": ["ff:ff:ff:ff:ff:ff"]}');
49
+INSERT INTO command_types VALUES (3, 'PiFace Digital', 'App\Http\Business\Commands\PiFaceCommand', '{"Commands":["device=0","up=0", "sleep=500", "down=0"]}');
50
+
51
+
52
+--
53
+-- Name: command_types_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dev
54
+--
55
+
56
+SELECT pg_catalog.setval('command_types_id_seq', 3, true);
57
+
58
+
59
+--
60
+-- Data for Name: commands; Type: TABLE DATA; Schema: public; Owner: dev
61
+--
62
+
63
+INSERT INTO commands VALUES (1, 'Dummy command', 'Command that will fail', 9, 1, '{"Success":false}');
64
+INSERT INTO commands VALUES (2, 'Dummy command 2', 'Command that will succeed', 9, 1, '{"Success":true}');
65
+
66
+
67
+--
68
+-- Name: commands_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dev
69
+--
70
+
71
+SELECT pg_catalog.setval('commands_id_seq', 4, true);
72
+
73
+
74
+--
75
+-- Name: hosts_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dev
76
+--
77
+
78
+SELECT pg_catalog.setval('hosts_id_seq', 10, true);
79
+
80
+
81
+--
82
+-- Data for Name: luticate_groups; Type: TABLE DATA; Schema: public; Owner: dev
83
+--
84
+
85
+INSERT INTO luticate_groups VALUES (0, 'Super Administrators');
86
+INSERT INTO luticate_groups VALUES (1, 'Administrators');
87
+INSERT INTO luticate_groups VALUES (3, 'Cameras');
88
+INSERT INTO luticate_groups VALUES (4, 'Sensors');
89
+INSERT INTO luticate_groups VALUES (5, 'Commands');
90
+
91
+
92
+--
93
+-- Name: luticate_groups_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dev
94
+--
95
+
96
+SELECT pg_catalog.setval('luticate_groups_id_seq', 5, true);
97
+
98
+
99
+--
100
+-- Data for Name: luticate_permissions; Type: TABLE DATA; Schema: public; Owner: dev
101
+--
102
+
103
+INSERT INTO luticate_permissions VALUES ('LU_USER_GET', false);
104
+INSERT INTO luticate_permissions VALUES ('LU_USER_SET_PASSWORD', false);
105
+INSERT INTO luticate_permissions VALUES ('LU_USER_LOGIN', true);
106
+INSERT INTO luticate_permissions VALUES ('LU_USER_EDIT_ME', true);
107
+INSERT INTO luticate_permissions VALUES ('LU_USER_SET_PASSWORD_ME', true);
108
+INSERT INTO luticate_permissions VALUES ('LU_GROUP_ADD', false);
109
+INSERT INTO luticate_permissions VALUES ('LU_GROUP_DEL', false);
110
+INSERT INTO luticate_permissions VALUES ('LU_GROUP_EDIT', false);
111
+INSERT INTO luticate_permissions VALUES ('LU_GROUP_USER_ADD', false);
112
+INSERT INTO luticate_permissions VALUES ('LU_GROUP_USER_DEL', false);
113
+INSERT INTO luticate_permissions VALUES ('LU_PERM_ADD', false);
114
+INSERT INTO luticate_permissions VALUES ('LU_PERM_DEL', false);
115
+INSERT INTO luticate_permissions VALUES ('LU_PERM_EDIT', false);
116
+INSERT INTO luticate_permissions VALUES ('LU_PERM_EFFECTIVE_GET', false);
117
+INSERT INTO luticate_permissions VALUES ('LU_PERM_GET', false);
118
+INSERT INTO luticate_permissions VALUES ('LU_PERM_GROUP_ADD', false);
119
+INSERT INTO luticate_permissions VALUES ('LU_PERM_GROUP_DEL', false);
120
+INSERT INTO luticate_permissions VALUES ('LU_PERM_GROUP_EDIT', false);
121
+INSERT INTO luticate_permissions VALUES ('LU_PERM_GROUP_GET', false);
122
+INSERT INTO luticate_permissions VALUES ('LU_GROUP_GET', false);
123
+INSERT INTO luticate_permissions VALUES ('LU_PERM_USER_ADD', false);
124
+INSERT INTO luticate_permissions VALUES ('LU_PERM_USER_DEL', false);
125
+INSERT INTO luticate_permissions VALUES ('LU_PERM_USER_EDIT', false);
126
+INSERT INTO luticate_permissions VALUES ('LU_USER_EDIT', false);
127
+INSERT INTO luticate_permissions VALUES ('LU_USER_DEL', false);
128
+INSERT INTO luticate_permissions VALUES ('LU_USER_ADD', false);
129
+INSERT INTO luticate_permissions VALUES ('LU_PERM_USER_GET', false);
130
+INSERT INTO luticate_permissions VALUES ('CAMOTION_HOST_ADD', false);
131
+INSERT INTO luticate_permissions VALUES ('CAMOTION_HOST_DEL', false);
132
+INSERT INTO luticate_permissions VALUES ('CAMOTION_HOST_EDIT', false);
133
+INSERT INTO luticate_permissions VALUES ('CAMOTION_COMMAND_ADD', false);
134
+INSERT INTO luticate_permissions VALUES ('CAMOTION_COMMAND_DEL', false);
135
+INSERT INTO luticate_permissions VALUES ('CAMOTION_COMMAND_EDIT', false);
136
+INSERT INTO luticate_permissions VALUES ('CAMOTION_SENSOR_ADD', false);
137
+INSERT INTO luticate_permissions VALUES ('CAMOTION_SENSOR_DEL', false);
138
+INSERT INTO luticate_permissions VALUES ('CAMOTION_SENSOR_EDIT', false);
139
+INSERT INTO luticate_permissions VALUES ('CAMOTION_CAMERA_ADD', false);
140
+INSERT INTO luticate_permissions VALUES ('CAMOTION_CAMERA_DEL', false);
141
+INSERT INTO luticate_permissions VALUES ('CAMOTION_CAMERA_EDIT', false);
142
+INSERT INTO luticate_permissions VALUES ('CAMOTION_SENSOR_EXEC', false);
143
+INSERT INTO luticate_permissions VALUES ('CAMOTION_SENSOR_GET', false);
144
+INSERT INTO luticate_permissions VALUES ('CAMOTION_CAMERA_EXEC', false);
145
+INSERT INTO luticate_permissions VALUES ('CAMOTION_CAMERA_GET', false);
146
+INSERT INTO luticate_permissions VALUES ('CAMOTION_COMMAND_EXEC', false);
147
+INSERT INTO luticate_permissions VALUES ('CAMOTION_COMMAND_GET', false);
148
+INSERT INTO luticate_permissions VALUES ('CAMOTION_HOST_GET', false);
149
+
150
+
151
+--
152
+-- Data for Name: luticate_permissions_groups; Type: TABLE DATA; Schema: public; Owner: dev
153
+--
154
+
155
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_ADD', true, 0);
156
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_DEL', true, 0);
157
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_EDIT', true, 0);
158
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_GET', true, 0);
159
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_USER_ADD', true, 0);
160
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_USER_DEL', true, 0);
161
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_EFFECTIVE_GET', true, 0);
162
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_GET', true, 0);
163
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_GROUP_ADD', true, 0);
164
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_GROUP_DEL', true, 0);
165
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_GROUP_EDIT', true, 0);
166
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_GROUP_GET', true, 0);
167
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_USER_ADD', true, 0);
168
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_USER_DEL', true, 0);
169
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_USER_EDIT', true, 0);
170
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_USER_GET', true, 0);
171
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_ADD', true, 0);
172
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_DEL', true, 0);
173
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_EDIT', true, 0);
174
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_EDIT_ME', true, 0);
175
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_GET', true, 0);
176
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_LOGIN', true, 0);
177
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_SET_PASSWORD', true, 0);
178
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_SET_PASSWORD_ME', true, 0);
179
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_ADD', true, 1);
180
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_DEL', true, 1);
181
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_EDIT', true, 1);
182
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_GET', true, 1);
183
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_USER_ADD', true, 1);
184
+INSERT INTO luticate_permissions_groups VALUES ('LU_GROUP_USER_DEL', true, 1);
185
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_EFFECTIVE_GET', true, 1);
186
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_GET', true, 1);
187
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_GROUP_ADD', true, 1);
188
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_GROUP_DEL', true, 1);
189
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_GROUP_EDIT', true, 1);
190
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_GROUP_GET', true, 1);
191
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_USER_ADD', true, 1);
192
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_USER_DEL', true, 1);
193
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_USER_EDIT', true, 1);
194
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_USER_GET', true, 1);
195
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_ADD', true, 1);
196
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_DEL', true, 1);
197
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_EDIT', true, 1);
198
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_EDIT_ME', true, 1);
199
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_GET', true, 1);
200
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_LOGIN', true, 1);
201
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_SET_PASSWORD', true, 1);
202
+INSERT INTO luticate_permissions_groups VALUES ('LU_USER_SET_PASSWORD_ME', true, 1);
203
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_EDIT', true, 0);
204
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_DEL', true, 0);
205
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_ADD', true, 0);
206
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_ADD', false, 1);
207
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_EDIT', false, 1);
208
+INSERT INTO luticate_permissions_groups VALUES ('LU_PERM_DEL', false, 1);
209
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_CAMERA_ADD', true, 1);
210
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_CAMERA_DEL', true, 1);
211
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_CAMERA_EDIT', true, 1);
212
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_CAMERA_EXEC', true, 1);
213
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_CAMERA_GET', true, 1);
214
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_COMMAND_ADD', true, 1);
215
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_COMMAND_DEL', true, 1);
216
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_COMMAND_EDIT', true, 1);
217
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_COMMAND_EXEC', true, 1);
218
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_COMMAND_GET', true, 1);
219
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_HOST_ADD', true, 1);
220
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_HOST_DEL', true, 1);
221
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_HOST_EDIT', true, 1);
222
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_HOST_GET', true, 1);
223
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_SENSOR_ADD', true, 1);
224
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_SENSOR_DEL', true, 1);
225
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_SENSOR_EDIT', true, 1);
226
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_SENSOR_EXEC', true, 1);
227
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_SENSOR_GET', true, 1);
228
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_CAMERA_ADD', true, 0);
229
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_CAMERA_DEL', true, 0);
230
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_CAMERA_EDIT', true, 0);
231
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_CAMERA_EXEC', true, 0);
232
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_CAMERA_GET', true, 0);
233
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_COMMAND_ADD', true, 0);
234
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_COMMAND_DEL', true, 0);
235
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_COMMAND_EDIT', true, 0);
236
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_COMMAND_EXEC', true, 0);
237
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_COMMAND_GET', true, 0);
238
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_HOST_ADD', true, 0);
239
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_HOST_DEL', true, 0);
240
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_HOST_EDIT', true, 0);
241
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_HOST_GET', true, 0);
242
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_SENSOR_ADD', true, 0);
243
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_SENSOR_DEL', true, 0);
244
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_SENSOR_EDIT', true, 0);
245
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_SENSOR_EXEC', true, 0);
246
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_SENSOR_GET', true, 0);
247
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_CAMERA_GET', true, 3);
248
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_CAMERA_EXEC', true, 3);
249
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_SENSOR_GET', true, 4);
250
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_SENSOR_EXEC', true, 4);
251
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_COMMAND_GET', true, 5);
252
+INSERT INTO luticate_permissions_groups VALUES ('CAMOTION_COMMAND_EXEC', true, 5);
253
+
254
+
255
+--
256
+-- Data for Name: luticate_users; Type: TABLE DATA; Schema: public; Owner: dev
257
+--
258
+
259
+INSERT INTO luticate_users VALUES (0, 'anonymous', 'anonymous@example.com', '', '', NULL, 'anonymous', 'anonymous');
260
+INSERT INTO luticate_users VALUES (1, 'root', 'root@example.com', '$2y$10$m1aN1a1ZEr1vmjFPfWl4Pu/63EhcxVCrC/DF0DFhdGbvORwtJtCmy', 'szHKcDk5v1', NULL, 'root', 'root');
261
+INSERT INTO luticate_users VALUES (4, 'user', 'uesr@example.com', '$2y$10$3aoyf68xWuL4/Rop1lAYDOaBTWeFyvX8H.lYBSZRH9HIwaFxhimDG', 'OqSvWHcjAB', NULL, 'User', 'User');
262
+
263
+
264
+--
265
+-- Data for Name: luticate_permissions_users; Type: TABLE DATA; Schema: public; Owner: dev
266
+--
267
+
268
+INSERT INTO luticate_permissions_users VALUES ('LU_GROUP_ADD', false, 0);
269
+INSERT INTO luticate_permissions_users VALUES ('LU_GROUP_DEL', false, 0);
270
+INSERT INTO luticate_permissions_users VALUES ('LU_GROUP_EDIT', false, 0);
271
+INSERT INTO luticate_permissions_users VALUES ('LU_GROUP_USER_ADD', false, 0);
272
+INSERT INTO luticate_permissions_users VALUES ('LU_GROUP_USER_DEL', false, 0);
273
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_ADD', false, 0);
274
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_DEL', false, 0);
275
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_EDIT', false, 0);
276
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_EFFECTIVE_GET', false, 0);
277
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_GET', false, 0);
278
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_GROUP_ADD', false, 0);
279
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_GROUP_DEL', false, 0);
280
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_GROUP_EDIT', false, 0);
281
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_GROUP_GET', false, 0);
282
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_USER_ADD', false, 0);
283
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_USER_DEL', false, 0);
284
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_USER_EDIT', false, 0);
285
+INSERT INTO luticate_permissions_users VALUES ('LU_PERM_USER_GET', false, 0);
286
+INSERT INTO luticate_permissions_users VALUES ('LU_USER_ADD', false, 0);
287
+INSERT INTO luticate_permissions_users VALUES ('LU_USER_DEL', false, 0);
288
+INSERT INTO luticate_permissions_users VALUES ('LU_USER_EDIT', false, 0);
289
+INSERT INTO luticate_permissions_users VALUES ('LU_USER_EDIT_ME', false, 0);
290
+INSERT INTO luticate_permissions_users VALUES ('LU_USER_GET', false, 0);
291
+INSERT INTO luticate_permissions_users VALUES ('LU_USER_SET_PASSWORD', false, 0);
292
+INSERT INTO luticate_permissions_users VALUES ('LU_USER_SET_PASSWORD_ME', false, 0);
293
+INSERT INTO luticate_permissions_users VALUES ('LU_USER_LOGIN', true, 0);
294
+INSERT INTO luticate_permissions_users VALUES ('LU_GROUP_GET', false, 0);
295
+INSERT INTO luticate_permissions_users VALUES ('CAMOTION_COMMAND_ADD', false, 0);
296
+INSERT INTO luticate_permissions_users VALUES ('CAMOTION_COMMAND_DEL', false, 0);
297
+INSERT INTO luticate_permissions_users VALUES ('CAMOTION_COMMAND_EDIT', false, 0);
298
+INSERT INTO luticate_permissions_users VALUES ('CAMOTION_COMMAND_EXEC', false, 0);
299
+INSERT INTO luticate_permissions_users VALUES ('CAMOTION_COMMAND_GET', false, 0);
300
+INSERT INTO luticate_permissions_users VALUES ('CAMOTION_SENSOR_ADD', false, 0);
301
+INSERT INTO luticate_permissions_users VALUES ('CAMOTION_SENSOR_DEL', false, 0);
302
+INSERT INTO luticate_permissions_users VALUES ('CAMOTION_SENSOR_EDIT', false, 0);
303
+INSERT INTO luticate_permissions_users VALUES ('CAMOTION_SENSOR_EXEC', false, 0);
304
+INSERT INTO luticate_permissions_users VALUES ('CAMOTION_SENSOR_GET', false, 0);
305
+INSERT INTO luticate_permissions_users VALUES ('CAMOTION_HOST_ADD', false, 0);
306
+INSERT INTO luticate_permissions_users VALUES ('CAMOTION_HOST_EDIT', false, 0);
307
+INSERT INTO luticate_permissions_users VALUES ('CAMOTION_HOST_DEL', false, 0);
308
+INSERT INTO luticate_permissions_users VALUES ('CAMOTION_HOST_GET', false, 0);
309
+INSERT INTO luticate_permissions_users VALUES ('CAMOTION_CAMERA_GET', false, 0);
310
+INSERT INTO luticate_permissions_users VALUES ('CAMOTION_CAMERA_EDIT', false, 0);
311
+INSERT INTO luticate_permissions_users VALUES ('CAMOTION_CAMERA_ADD', false, 0);
312
+INSERT INTO luticate_permissions_users VALUES ('CAMOTION_CAMERA_DEL', false, 0);
313
+INSERT INTO luticate_permissions_users VALUES ('CAMOTION_CAMERA_EXEC', false, 0);
314
+
315
+
316
+--
317
+-- Data for Name: luticate_users_groups; Type: TABLE DATA; Schema: public; Owner: dev
318
+--
319
+
320
+INSERT INTO luticate_users_groups VALUES (1, 0);
321
+INSERT INTO luticate_users_groups VALUES (4, 3);
322
+INSERT INTO luticate_users_groups VALUES (4, 5);
323
+INSERT INTO luticate_users_groups VALUES (4, 4);
324
+
325
+
326
+--
327
+-- Name: luticate_users_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dev
328
+--
329
+
330
+SELECT pg_catalog.setval('luticate_users_id_seq', 4, true);
331
+
332
+
333
+--
334
+-- Data for Name: sensor_types; Type: TABLE DATA; Schema: public; Owner: dev
335
+--
336
+
337
+INSERT INTO sensor_types VALUES (1, 'Dummy Sensor', 'App\Http\Business\Sensors\DummySensor', '{"Minimum": 0, "Maximum": 42}');
338
+INSERT INTO sensor_types VALUES (2, 'PiFace Digital', 'App\Http\Business\Sensors\PiFaceSensor', '{"Device": 0, "Pin":0, "True": "Openned", "False": "Closed"}');
339
+
340
+
341
+--
342
+-- Name: sensor_types_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dev
343
+--
344
+
345
+SELECT pg_catalog.setval('sensor_types_id_seq', 3, true);
346
+
347
+
348
+--
349
+-- Data for Name: sensors; Type: TABLE DATA; Schema: public; Owner: dev
350
+--
351
+
352
+INSERT INTO sensors VALUES (6, 'Dummy sensor', 'Get a random value', 9, 1, '{"Minimum":0,"Maximum":42}');
353
+INSERT INTO sensors VALUES (7, 'Dummy sensor 2', 'Get a negative random value', 9, 1, '{"Minimum":-42,"Maximum":0}');
354
+
355
+
356
+--
357
+-- Name: sensors_id_seq; Type: SEQUENCE SET; Schema: public; Owner: dev
358
+--
359
+
360
+SELECT pg_catalog.setval('sensors_id_seq', 7, true);
361
+
362
+
363
+--
364
+-- PostgreSQL database dump complete
365
+--

+ 93
- 0
postgresql/docker-entrypoint-initdb.d/0.1.3_01_struct_init.sql View File

@@ -0,0 +1,93 @@
1
+--
2
+-- Name: luticate_settings; Type: TABLE; Schema: public; Owner: dev; Tablespace:
3
+--
4
+
5
+CREATE TABLE luticate_settings (
6
+    name character varying(128) NOT NULL,
7
+    type character varying(128) NOT NULL,
8
+    value text NOT NULL,
9
+    is_blocked boolean NOT NULL,
10
+    is_admin boolean NOT NULL
11
+);
12
+
13
+
14
+--
15
+-- Name: luticate_settings_users; Type: TABLE; Schema: public; Owner: dev; Tablespace:
16
+--
17
+
18
+CREATE TABLE luticate_settings_users (
19
+    name character varying(128) NOT NULL,
20
+    value text NOT NULL,
21
+    user_id integer NOT NULL,
22
+    is_blocked boolean NOT NULL
23
+);
24
+
25
+--
26
+-- Name: luticate_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
27
+--
28
+
29
+ALTER TABLE ONLY luticate_settings
30
+    ADD CONSTRAINT luticate_settings_pkey PRIMARY KEY (name);
31
+
32
+
33
+--
34
+-- Name: luticate_settings_users_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
35
+--
36
+
37
+ALTER TABLE ONLY luticate_settings_users
38
+    ADD CONSTRAINT luticate_settings_users_pkey PRIMARY KEY (name, user_id);
39
+
40
+--
41
+-- Name: luticate_settings_users_name_fkey; Type: FK CONSTRAINT; Schema: public; Owner: dev
42
+--
43
+
44
+ALTER TABLE ONLY luticate_settings_users
45
+    ADD CONSTRAINT luticate_settings_users_name_fkey FOREIGN KEY (name) REFERENCES luticate_settings(name) ON DELETE CASCADE;
46
+
47
+
48
+--
49
+-- Name: luticate_settings_users_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: dev
50
+--
51
+
52
+ALTER TABLE ONLY luticate_settings_users
53
+    ADD CONSTRAINT luticate_settings_users_user_id_fkey FOREIGN KEY (user_id) REFERENCES luticate_users(id) ON DELETE CASCADE;
54
+
55
+--
56
+-- Name: sp_lu_get_user_setting(integer, character varying); Type: FUNCTION; Schema: public; Owner: dev
57
+--
58
+
59
+CREATE FUNCTION sp_lu_get_user_setting(_user_id integer, _setting_name character varying, OUT setting json) RETURNS json
60
+    LANGUAGE plpgsql IMMUTABLE SECURITY DEFINER COST 10
61
+    AS $$
62
+DECLARE
63
+_setting luticate_settings;
64
+_setting_user luticate_settings_users;
65
+BEGIN
66
+    SELECT * INTO _setting FROM luticate_settings WHERE "name" = _setting_name AND NOT "is_admin";
67
+    IF _setting IS NULL THEN
68
+        setting := NULL;
69
+    ELSE
70
+        IF NOT _setting.is_blocked THEN
71
+            SELECT * INTO _setting_user FROM luticate_settings_users WHERE "user_id" = _user_id AND "name" = _setting_name;
72
+            IF _setting_user IS NOT NULL THEN
73
+                _setting.value := _setting_user.value;
74
+            END IF;
75
+        END IF;
76
+        setting := to_json(_setting);
77
+    END IF;
78
+END;
79
+$$;
80
+
81
+
82
+--
83
+-- Name: sp_lu_get_all_user_settings(integer); Type: FUNCTION; Schema: public; Owner: dev
84
+--
85
+
86
+CREATE FUNCTION sp_lu_get_all_user_settings(_user_id integer, OUT _settings json) RETURNS SETOF json
87
+    LANGUAGE sql IMMUTABLE SECURITY DEFINER COST 10
88
+    AS $$
89
+	SELECT sp_lu_get_user_setting(_user_id, s.name)
90
+	FROM luticate_settings s
91
+	WHERE NOT s.is_admin
92
+	ORDER BY s.name
93
+$$;

+ 62
- 0
postgresql/docker-entrypoint-initdb.d/0.1.3_10_data_init.sql View File

@@ -0,0 +1,62 @@
1
+--
2
+-- Data for Name: luticate_settings; Type: TABLE DATA; Schema: public; Owner: dev
3
+--
4
+
5
+INSERT INTO luticate_settings VALUES ('LU_SESSION_DAYS', 'int', '30', true, true);
6
+INSERT INTO luticate_settings VALUES ('LU_USERS_PER_PAGE', 'int', '15', false, false);
7
+INSERT INTO luticate_settings VALUES ('LU_GROUPS_PER_PAGE', 'int', '15', false, false);
8
+INSERT INTO luticate_settings VALUES ('LU_SETTINGS_PER_PAGE', 'int', '15', false, false);
9
+INSERT INTO luticate_settings VALUES ('LU_PERMISSIONS_PER_PAGE', 'int', '15', false, false);
10
+
11
+--
12
+-- Data for Name: luticate_permissions; Type: TABLE DATA; Schema: public; Owner: dev
13
+--
14
+
15
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_DEL', false);
16
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_EDIT', false);
17
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_EFFECTIVE_GET', false);
18
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_GET', false);
19
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_USER_EDIT', false);
20
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_USER_GET', false);
21
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_EDIT_ME', false);
22
+INSERT INTO luticate_permissions VALUES ('LU_SETTING_ADD', false);
23
+
24
+--
25
+-- Data for Name: luticate_permissions_groups; Type: TABLE DATA; Schema: public; Owner: dev
26
+--
27
+
28
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_ADD', false, 1);
29
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_DEL', false, 1);
30
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_EDIT', true, 1);
31
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_EFFECTIVE_GET', true, 1);
32
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_GET', true, 1);
33
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_USER_EDIT', true, 1);
34
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_USER_GET', true, 1);
35
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_ADD', true, 0);
36
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_DEL', true, 0);
37
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_EDIT', true, 0);
38
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_EFFECTIVE_GET', true, 0);
39
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_GET', true, 0);
40
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_USER_EDIT', true, 0);
41
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_USER_GET', true, 0);
42
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_EDIT_ME', true, 1);
43
+INSERT INTO luticate_permissions_groups VALUES ('LU_SETTING_EDIT_ME', true, 0);
44
+
45
+--
46
+-- Data for Name: luticate_permissions_users; Type: TABLE DATA; Schema: public; Owner: dev
47
+--
48
+
49
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_USER_GET', true, 0);
50
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_ADD', false, 0);
51
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_EDIT', false, 0);
52
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_EFFECTIVE_GET', false, 0);
53
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_DEL', false, 0);
54
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_EDIT_ME', false, 0);
55
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_GET', false, 0);
56
+INSERT INTO luticate_permissions_users VALUES ('LU_SETTING_USER_EDIT', false, 0);
57
+
58
+--
59
+-- Data for Name: camera_types; Type: TABLE DATA; Schema: public; Owner: dev
60
+--
61
+
62
+INSERT INTO camera_types VALUES (4, 'Elro C903IP', 'App\Http\Business\Cameras\Elro\C903IP', '{"Host": "http://camX.example.com","Port":6080, "Username": "user", "Password": "PA$$W0RD"}');

+ 17
- 0
postgresql/vars-vars View File

@@ -0,0 +1,17 @@
1
+POSTGRES_MASTER_MODE
2
+POSTGRES_HOST
3
+POSTGRES_USER
4
+POSTGRES_PASSWORD
5
+POSTGRES_DB
6
+POSTGRES_REP_USER
7
+POSTGRES_REP_PASSWORD
8
+POSTGRES_REP_ALLOWED_HOST
9
+POSTGRES_RO_USER
10
+POSTGRES_RO_PASSWORD
11
+
12
+CM_BACKEND_TOKEN
13
+
14
+CM_API_HOST
15
+CM_API_PORT
16
+CM_API_MCRYPT_KEY
17
+CM_API_JWT_KEY

+ 1
- 1
update_vars.sh View File

@@ -1,7 +1,7 @@
1 1
 #! /usr/bin/env sh
2 2
 
3 3
 vars=$(cat env | cut -d= -f1)
4
-for docker in backend
4
+for docker in backend frontend postgresql api
5 5
 do
6 6
   echo "${vars}" > "./${docker}/vars-vars"
7 7
 done

Loading…
Cancel
Save