Fossil SCM

Modularize server/project code handling. Small style fix to the Dockerfile.

mistachkin 2014-09-23 15:33 trunk
Commit 1cf47285854253cdd2b7b7615bdcb1309df779b9
3 files changed +2 -2 +29 -6 +2 -7
+2 -2
--- Dockerfile
+++ Dockerfile
@@ -7,13 +7,13 @@
77
# RUN yum update -y && yum clean all
88
RUN yum install -y gcc make zlib-devel openssl-devel tcl-devel && yum clean all
99
RUN groupadd -r fossil -g 433 && useradd -u 431 -r -g fossil -d /opt/fossil -s /sbin/nologin -c "Fossil user" fossil
1010
1111
### If you want to build "release", change the next line accordingly.
12
-ENV VERSION trunk
12
+ENV FOSSIL_INSTALL_VERSION trunk
1313
14
-RUN curl "http://www.fossil-scm.org/index.html/tarball/fossil-src.tar.gz?name=fossil-src&uuid=${VERSION}" | tar zx
14
+RUN curl "http://www.fossil-scm.org/index.html/tarball/fossil-src.tar.gz?name=fossil-src&uuid=${FOSSIL_INSTALL_VERSION}" | tar zx
1515
RUN cd fossil-src && ./configure --lineedit=0 --json --with-tcl --with-tcl-stubs --with-tcl-private-stubs && make;
1616
RUN cp fossil-src/fossil /usr/bin
1717
RUN rm -rf fossil-src
1818
RUN chmod a+rx /usr/bin/fossil
1919
RUN mkdir -p /opt/fossil
2020
--- Dockerfile
+++ Dockerfile
@@ -7,13 +7,13 @@
7 # RUN yum update -y && yum clean all
8 RUN yum install -y gcc make zlib-devel openssl-devel tcl-devel && yum clean all
9 RUN groupadd -r fossil -g 433 && useradd -u 431 -r -g fossil -d /opt/fossil -s /sbin/nologin -c "Fossil user" fossil
10
11 ### If you want to build "release", change the next line accordingly.
12 ENV VERSION trunk
13
14 RUN curl "http://www.fossil-scm.org/index.html/tarball/fossil-src.tar.gz?name=fossil-src&uuid=${VERSION}" | tar zx
15 RUN cd fossil-src && ./configure --lineedit=0 --json --with-tcl --with-tcl-stubs --with-tcl-private-stubs && make;
16 RUN cp fossil-src/fossil /usr/bin
17 RUN rm -rf fossil-src
18 RUN chmod a+rx /usr/bin/fossil
19 RUN mkdir -p /opt/fossil
20
--- Dockerfile
+++ Dockerfile
@@ -7,13 +7,13 @@
7 # RUN yum update -y && yum clean all
8 RUN yum install -y gcc make zlib-devel openssl-devel tcl-devel && yum clean all
9 RUN groupadd -r fossil -g 433 && useradd -u 431 -r -g fossil -d /opt/fossil -s /sbin/nologin -c "Fossil user" fossil
10
11 ### If you want to build "release", change the next line accordingly.
12 ENV FOSSIL_INSTALL_VERSION trunk
13
14 RUN curl "http://www.fossil-scm.org/index.html/tarball/fossil-src.tar.gz?name=fossil-src&uuid=${FOSSIL_INSTALL_VERSION}" | tar zx
15 RUN cd fossil-src && ./configure --lineedit=0 --json --with-tcl --with-tcl-stubs --with-tcl-private-stubs && make;
16 RUN cp fossil-src/fossil /usr/bin
17 RUN rm -rf fossil-src
18 RUN chmod a+rx /usr/bin/fossil
19 RUN mkdir -p /opt/fossil
20
+29 -6
--- src/db.c
+++ src/db.c
@@ -1311,10 +1311,38 @@
13111311
"INSERT OR IGNORE INTO user(login,pw,cap,info)"
13121312
" VALUES('reader','','kptw','Reader');"
13131313
);
13141314
}
13151315
}
1316
+
1317
+/*
1318
+** This function sets the server and project codes if they do not already
1319
+** exist. Currently, it should be called only by the db_initial_setup()
1320
+** or cmd_webserver() functions, the latter being used to facilitate more
1321
+** robust integration with "canned image" environments (e.g. Docker).
1322
+*/
1323
+void db_setup_server_and_project_codes(
1324
+ int optional
1325
+){
1326
+ if( !optional ){
1327
+ db_multi_exec(
1328
+ "INSERT INTO config(name,value,mtime)"
1329
+ " VALUES('server-code', lower(hex(randomblob(20))),now());"
1330
+ "INSERT INTO config(name,value,mtime)"
1331
+ " VALUES('project-code', lower(hex(randomblob(20))),now());"
1332
+ );
1333
+ }else{
1334
+ db_optional_sql("repository",
1335
+ "INSERT INTO config(name,value,mtime)"
1336
+ " VALUES('server-code', lower(hex(randomblob(20))),now());"
1337
+ );
1338
+ db_optional_sql("repository",
1339
+ "INSERT INTO config(name,value,mtime)"
1340
+ " VALUES('project-code', lower(hex(randomblob(20))),now());"
1341
+ );
1342
+ }
1343
+}
13161344
13171345
/*
13181346
** Return a pointer to a string that contains the RHS of an IN operator
13191347
** that will select CONFIG table names that are in the list of control
13201348
** settings.
@@ -1364,16 +1392,11 @@
13641392
13651393
db_set("content-schema", CONTENT_SCHEMA, 0);
13661394
db_set("aux-schema", AUX_SCHEMA, 0);
13671395
db_set("rebuilt", get_version(), 0);
13681396
if( makeServerCodes ){
1369
- db_multi_exec(
1370
- "INSERT INTO config(name,value,mtime)"
1371
- " VALUES('server-code', lower(hex(randomblob(20))),now());"
1372
- "INSERT INTO config(name,value,mtime)"
1373
- " VALUES('project-code', lower(hex(randomblob(20))),now());"
1374
- );
1397
+ db_setup_server_and_project_codes(0);
13751398
}
13761399
if( !db_is_global("autosync") ) db_set_int("autosync", 1, 0);
13771400
if( !db_is_global("localauth") ) db_set_int("localauth", 0, 0);
13781401
if( !db_is_global("timeline-plaintext") ){
13791402
db_set_int("timeline-plaintext", 1, 0);
13801403
--- src/db.c
+++ src/db.c
@@ -1311,10 +1311,38 @@
1311 "INSERT OR IGNORE INTO user(login,pw,cap,info)"
1312 " VALUES('reader','','kptw','Reader');"
1313 );
1314 }
1315 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1316
1317 /*
1318 ** Return a pointer to a string that contains the RHS of an IN operator
1319 ** that will select CONFIG table names that are in the list of control
1320 ** settings.
@@ -1364,16 +1392,11 @@
1364
1365 db_set("content-schema", CONTENT_SCHEMA, 0);
1366 db_set("aux-schema", AUX_SCHEMA, 0);
1367 db_set("rebuilt", get_version(), 0);
1368 if( makeServerCodes ){
1369 db_multi_exec(
1370 "INSERT INTO config(name,value,mtime)"
1371 " VALUES('server-code', lower(hex(randomblob(20))),now());"
1372 "INSERT INTO config(name,value,mtime)"
1373 " VALUES('project-code', lower(hex(randomblob(20))),now());"
1374 );
1375 }
1376 if( !db_is_global("autosync") ) db_set_int("autosync", 1, 0);
1377 if( !db_is_global("localauth") ) db_set_int("localauth", 0, 0);
1378 if( !db_is_global("timeline-plaintext") ){
1379 db_set_int("timeline-plaintext", 1, 0);
1380
--- src/db.c
+++ src/db.c
@@ -1311,10 +1311,38 @@
1311 "INSERT OR IGNORE INTO user(login,pw,cap,info)"
1312 " VALUES('reader','','kptw','Reader');"
1313 );
1314 }
1315 }
1316
1317 /*
1318 ** This function sets the server and project codes if they do not already
1319 ** exist. Currently, it should be called only by the db_initial_setup()
1320 ** or cmd_webserver() functions, the latter being used to facilitate more
1321 ** robust integration with "canned image" environments (e.g. Docker).
1322 */
1323 void db_setup_server_and_project_codes(
1324 int optional
1325 ){
1326 if( !optional ){
1327 db_multi_exec(
1328 "INSERT INTO config(name,value,mtime)"
1329 " VALUES('server-code', lower(hex(randomblob(20))),now());"
1330 "INSERT INTO config(name,value,mtime)"
1331 " VALUES('project-code', lower(hex(randomblob(20))),now());"
1332 );
1333 }else{
1334 db_optional_sql("repository",
1335 "INSERT INTO config(name,value,mtime)"
1336 " VALUES('server-code', lower(hex(randomblob(20))),now());"
1337 );
1338 db_optional_sql("repository",
1339 "INSERT INTO config(name,value,mtime)"
1340 " VALUES('project-code', lower(hex(randomblob(20))),now());"
1341 );
1342 }
1343 }
1344
1345 /*
1346 ** Return a pointer to a string that contains the RHS of an IN operator
1347 ** that will select CONFIG table names that are in the list of control
1348 ** settings.
@@ -1364,16 +1392,11 @@
1392
1393 db_set("content-schema", CONTENT_SCHEMA, 0);
1394 db_set("aux-schema", AUX_SCHEMA, 0);
1395 db_set("rebuilt", get_version(), 0);
1396 if( makeServerCodes ){
1397 db_setup_server_and_project_codes(0);
 
 
 
 
 
1398 }
1399 if( !db_is_global("autosync") ) db_set_int("autosync", 1, 0);
1400 if( !db_is_global("localauth") ) db_set_int("localauth", 0, 0);
1401 if( !db_is_global("timeline-plaintext") ){
1402 db_set_int("timeline-plaintext", 1, 0);
1403
+2 -7
--- src/main.c
+++ src/main.c
@@ -2197,17 +2197,12 @@
21972197
}else{
21982198
zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser);
21992199
}
22002200
if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
22012201
if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
2202
- }else if( db_get("server-code", 0)==0 ){
2203
- db_multi_exec(
2204
- "INSERT INTO config(name,value,mtime)"
2205
- " VALUES('server-code', lower(hex(randomblob(20))),now());"
2206
- "INSERT INTO config(name,value,mtime)"
2207
- " VALUES('project-code', lower(hex(randomblob(20))),now());"
2208
- );
2202
+ }else if( db_get("server-code", 0)==0 || db_get("project-code", 0)==0 ){
2203
+ db_setup_server_and_project_codes(1);
22092204
}
22102205
db_close(1);
22112206
if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
22122207
fossil_fatal("unable to listen on TCP socket %d", iPort);
22132208
}
22142209
--- src/main.c
+++ src/main.c
@@ -2197,17 +2197,12 @@
2197 }else{
2198 zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser);
2199 }
2200 if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
2201 if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
2202 }else if( db_get("server-code", 0)==0 ){
2203 db_multi_exec(
2204 "INSERT INTO config(name,value,mtime)"
2205 " VALUES('server-code', lower(hex(randomblob(20))),now());"
2206 "INSERT INTO config(name,value,mtime)"
2207 " VALUES('project-code', lower(hex(randomblob(20))),now());"
2208 );
2209 }
2210 db_close(1);
2211 if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
2212 fossil_fatal("unable to listen on TCP socket %d", iPort);
2213 }
2214
--- src/main.c
+++ src/main.c
@@ -2197,17 +2197,12 @@
2197 }else{
2198 zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser);
2199 }
2200 if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
2201 if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
2202 }else if( db_get("server-code", 0)==0 || db_get("project-code", 0)==0 ){
2203 db_setup_server_and_project_codes(1);
 
 
 
 
 
2204 }
2205 db_close(1);
2206 if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
2207 fossil_fatal("unable to listen on TCP socket %d", iPort);
2208 }
2209

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button