diff --git a/INSTALL b/INSTALL index 7ca4d68..5135fa4 100644 --- a/INSTALL +++ b/INSTALL @@ -47,12 +47,16 @@ make your access lists. Running with traditional inetd superserver ========================================== -If you want to run Gophernicus under the traditional Unix -inetd, add the below line to your /etc/inetd.conf and restart -the inetd process. +If you want to run Gophernicus under the traditional Unix inetd, the +below line should be added to your /etc/inetd.conf and the inetd +process restarted. gopher stream tcp nowait nobody /usr/sbin/in.gophernicus in.gophernicus -h +The Makefile will automatically do this for you if you have the +update(1) script installed, which is the usual case in most current +flavors of Linux and BSD. + Compiling on Debian Linux (and Ubuntu) ====================================== diff --git a/Makefile b/Makefile index 86f112b..8b8bdc7 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,8 @@ MAP = gophermap INETD = /etc/inetd.conf XINETD = /etc/xinetd.d +INETLIN = "gopher stream tcp nowait nobody $(SBINDIR)/$(BINARY) $(BINARY) -h `hostname`" +INETPID = /var/run/inetd.pid LAUNCHD = /Library/LaunchDaemons PLIST = org.$(NAME).server.plist NET_SRV = /boot/common/settings/network/services @@ -44,7 +46,7 @@ DEFAULT = /etc/default CC = gcc HOSTCC = $(CC) CFLAGS = -O2 -Wall -LDFLAGS = +LDFLAGS = IPCRM = /usr/bin/ipcrm @@ -52,7 +54,7 @@ IPCRM = /usr/bin/ipcrm # # Platform support, compatible with both BSD and GNU make # -all: +all: headers @case `uname` in \ Darwin) $(MAKE) ROOT="$(OSXROOT)" DESTDIR="$(OSXDEST)" $(BINARY); ;; \ Haiku) $(MAKE) EXTRA_LIBS="-lnetwork" $(BINARY); ;; \ @@ -85,8 +87,8 @@ ChangeLog: # # Building # -$(NAME).c: $(NAME).h $(HEADERS) - +$(NAME).c: headers $(NAME).h + $(BINARY): $(OBJECTS) $(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) $(OBJECTS) $(EXTRA_LIBS) -o $@ @@ -149,7 +151,7 @@ install: ChangeLog clean-shm esac @if [ -d "$(HAS_STD)" ]; then $(MAKE) install-systemd install-done; \ elif [ -d "$(XINETD)" ]; then $(MAKE) install-xinetd install-done; \ - elif [ -f "$(INETD)" ]; then $(MAKE) install-inetd; fi + elif [ -f "$(INETD)" ]; then $(MAKE) install-inetd install-done; fi .PHONY: install @@ -157,6 +159,7 @@ install-done: @echo @echo "======================================================================" @echo + @echo "If there were no errors shown above," @echo "Gophernicus has now been succesfully installed. To try it out, launch" @echo "your favorite gopher browser and navigate to your gopher root." @echo @@ -173,7 +176,7 @@ install-done: @echo "======================================================================" @echo -install-files: +install-files: $(BINARY) mkdir -p $(SBINDIR) $(INSTALL) -s -m 755 $(BINARY) $(SBINDIR) @echo @@ -191,21 +194,20 @@ install-root: fi @echo -install-inetd: - @echo - @echo "======================================================================" - @echo - @echo "Looks like your system has the traditional internet superserver inetd." - @echo "Automatic installations aren't supported, so please add the following" - @echo "line to the end of your /etc/inetd.conf and restart or kill -HUP the" - @echo "inetd process." - @echo - @echo "gopher stream tcp nowait nobody $(SBINDIR)/$(BINARY) $(BINARY) -h `hostname`" - @echo - @echo "======================================================================" +install-inetd: install-files install-docs install-root + @if update-inetd --add $(INETLIN); then \ + echo update-inetd install worked ; \ + else if grep '^gopher' $(INETD) >/dev/null 2>&1 ; then \ + echo "::::: Gopher entry in $(INETD) already present -- please check! :::::"; \ + else echo "Trying to add gopher entry to $(INETD)" ; \ + echo "$(INETLIN)" >> $(INETD) ; \ + if [ -r $(INETPID) ] ; then kill -HUP `cat $(INETPID)` ; \ + else echo "::::: No PID for inetd found, not restarted -- please check! :::::" ; fi ; \ + fi ; \ + fi @echo -install-xinetd: +install-xinetd: install-files install-docs install-root if [ -d "$(XINETD)" -a ! -f "$(XINETD)/$(NAME)" ]; then \ sed -e "s/@HOSTNAME@/`hostname`/g" $(NAME).xinetd > $(XINETD)/$(NAME); \ [ -x /sbin/service ] && /sbin/service xinetd reload; \ @@ -239,7 +241,7 @@ install-haiku: nohup /boot/system/servers/net_server >/dev/null 2>/dev/null & @echo -install-systemd: +install-systemd: install-files install-docs install-root if [ -d "$(HAS_STD)" ]; then \ if [ -d "$(SYSCONF)" -a ! -f "$(SYSCONF)/$(NAME)" ]; then \ $(INSTALL) -m 644 $(NAME).env $(SYSCONF)/$(NAME); \ @@ -262,12 +264,24 @@ install-systemd: # # Uninstall targets # -uninstall: uninstall-xinetd uninstall-launchd uninstall-systemd +uninstall: uninstall-xinetd uninstall-launchd uninstall-systemd uninstall-inetd rm -f $(SBINDIR)/$(BINARY) for DOC in $(DOCS); do rm -f $(DOCDIR)/$$DOC; done rmdir -p $(SBINDIR) $(DOCDIR) 2>/dev/null || true @echo +uninstall-inetd: + @if [ -f "$(INETD)" ] && update-inetd --remove "^gopher.*gophernicus" ; then \ + echo update-inetd remove worked ; \ + else if grep '^gopher' $(INETD) >/dev/null 2>&1 && \ + sed -i .bak -e 's/^gopher/#gopher/' $(INETD) ; then \ + echo "commented out gopher entry in $(INETD), reloading inetd" ; \ + [ -r $(INETPID) ] && kill -HUP `cat $(INETPID)` ; \ + else echo "::::: could not find gopher entry in $(INETD) :::::" ; \ + fi ; \ + fi + @echo + uninstall-xinetd: if grep -q $(BINARY) "$(XINETD)/gopher" 2>/dev/null; then \ rm -f $(XINETD)/gopher; \