| | @@ -1311,10 +1311,38 @@ |
| 1311 | 1311 | "INSERT OR IGNORE INTO user(login,pw,cap,info)" |
| 1312 | 1312 | " VALUES('reader','','kptw','Reader');" |
| 1313 | 1313 | ); |
| 1314 | 1314 | } |
| 1315 | 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 | +} |
| 1316 | 1344 | |
| 1317 | 1345 | /* |
| 1318 | 1346 | ** Return a pointer to a string that contains the RHS of an IN operator |
| 1319 | 1347 | ** that will select CONFIG table names that are in the list of control |
| 1320 | 1348 | ** settings. |
| | @@ -1364,16 +1392,11 @@ |
| 1364 | 1392 | |
| 1365 | 1393 | db_set("content-schema", CONTENT_SCHEMA, 0); |
| 1366 | 1394 | db_set("aux-schema", AUX_SCHEMA, 0); |
| 1367 | 1395 | db_set("rebuilt", get_version(), 0); |
| 1368 | 1396 | 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); |
| 1375 | 1398 | } |
| 1376 | 1399 | if( !db_is_global("autosync") ) db_set_int("autosync", 1, 0); |
| 1377 | 1400 | if( !db_is_global("localauth") ) db_set_int("localauth", 0, 0); |
| 1378 | 1401 | if( !db_is_global("timeline-plaintext") ){ |
| 1379 | 1402 | db_set_int("timeline-plaintext", 1, 0); |
| 1380 | 1403 | |