From 9021184cd2cbc18109d388bc6c2e3e7703cb6621 Mon Sep 17 00:00:00 2001 From: nishi Date: Sat, 11 May 2024 01:22:48 +0000 Subject: [PATCH] addding installer git-svn-id: file:///raid/svn-main/nishi-mandshurica/trunk@76 f982e544-4a7d-3444-ad1a-fde59a2a69f1 --- GNUmakefile | 11 ++++++++++- Mandshurica/GNUmakefile | 5 ++++- Mandshurica/config.c | 8 ++++---- Module/GNUmakefile | 5 ++++- Module/cookie.c | 17 ++++++++++++++--- Tool/GNUmakefile | 7 +++++-- Webroot/GNUmakefile | 5 +++++ Webroot/manage/index.html.tmpl | 16 ++++++++++++++++ 8 files changed, 62 insertions(+), 12 deletions(-) create mode 100644 Webroot/manage/index.html.tmpl diff --git a/GNUmakefile b/GNUmakefile index 84ce8d2..ae23bca 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,6 +1,6 @@ # $Id$ PREFIX := /usr/local -MODULE_PREFIX := $(PREFIX)/lib/mandshurica +MODULE_PREFIX := $(PREFIX)/lib/mandshurica/module WEBROOT_PREFIX := $(PREFIX)/lib/mandshurica/webroot PROJECTS_PREFIX := $(PREFIX)/lib/mandshurica/projects TOOL_PREFIX := $(PREFIX)/lib/mandshurica/tool @@ -35,6 +35,15 @@ replace: echo done; \ done +install: all + mkdir -p $(PREFIX) $(MODULE_PREFIX) $(WEBROOT_PREFIX) $(PROJECTS_PREFIX) $(TOOL_PREFIX) $(PREFIX)/etc $(PREFIX)/bin $(PREFIX)/lib/mandshurica/db + touch $(PREFIX)/lib/mandshurica/db/auth.db $(PREFIX)/lib/mandshurica/db/login.db $(PREFIX)/lib/mandshurica/db/project.db + ./Mandshurica/mandshurica --create $(PREFIX)/etc/mandshurica.conf + $(MAKE) -C ./Mandshurica install PREFIX="$(PREFIX)" MODULE_PREFIX="$(MODULE_PREFIX)" PROJECTS_PREFIX="$(PROJECTS_PREFIX)" TOOL_PREFIX="$(TOOL_PREFIX)" WEBROOT_PREFIX="$(WEBROOT_PREFIX)" + $(MAKE) -C ./Module install PREFIX="$(PREFIX)" MODULE_PREFIX="$(MODULE_PREFIX)" PROJECTS_PREFIX="$(PROJECTS_PREFIX)" TOOL_PREFIX="$(TOOL_PREFIX)" WEBROOT_PREFIX="$(WEBROOT_PREFIX)" + $(MAKE) -C ./Tool install PREFIX="$(PREFIX)" MODULE_PREFIX="$(MODULE_PREFIX)" PROJECTS_PREFIX="$(PROJECTS_PREFIX)" TOOL_PREFIX="$(TOOL_PREFIX)" WEBROOT_PREFIX="$(WEBROOT_PREFIX)" + $(MAKE) -C ./Webroot install PREFIX="$(PREFIX)" MODULE_PREFIX="$(MODULE_PREFIX)" PROJECTS_PREFIX="$(PROJECTS_PREFIX)" TOOL_PREFIX="$(TOOL_PREFIX)" WEBROOT_PREFIX="$(WEBROOT_PREFIX)" + clean: $(MAKE) -C ./Mandshurica clean $(MAKE) -C ./Module clean diff --git a/Mandshurica/GNUmakefile b/Mandshurica/GNUmakefile index 5848491..bd7e82b 100644 --- a/Mandshurica/GNUmakefile +++ b/Mandshurica/GNUmakefile @@ -4,7 +4,7 @@ EXTRA_CFLAGS = -pthread EXTRA_LDFLAGS = EXTRA_LIBS = -pthread -lcrypto -.PHONY: all clean +.PHONY: all clean install ifeq ($(shell uname -s),Linux) EXTRA_LIBS += -ldl @@ -21,5 +21,8 @@ all: ./mandshurica ./%.o: ./%.c ./mandshurica%.h $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $< +install: + cp ./mandshurica $(PREFIX)/bin/ + clean: rm -f ./mandshurica ./*.o diff --git a/Mandshurica/config.c b/Mandshurica/config.c index 5524d31..bc4fc05 100644 --- a/Mandshurica/config.c +++ b/Mandshurica/config.c @@ -155,7 +155,7 @@ int mandshurica_load_config(const char* path) { if(value[0] == '/') { path = mandshurica_strdup(value); } else { - path = mandshurica_strcat3(server_root, "/", value); + path = mandshurica_strcat3(server_root, "/lib/mandshurica/module/", value); } void* lib = dlopen(path, RTLD_LAZY); if(lib != NULL) { @@ -211,9 +211,9 @@ int mandshurica_create_config(const char* path) { fprintf(f, "# Generated by Mandshurica " MANDSHURICA_VERSION "\n"); fprintf(f, "ServerRoot %s\n", PREFIX); fprintf(f, "\n"); - fprintf(f, "Set LoginDB %s/login.db\n", PREFIX); - fprintf(f, "Set CookieDB %s/cookie.db\n", PREFIX); - fprintf(f, "Set ProjectDB %s/project.db\n", PREFIX); + fprintf(f, "Set AuthDB %s/lib/mandshurica/db/auth.db\n", PREFIX); + fprintf(f, "Set LoginDB %s/lib/mandshurica/db/login.db\n", PREFIX); + fprintf(f, "Set ProjectDB %s/lib/mandshurica/db/project.db\n", PREFIX); fprintf(f, "Set HTTPPort 1024\n"); fprintf(f, "Set HTTPRoot %s\n", WEBROOT_PREFIX); fprintf(f, "Set HTMLManage %s/html-manage\n", TOOL_PREFIX); diff --git a/Module/GNUmakefile b/Module/GNUmakefile index d73b1e5..66fee1b 100644 --- a/Module/GNUmakefile +++ b/Module/GNUmakefile @@ -4,7 +4,7 @@ EXTRA_CFLAGS = -fPIC EXTRA_LDFLAGS = -shared EXTRA_LIBS = -.PHONY: all clean +.PHONY: all clean install ifeq ($(shell uname -s),Linux) EXTRA_LIBS += -ldl @@ -27,5 +27,8 @@ all: ./subversion.so ./syslog.so ./http.so ./cookie.so ./%.o: ./%.c ../Mandshurica/mandshurica.h $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $< +install: + cp *.so $(MODULE_PREFIX)/ + clean: rm -f *.so *.o diff --git a/Module/cookie.c b/Module/cookie.c index ddcab9e..7daae93 100644 --- a/Module/cookie.c +++ b/Module/cookie.c @@ -49,10 +49,10 @@ int mod_init(struct mandshurica_config* _config) { config = _config; config->mandshurica_log(MS_INFO, "Cookie authentication Module init"); - char* db = config->mandshurica_get_param("CookieDB"); + char* db = config->mandshurica_get_param("AuthDB"); if(db == NULL) { - config->mandshurica_log(MS_ERROR, "Cookie authentication Database path is not set!"); + config->mandshurica_log(MS_ERROR, "Cookie authentication Database path is not set! (AuthDB)"); return 1; } @@ -60,6 +60,17 @@ int mod_init(struct mandshurica_config* _config) { config->mandshurica_log(MS_INFO, log); free(log); + db = config->mandshurica_get_param("LoginDB"); + + if(db == NULL) { + config->mandshurica_log(MS_ERROR, "Cookie token Database path is not set! (LoginDB)"); + return 1; + } + + log = mandshurica_strcat("Cookie token Database is ", db); + config->mandshurica_log(MS_INFO, log); + free(log); + return 0; } @@ -96,7 +107,7 @@ int mod_auth(const char* username, const char* password, char** ptr) { } if(login) { *ptr = NULL; - struct ms_db* db = mandshurica_db_open(config->mandshurica_get_param("CookieDB")); + struct ms_db* db = mandshurica_db_open(config->mandshurica_get_param("AuthDB")); if(db != NULL) { char* pwd = mandshurica_db_get(db, username); if(pwd == NULL) { diff --git a/Tool/GNUmakefile b/Tool/GNUmakefile index da09fae..054ac96 100644 --- a/Tool/GNUmakefile +++ b/Tool/GNUmakefile @@ -4,7 +4,7 @@ EXTRA_CFLAGS = EXTRA_LDFLAGS = EXTRA_LIBS = -.PHONY: all clean +.PHONY: all clean install all: ./html-manage @@ -19,6 +19,9 @@ all: ./html-manage ./db.o: ../Mandshurica/db.c $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $< - + +install: + cp ./html-manage $(TOOL_PREFIX)/ + clean: rm -f ./html-manage *.o diff --git a/Webroot/GNUmakefile b/Webroot/GNUmakefile index fbbab2d..0fb322d 100644 --- a/Webroot/GNUmakefile +++ b/Webroot/GNUmakefile @@ -1 +1,6 @@ # $Id$ +.PHONY: install + +install: + cp -rf * $(WEBROOT_PREFIX)/ + rm $(WEBROOT_PREFIX)/GNUmakefile diff --git a/Webroot/manage/index.html.tmpl b/Webroot/manage/index.html.tmpl new file mode 100644 index 0000000..4df128d --- /dev/null +++ b/Webroot/manage/index.html.tmpl @@ -0,0 +1,16 @@ + +@include head-start.html@ +Mandshurica - Manage +@include body-start.html@ +

Mandshurica - Manage

+@include bar.html@ +@ifnot login@ +You are not authorized to see this page. Login? +@endif@ +@if login@ +Manage your projects here.
+@exec $Config_HTMLManage $Config_ProjectDB@ +@endif@ +@include end.html@ -- 2.43.0