]> WPIA git - motion.git/blob - README.md
Merge branch 'jenkins' into 'master'
[motion.git] / README.md
1 # Installation
2 Requires Python 3 and a running PostgreSQL installation.
3
4 For a productive environment use a nginx webserver.
5
6 To install:
7 ```
8 virtualenv -p python3 .
9 . bin/activate
10 pip install -r requirements.txt
11 ```
12 Then edit config.py.example into config.py with your database connection
13
14 ## Development and debug
15
16 To debug-run linux:
17 ```
18 LANG=C.UTF-8 FLASK_DEBUG=1 FLASK_APP=motion.py flask run
19 ```
20
21 To debug-run windows:
22 ```
23 set LANG=C.UTF-8
24 set FLASK_DEBUG=1
25 set FLASK_APP=motion.py
26 flask run
27 ```
28
29 For unit testing use config values from config.py.example:
30 ```
31 python -m unittest tests/test_motion.py
32 ```
33
34 The database schema is automatically installed when the table "schema_version" does not exist and the application is started.
35
36 The following user rights can be granted:
37 - create: user is able to create a new motion
38 - vote: user is able to vote running motions
39 - cancel: user is able to cancel a running motion
40 - finish: user is able to close a running motion
41 - audit: user is able to see given votes of a finished motion
42
43 To grant right use the following (here with vote right as example):
44 - on all groups add "vote:*"
45 - on one given group add "vote:group1"
46 - on two given groups add "vote:group1 vote:group2"
47
48 # Usage
49
50 Within the motion content markdown can be used for formatting e.g. 
51 * To add a line break add two lines
52 * to enter a link use `[text](https//domain.tld/link)`
53
54 ## Settings for nginx
55
56 To control the access this map is used:
57
58 ```
59 map "$host:$ssl_client_serial:$ssl_client_i_dn" $motion_user_role {
60 "host.domain.tld:serialnumber:/issuername" 'username/create:* vote:* cancel:* audit:*';
61 ...
62 default "<invalid>/";
63 }
64 ```
65
66 example taken from motions.board.wpia.club:
67 ```
68 map "$host:$ssl_client_serial:$ssl_client_i_dn" $motion_user_role {
69 "motions.board.wpia.club:0a0000000a1234567890abcdef1234567890abcde:/CN=Orga 2019-2/O=TC InterimCA/OU=TC InterimCAs/C=AT" 'president/create:* vote:* cancel:* audit:*';
70 ...
71 default "<invalid>/";
72 }
73 ```
74
75
76 ## configuration
77 ```
78 listen 0.0.0.0:443 ssl;
79 listen [::]:443 ssl;
80 server_name host.domain.tld;
81 gzip on;
82 ssl_certificate /etc/ssl/private/host.domain.tld.crt;
83 ssl_certificate_key /etc/ssl/private/host.domain.tld.key;
84
85 ssl_client_certificate /etc/ssl/host.domain.tld.pem;
86 ssl_verify_client on;
87 ssl_verify_depth 4;
88 access_log /tmp/host.domain.tld.log motion-cert;
89
90 location / {
91 fastcgi_param QUERY_STRING $query_string;
92 fastcgi_param REQUEST_METHOD $request_method;
93 fastcgi_param CONTENT_TYPE $content_type;
94 fastcgi_param CONTENT_LENGTH $content_length;
95 fastcgi_param REQUEST_URI $request_uri;
96 fastcgi_param PATH_INFO $document_uri;
97 fastcgi_param REMOTE_ADDR $remote_addr;
98 fastcgi_param REMOTE_PORT $remote_port;
99 fastcgi_param SERVER_NAME $host;
100 fastcgi_param SERVER_PORT '443';
101 fastcgi_param SERVER_PROTOCOL 'https';
102 fastcgi_param USER_ROLES $motion_user_role;
103 fastcgi_pass unix:/motion-socket/motion.fcgi;
104 }
105 ```
106
107 # Configuration for a Jenkins Freestyle Project
108
109 ## Preconditions for Jenkins system
110
111 * Python 3 installed with:
112
113   python3 virtualenv python3-pip
114
115 * PostgreSQL server installed with motion database and database user
116
117
118 ## Add freestyle project
119
120 ### Source-Code-Management
121
122 Adjust Git settings
123
124 ### Build Environment
125
126 Add Bindings
127
128 Add Username and password (separated)
129
130 Enter username (DB_USER) and password (DB_PW) according to database credentials
131
132 ### Build
133
134 Add build step shell
135
136 Add the command
137
138 ```
139 rm -rf env
140 virtualenv -p python3 env
141 . env/bin/activate
142 pip3 install -r requirements.txt
143
144
145 cat > config.py << EOF
146 DATABASE="pq://IP-ADDRESS/motion"
147 USER="${DB_USER}"
148 PASSWORD="${DB_PW}"
149 EOF
150
151 python3 jenkins_job.py
152 ```
153
154 If an IPv6 address is used the following needs to be added to the script to fix a bug of the IPv6 literal translation:
155 (https://github.com/python-postgres/fe/issues/104)
156
157 ```
158 patch env/lib/python3*/site-packages/postgresql/versionstring.py <<EOF
159 diff --git a/postgresql/versionstring.py b/postgresql/versionstring.py
160 index ccb3953..2503013 100644
161 --- a/postgresql/versionstring.py
162 +++ b/postgresql/versionstring.py
163 @@ -15,7 +15,7 @@ def split(vstr : str) -> (
164     Split a PostgreSQL version string into a tuple
165     (major,minor,patch,...,state_class,state_level)
166     """
167 -   v = vstr.strip().split('.')
168 +   v = vstr.strip().split(' ')[0].split('.')
169  
170     # Get rid of the numbers around the state_class (beta,a,dev,alpha, etc)
171     state_class = v[-1].strip('0123456789')
172 EOF
173 ```
174
175 ### Post build actions
176
177 Add Publish JUnit test result report - test report XMLs
178
179 ```
180 python_tests_xml/*
181 ```