Fossil

Diff
Login

Differences From Artifact [df88f7f101]:

To Artifact [cfa5a42c54]:


671
672
673
674
675
676
677
678
679



680
681
682

683
684
685
686
687
688
689
690
691
692
693
694










695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714

715
716
717
718
719
720
721
671
672
673
674
675
676
677


678
679
680
681


682
683
684
685
686
687
688
689





690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718

719
720
721
722
723
724
725
726







-
-
+
+
+

-
-
+







-
-
-
-
-
+
+
+
+
+
+
+
+
+
+



















-
+








/*
** Fill an empty repository database with the basic information for a
** repository. This function is shared between 'create_repository_cmd'
** ('new') and 'reconstruct_cmd' ('reconstruct'), both of which create
** new repositories.
**
** The caller determines wheter the function inserts an empty root
** manifest (zRoot == TRUE), or not (zRoot == FALSE).
** The makeInitialVersion flag determines whether or not an initial
** manifest is created.  The makeServerCodes flag determines whether or
** not server and project codes are invented for this repository.
*/

void db_initial_setup (int zRoot){
void db_initial_setup (int makeInitialVersion, int makeServerCodes){
  char *zDate;
  char *zUser;
  Blob hash;
  Blob manifest;

  db_set("content-schema", CONTENT_SCHEMA);
  db_set("aux-schema", AUX_SCHEMA);
  db_set_int("authenticate-localhost", 0);
  db_multi_exec(
    "INSERT INTO config(name,value) VALUES('server-code', hex(randomblob(20)));"
    "INSERT INTO config(name,value) VALUES('project-code',hex(randomblob(20)));"
  );
  if( makeServerCodes ){
    db_multi_exec(
      "INSERT INTO config(name,value)"
      " VALUES('server-code', lower(hex(randomblob(20))));"
      "INSERT INTO config(name,value)"
      " VALUES('project-code', lower(hex(randomblob(20))));"
    );
  }
  db_set_int("autosync", 1);
  db_set_int("localauth", 0);
  zUser = db_global_get("default-user", 0);
  if( zUser==0 ){
    zUser = getenv("USER");
  }
  if( zUser==0 ){
    zUser = "root";
  }
  db_multi_exec(
     "INSERT INTO user(login, pw, cap, info)"
     "VALUES(%Q,'','s','')", zUser
  );
  db_multi_exec(
     "INSERT INTO user(login,pw,cap,info)"
     "   VALUES('anonymous','anonymous','hjkorw','Anon');"
     "INSERT INTO user(login,pw,cap,info)"
     "   VALUES('nobody','','jor','Nobody');"
  );
  user_select();

  if (zRoot){
  if (makeInitialVersion){
    blob_zero(&manifest);
    blob_appendf(&manifest, "C initial\\sempty\\sbaseline\n");
    zDate = db_text(0, "SELECT datetime('now')");
    zDate[10]='T';
    blob_appendf(&manifest, "D %s\n", zDate);
    blob_appendf(&manifest, "P\n");
    md5sum_init();
740
741
742
743
744
745
746
747

748
749
750
751
752
753
754
745
746
747
748
749
750
751

752
753
754
755
756
757
758
759







-
+







  if( g.argc!=3 ){
    usage("REPOSITORY-NAME");
  }
  db_create_repository(g.argv[2]);
  db_open_repository(g.argv[2]);
  db_open_config();
  db_begin_transaction();
  db_initial_setup (1);
  db_initial_setup(1, 1);
  db_end_transaction(0);
  printf("project-id: %s\n", db_get("project-code", 0));
  printf("server-id:  %s\n", db_get("server-code", 0));
  printf("admin-user: %s (no password set yet!)\n", g.zLogin);
  printf("baseline:   %s\n", db_text(0, "SELECT uuid FROM blob"));
}

961
962
963
964
965
966
967
968










969
970
971
972
973

974
975
976
977
978
979
980
966
967
968
969
970
971
972

973
974
975
976
977
978
979
980
981
982
983
984
985
986

987
988
989
990
991
992
993
994







-
+
+
+
+
+
+
+
+
+
+




-
+








/*
** COMMAND: setting
** %fossil setting ?PROPERTY? ?VALUE?
**
** With no arguments, list all properties and their values.  With just
** a property name, show the value of that property.  With a value
** arugment, change the property for the current repository.
** argument, change the property for the current repository.
**
**    autosync         If enabled, automatically pull prior to
**                     commit or update and automatically push
**                     after commit or tag or branch creation.
**
**    localauth        If true, require that HTTP connections from
**                     127.0.0.1 be authenticated by password.  If
**                     false, all HTTP requests from localhost have
**                     unrestricted access to the repository.
*/
void setting_cmd(void){
  static const char *azName[] = {
    "autosync",
    "safemerge"
    "localauth"
  };
  int i;
  db_find_and_open_repository();
  if( g.argc==2 ){
    for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
      printf("%-20s %d\n", azName[i], db_get_int(azName[i], 0));
    }