Режик на OpenBSD
Добавлено: Пт ноя 25, 2005 0:37
Собрал и настроил Режик на OpenBSD (сквид ставил из портов). Пришлось чуть подправить код чтобы собралось, при этом сделал использование программы install при работе 'make install'. Вот патч:
Код: Выделить всё
diff redirector/Makefile redirector.openbsd/Makefile
--- redirector/Makefile Thu Sep 30 17:50:40 2004
+++ redirector.openbsd/Makefile Sun Nov 20 00:15:18 2005
@@ -1,58 +1,73 @@
+# Makefile for build the Rejik on OpenBSD
+#
+
### Edit this:
-INSTALL_PATH=/usr/local/rejik3
-SQUID_USER=nobody
-SQUID_GROUP=nogroup
+CONFIG=/etc/squid/rejik3/redirector.conf
+INSTALL_PATH=/usr/local/libexec/rejik3
+CONFIG_PATH=/etc/squid/rejik3
+DATA_PATH=/var/squid/rejik3
+SQUID_USER=_squid
+SQUID_GROUP=_squid
CC=gcc -Wall
+CDEFS= -DDEFAULT_CONFIG=\"$(CONFIG)\"
INCLUDE=-I/usr/include -I/usr/local/include -I/usr/include/pcre
LIBS=-L/lib `pcre-config --libs`
+INSTALLDIR=install -d
+INSTALL=install
+CFGPERM=644
+DATAPERM=644
+BINPERM=555
+CFGDIRPERM=755
+BINDIRPERM=555
+DATADIRPERM=755
+DATAOWNER=-o $(SQUID_USER) -g $(SQUID_GROUP)
+
### Don't edit
-COMMON_OBJ=err_mes.o now.o get_opt.o parse_urls.o cache2url.o ip.o id.o comparing.o
-REDIRECTOR_OBJ= pass.o raw_change.o load_cache.o pcre.o parse_input.o init_vars.o check_urls.o run_make_cache.o new_url.o redirect.o ${COMMON_OBJ}
-MAKE-CACHE_OBJ= load_urls.o prune_urls.o write_cache.o need_cache_update.o ${COMMON_OBJ}
+COMMON_OBJ=err_mes.o now.o get_opt.o parse_urls.o cache2url.o ip.o id.o comparing.o
+REDIRECTOR_OBJ= pass.o raw_change.o load_cache.o pcre.o parse_input.o init_vars.o check_urls.o run_make_cache.o new_url.o redirect.o ${COMMON_OBJ)
+MAKE-CACHE_OBJ= load_urls.o prune_urls.o write_cache.o need_cache_update.o ${COMMON_OBJ)
.c.o: vars.h
- ${CC} ${INCLUDE} -c $<
+ $(CC) $(INCLUDE) -c $<
-all: clean ${REDIRECTOR_OBJ} ${MAKE-CACHE_OBJ}
- ${CC} ${INCLUDE} -o redirector redirector.c ${LIBS} ${REDIRECTOR_OBJ}
- ${CC} ${INCLUDE} -o make-cache make-cache.c ${LIBS} ${MAKE-CACHE_OBJ}
+all: clean $(REDIRECTOR_OBJ) $(MAKE-CACHE_OBJ)
+ $(CC) $(INCLUDE) -o redirector redirector.c $(LIBS) $(REDIRECTOR_OBJ)
+ $(CC) $(INCLUDE) -o make-cache make-cache.c $(LIBS) $(MAKE-CACHE_OBJ)
clean:
- rm -f ${REDIRECTOR_OBJ} ${MAKE-CACHE_OBJ} redirector make-cache OUT
+ rm -f $(REDIRECTOR_OBJ) $(MAKE-CACHE_OBJ) redirector make-cache OUT
-install:
+install:
# Make dirs
- mkdir -p ${INSTALL_PATH}/tools
+ $(INSTALLDIR) -m $(BINDIRPERM) $(INSTALL_PATH)/tools
+ $(INSTALLDIR) -m $(CFGDIRPERM) $(CONFIG_PATH)
+ $(INSTALLDIR) -m $(DATADIRPERM) $(DATAOWNER) $(DATA_PATH)
# Install redirector
- cp make-cache ${INSTALL_PATH}
- cp redirector ${INSTALL_PATH}
- cp redirector.conf.dist ${INSTALL_PATH}
+ $(INSTALL) -c -m $(BINPERM) make-cache $(INSTALL_PATH)
+ $(INSTALL) -c -m $(BINPERM) redirector $(INSTALL_PATH)
+ $(INSTALL) -c -m $(BINPERM) redirector.conf.dist $(CONFIG_PATH)
# Install tools
- echo "#!/bin/sh" > ${INSTALL_PATH}/tools/check-redirector
- echo 'su ${SQUID_USER} -c "echo \"http://sex.ru 127.0.0.1/- - GET\" | ${INSTALL_PATH}/redirector ${INSTALL_PATH}/redirector.conf;"' >> ${INSTALL_PATH}/tools/check-redirector
- chmod 755 ${INSTALL_PATH}/tools/check-redirector
+ echo "#!/bin/sh" > check-redirector
+ echo 'su $(SQUID_USER) -c "echo \"http://sex.ru 127.0.0.1/- - GET\" | $(INSTALL_PATH)/redirector $(INSTALL_PATH)/redirector.conf;"' >>check-redirector
+ $(INSTALL) -m $(BINPERM) check-redirector $(INSTALL_PATH)/tools
- echo "#!/bin/sh" > ${INSTALL_PATH}/tools/set-permissions
- echo 'chown -R ${SQUID_USER}:${SQUID_GROUP} ${INSTALL_PATH}' >> ${INSTALL_PATH}/tools/set-permissions
- chmod 755 ${INSTALL_PATH}/tools/set-permissions
+ echo "#!/bin/sh" > set-permissions
+ echo 'chown -R $(SQUID_USER):$(SQUID_GROUP) $(DATA_PATH)' >> set-permissions
+ $(INSTALL) -m $(BINPERM) set-permissions $(INSTALL_PATH)/tools/set-permissions
+ $(INSTALL) -m $(BINPERM) tools/kill-cache $(INSTALL_PATH)/tools
- cp tools/kill-cache ${INSTALL_PATH}/tools
- chmod 755 ${INSTALL_PATH}/tools/kill-cache
+ $(INSTALL) -m $(BINPERM) tools/benchmark $(INSTALL_PATH)/tools
- cp tools/benchmark ${INSTALL_PATH}/tools
- chmod 755 ${INSTALL_PATH}/tools/benchmark
+ $(INSTALL) -m $(CFGPERM) tools/IN.gz $(INSTALL_PATH)/tools
- cp tools/IN.gz ${INSTALL_PATH}/tools
- chmod 644 ${INSTALL_PATH}/tools/IN.gz
-
# Set permissions
- chown -R ${SQUID_USER}:${SQUID_GROUP} ${INSTALL_PATH}
- chmod 770 ${INSTALL_PATH}
- chmod 644 ${INSTALL_PATH}/redirector.conf.dist
- chmod 755 ${INSTALL_PATH}/redirector
- chmod 755 ${INSTALL_PATH}/make-cache
+ chown -R $(SQUID_USER):$(SQUID_GROUP) $(INSTALL_PATH)
+ chmod 770 $(INSTALL_PATH)
+ chmod 644 $(CONFIG_PATH)/redirector.conf.dist
+ chmod 755 $(INSTALL_PATH)/redirector
+ chmod 755 $(INSTALL_PATH)/make-cache
Common subdirectories: redirector/tools and redirector.openbsd/tools
diff redirector/vars.h redirector.openbsd/vars.h
--- redirector/vars.h Thu Oct 21 16:20:23 2004
+++ redirector.openbsd/vars.h Sun Nov 20 00:16:13 2005
@@ -1,10 +1,12 @@
#include <stdio.h>
#include <pcre.h>
+#ifndef DEFAULT_CONFIG
#define DEFAULT_CONFIG "/usr/local/rejik3/redirector.conf"
+#endif
/*** Print debug info for develop ***/
-//#define DEBUG_CFG
+//#define DEBUG_CFG
//#define DEBUG_CYCLE
//#define DEBUG_MAKE_CACHE
//#define DEBUG_URLS_LOAD
@@ -72,7 +74,7 @@
* protocol | subdomen | twoleveldomen |port| dirs *
*****************************************************************/
struct p_url
- {
+ {
unsigned char protocol[ML_PROTOKOL];
unsigned char twoleveldomen[ML_2LD];
unsigned char port[ML_PORT];
@@ -83,7 +85,7 @@
//GLOBAL OPTIONS
unsigned char *err_log; // Error log path
unsigned char *chg_log; // Change log path
-unsigned char *makecache; // make-cache program
+unsigned char *makecache; // make-cache program
unsigned char *work_ip; //Work ip
unsigned int work_ip_count; //Work ip count
@@ -127,7 +129,7 @@
unsigned char *work_ip; //Work ip
unsigned int work_ip_count; //Work ip count
- unsigned int work_ip_flag; //Work ip flag
+ unsigned int work_ip_flag; //Work ip flag
unsigned char *allow_ip; //Allow ip
unsigned int allow_ip_count; //Allow ip count
@@ -141,7 +143,7 @@
pcre **ban_pcre; //Ban PCRE patterns
pcre_extra **ban_pcre_s; //Ban PCRE optimization
- unsigned int ban_pcre_count; //Ban PCRE patterns count
+ unsigned int ban_pcre_count; //Ban PCRE patterns count
unsigned char **ban_urls; //Ban urls lists area
unsigned int ban_urls_count; //Counter urls elements