diff options
-rwxr-xr-x | etc/init.d/uanytun | 6 | ||||
-rw-r--r-- | src/Makefile | 47 | ||||
-rwxr-xr-x | src/configure | 22 |
3 files changed, 69 insertions, 6 deletions
diff --git a/etc/init.d/uanytun b/etc/init.d/uanytun index 3181525..518b5c6 100755 --- a/etc/init.d/uanytun +++ b/etc/init.d/uanytun @@ -11,10 +11,9 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/sbin/uanytun CHROOTDIR='/var/run/uanytun' -# DAEMONOPTS="--username nobody --groupname nogroup --chroot $CHROOTDIR" +CONFIG_DIR=/etc/uanytun NAME=uanytun DESC=uanytun -CONFIG_DIR=/etc/uanytun test -x $DAEMON || exit 0 @@ -29,8 +28,7 @@ start_vpn () { POSTUP='' test -f $CONFIG_DIR/$NAME/post-up.sh && POSTUP="-x $CONFIG_DIR/$NAME/post-up.sh" DAEMONARG=`sed 's/#.*//' < $CONFIG_DIR/$NAME/config | grep -e '\w' | sed 's/^/--/' | tr '\n' ' '` - $DAEMON --write-pid /var/run/uanytun.$NAME.pid $POSTUP \ - $DAEMONOPTS $DAEMONARG || STATUS="FAILED" + $DAEMON --write-pid /var/run/uanytun.$NAME.pid $POSTUP $DAEMONARG || STATUS="FAILED" else STATUS="no config found" fi diff --git a/src/Makefile b/src/Makefile index 1d0d5c6..89570a2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -56,7 +56,7 @@ endif SRC := $(OBJ:%.o=%.c) -.PHONY: distclean clean +.PHONY: clean distclean manpage install install-bin install-etc install-man remove purge all: $(EXECUTABLE) @@ -85,3 +85,48 @@ clean: rm -f *.o rm -f *.d rm -f $(EXECUTABLE) + +manpage: + $(MAKE) --directory="../doc/" manpage + +install: install-bin install-etc install-man + +install-bin: $(EXECUTABLE) + mkdir -p $(DESTDIR)$(SBINDIR) + install -m 755 $(EXECUTABLE) $(DESTDIR)$(SBINDIR) + $(STRIP) $(DESTDIR)$(SBINDIR)/$(EXECUTABLE) + +install-etc: + mkdir -p $(DESTDIR)$(ETCDIR)/uanytun + install -m 644 ../etc/uanytun/autostart $(DESTDIR)$(ETCDIR)/uanytun/autostart + @( cd '../etc/uanytun/' ; \ + for dir in `ls`; do \ + if [ -d $$dir ]; then \ + echo "install $$dir configuration" ; \ + cd $$dir ; \ + mkdir -p $(DESTDIR)$(ETCDIR)/uanytun/$$dir ; \ + install -m 600 config $(DESTDIR)$(ETCDIR)/uanytun/$$dir/config ; \ + if [ -e 'post-up.sh' ]; then \ + install -m 755 post-up.sh $(DESTDIR)$(ETCDIR)/uanytun/$$dir/post-up.sh ; \ + fi ; \ + cd .. ; \ + fi ; \ + done \ + ) + mkdir -p $(DESTDIR)$(ETCDIR)/init.d + install -m 755 ../etc/init.d/uanytun $(DESTDIR)$(ETCDIR)/init.d/$(EXECUTABLE) + @ sed -i 's#DAEMON=/usr/sbin/uanytun#DAEMON=$(SBINDIR)/$(EXECUTABLE)#' $(DESTDIR)$(ETCDIR)/init.d/$(EXECUTABLE) + @ sed -i 's#CONFIG_DIR=/etc/uanytun#CONFIG_DIR=$(ETCDIR)/uanytun#' $(DESTDIR)$(ETCDIR)/init.d/$(EXECUTABLE) + +install-man: manpage + mkdir -p $(DESTDIR)$(MANDIR)/man8/ + cp ../doc/uanytun.8 $(DESTDIR)$(MANDIR)/man8/$(EXECUTABLE).8 + gzip $(DESTDIR)$(MANDIR)/man8/$(EXECUTABLE).8 + +remove: + rm -f $(DESTDIR)$(SBINDIR)/$(EXECUTABLE) + rm -f $(DESTDIR)$(MANDIR)/man8/$(EXECUTABLE).8.gz + rm -f $(DESTDIR)$(ETCDIR)/init.d/$(EXECUTABLE) + +purge: remove + rm -rf $(DESTDIR)$(ETCDIR)/uanytun/ diff --git a/src/configure b/src/configure index cad9c57..a1608ef 100755 --- a/src/configure +++ b/src/configure @@ -43,9 +43,12 @@ ANYTUN_02_COMPAT=0 PASSPHRASE=1 V4_MAPPED=1 +PREFIX='/usr/local' + print_usage() { echo "configure --help print this" - echo " --target=<TARGET> build target i.e. Linux" + echo " --target=<TARGET> build target i.e. Linux (default: autodetect)" + echo " --prefix=<PREFIX> the installation prefix (default: /usr/local)" echo " --use-ssl-crypto use ssl crypto library instead of libgcrypt" echo " --disable-crypto disable crypto at all (only NULL cipher)" echo " --enable-anytun02-compat enable compatiblity mode for anytun 0.2.x and prior" @@ -60,6 +63,9 @@ do --target=*) TARGET=${arg#--target=} ;; + --prefix=*) + PREFIX=${arg#--prefix=} + ;; --use-ssl-crypto) CRYPTO_LIB='ssl' ;; @@ -144,11 +150,25 @@ if [ $V4_MAPPED -eq 0 ]; then echo "WARNING: disabling V4 mapped addresses, this prevents uanytun from using IPv6 as outer Protocol" fi +if [ "x$PREFIX" = "x/usr" ]; then + ETCDIR=/etc +else + ETCDIR=$PREFIX/etc +fi + cat >> include.mk <<EOF +# this file was created automatically +# do not edit this file directly +# use ./configure instead + TARGET := $TARGET CC := gcc CFLAGS := $CFLAGS LDFLAGS := $LDFLAGS + +SBINDIR := $PREFIX/sbin +MANDIR := $PREFIX/share/man +ETCDIR := $ETCDIR EOF exit 0 |