summaryrefslogtreecommitdiff
path: root/usr.sbin/ypserv/ypinit
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1995-11-01 16:56:44 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1995-11-01 16:56:44 +0000
commit8bf9f802d4321d9b6265d2ed11b96f9dcd319801 (patch)
treea466ee254e08a5a7b6541862e7d95712e699950b /usr.sbin/ypserv/ypinit
parented9016f1ebe086095be8004780196d995d8f0798 (diff)
+ full set of ypserv tools that compile
Diffstat (limited to 'usr.sbin/ypserv/ypinit')
-rw-r--r--usr.sbin/ypserv/ypinit/Makefile12
-rw-r--r--usr.sbin/ypserv/ypinit/Makefile.main8
-rw-r--r--usr.sbin/ypserv/ypinit/Makefile.yp172
-rw-r--r--usr.sbin/ypserv/ypinit/ypinit.sh210
4 files changed, 402 insertions, 0 deletions
diff --git a/usr.sbin/ypserv/ypinit/Makefile b/usr.sbin/ypserv/ypinit/Makefile
new file mode 100644
index 00000000000..618ebfd4132
--- /dev/null
+++ b/usr.sbin/ypserv/ypinit/Makefile
@@ -0,0 +1,12 @@
+# from: @(#)Makefile 5.3 (Berkeley) 6/22/90
+# $Id: Makefile,v 1.1 1995/11/01 16:56:27 deraadt Exp $
+
+FILES= Makefile.main Makefile.yp
+NOOBJ= noobj
+
+install:
+ install -c -o root -g wheel -m 751 ${FILES} ${DESTDIR}/var/yp
+ install -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${.CURDIR}/ypinit.sh ${DESTDIR}/usr/sbin/ypinit
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/ypserv/ypinit/Makefile.main b/usr.sbin/ypserv/ypinit/Makefile.main
new file mode 100644
index 00000000000..c7dd091871d
--- /dev/null
+++ b/usr.sbin/ypserv/ypinit/Makefile.main
@@ -0,0 +1,8 @@
+# from: @(#)Makefile 5.6.1.2 (Berkeley) 5/8/91
+# $Id: Makefile.main,v 1.1 1995/11/01 16:56:28 deraadt Exp $
+
+SUBDIR=
+
+passwd group hosts networks rpc services protocols: _SUBDIRUSE
+
+.include <bsd.subdir.mk>
diff --git a/usr.sbin/ypserv/ypinit/Makefile.yp b/usr.sbin/ypserv/ypinit/Makefile.yp
new file mode 100644
index 00000000000..5df9f91c4ad
--- /dev/null
+++ b/usr.sbin/ypserv/ypinit/Makefile.yp
@@ -0,0 +1,172 @@
+# from: @(#)Makefile 5.6.1.2 (Berkeley) 5/8/91
+# $Id: Makefile.yp,v 1.1 1995/11/01 16:56:28 deraadt Exp $
+
+YPDBDIR=/var/yp
+DIR=/etc
+NOPUSH=""
+#
+AWK=/usr/bin/awk
+CAT=/bin/cat
+CUT=/usr/bin/cut
+ECHO=/bin/echo
+MAKEDBM=/usr/sbin/makedbm
+SED=/usr/bin/sed
+STDHOSTS=/usr/sbin/stdhosts
+TOUCH=/usr/bin/touch
+YPPUSH=$(ECHO) "YPPUSH Not Yet Implemented: "
+
+all: passwd group hosts networks rpc services protocols
+
+passwd.time: $(DIR)/master.passwd
+ -@if [ -f $(>) ]; then \
+ $(CAT) $(>) | $(CUT) -d: -f1-4,8-10 | \
+ $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
+ { print $$1, $$0 }' - | $(MAKEDBM) - passwd.byname; \
+ $(CAT) $(>) | $(CUT) -d: -f1-4,8-10 |\
+ $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
+ { print $$3, $$0 }' - | $(MAKEDBM) - passwd.byuid; \
+ $(TOUCH) $(@); \
+ $(ECHO) "updated passwd"; \
+ if [ ! $(NOPUSH) ]; then \
+ $(YPPUSH) passwd.byname; \
+ $(YPPUSH) passwd.byuid; \
+ $(ECHO) "pushed passwd"; \
+ else \
+ : ; \
+ fi \
+ else \
+ $(ECHO) "couldn't find $(>)"; \
+ fi
+
+
+group.time: $(DIR)/group
+ -@if [ -f $(>) ]; then \
+ $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
+ { print $$1, $$0 }' $(>) | \
+ $(MAKEDBM) - group.byname; \
+ $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
+ { print $$3, $$0 }' $(>) | \
+ $(MAKEDBM) - group.bygid; \
+ $(TOUCH) $(@); \
+ $(ECHO) "updated group"; \
+ if [ ! $(NOPUSH) ]; then \
+ $(YPPUSH) group.byname; \
+ $(YPPUSH) group.bygid; \
+ $(ECHO) "pushed group"; \
+ else \
+ : ; \
+ fi \
+ else \
+ $(ECHO) "couldn't find $(>)"; \
+ fi
+
+hosts.time: $(DIR)/hosts
+ -@if [ -f $(DIR)/hosts ]; then \
+ $(STDHOSTS) $(>) | $(SED) -e s/#.*$$// | \
+ $(AWK) '{for (i = 2; i <= NF; i++) print $$i, $$0 }' | \
+ $(MAKEDBM) - hosts.byname; \
+ $(STDHOSTS) $(>) | \
+ $(AWK) 'BEGIN { OFS="\t"; } { print $$1, $$0 }' | \
+ $(MAKEDBM) - hosts.byaddr; \
+ $(TOUCH) $(@); \
+ $(ECHO) "updated hosts"; \
+ if [ ! $(NOPUSH) ]; then \
+ $(YPPUSH) hosts.byname; \
+ $(YPPUSH) hosts.byaddr; \
+ $(ECHO) "pushed hosts"; \
+ else \
+ : ; \
+ fi \
+ else \
+ $(ECHO) "couldn't find $(>)"; \
+ fi
+
+networks.time: $(DIR)/networks
+ -@if [ -f $(>) ]; then \
+ $(SED) -e "/^#/d" -e s/#.*$$// $(>) | \
+ $(AWK) '{print $$1, $$0; for (i = 3;i <= NF;i++) print $$i,$$0}' | \
+ $(MAKEDBM) - networks.byname; \
+ $(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
+ $(MAKEDBM) - networks.byaddr; \
+ $(TOUCH) $(@); \
+ $(ECHO) "updated networks"; \
+ if [ ! $(NOPUSH) ]; then \
+ $(YPPUSH) networks.byname; \
+ $(YPPUSH) networks.byaddr; \
+ $(ECHO) "pushed networks"; \
+ else \
+ : ; \
+ fi \
+ else \
+ $(ECHO) "couldn't find $(>)"; \
+ fi
+
+rpc.time: $(DIR)/rpc
+ -@if [ -f $(>) ]; then \
+ $(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
+ $(MAKEDBM) - rpc.bynumber; \
+ $(TOUCH) $(@); \
+ $(ECHO) "updated rpc"; \
+ if [ ! $(NOPUSH) ]; then \
+ $(YPPUSH) rpc.bynumber; \
+ $(ECHO) "pushed rpc"; \
+ else \
+ : ; \
+ fi \
+ else \
+ $(ECHO) "couldn't find $(>)"; \
+ fi
+
+
+services.time: $(DIR)/services
+ -@if [ -f $(>) ]; then \
+ $(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
+ $(MAKEDBM) - services.byname; \
+ $(TOUCH) $(@); \
+ $(ECHO) "updated services"; \
+ if [ ! $(NOPUSH) ]; then \
+ $(YPPUSH) services.byname; \
+ $(ECHO) "pushed services"; \
+ else \
+ : ; \
+ fi \
+ else \
+ $(ECHO) "couldn't find $(>)"; \
+ fi
+
+
+protocols.time: $(DIR)/protocols
+ -@if [ -f $(>) ]; then \
+ $(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
+ $(MAKEDBM) - protocols.bynumber; \
+ $(SED) -e "/^#/d" -e s/#.*$$// $(>) | \
+ $(AWK) '{print $$1, $$0; for (i = 3;i <= NF;i++) print $$i,$$0}' | \
+ $(MAKEDBM) - protocols.byname; \
+ $(TOUCH) $(@); \
+ $(ECHO) "updated protocols"; \
+ if [ ! $(NOPUSH) ]; then \
+ $(YPPUSH) protocols.bynumber; \
+ $(YPPUSH) protocols.byname; \
+ $(ECHO) "pushed protocols"; \
+ else \
+ : ; \
+ fi \
+ else \
+ $(ECHO) "couldn't find $(>)"; \
+ fi
+
+
+passwd: passwd.time
+group: group.time
+hosts: hosts.time
+networks: networks.time
+rpc: rpc.time
+services: services.time
+protocols: protocols.time
+$(DIR)/passwd:
+$(DIR)/group:
+$(DIR)/hosts:
+$(DIR)/networks:
+$(DIR)/rpc:
+$(DIR)/services:
+$(DIR)/protocols:
diff --git a/usr.sbin/ypserv/ypinit/ypinit.sh b/usr.sbin/ypserv/ypinit/ypinit.sh
new file mode 100644
index 00000000000..e6211f67a1a
--- /dev/null
+++ b/usr.sbin/ypserv/ypinit/ypinit.sh
@@ -0,0 +1,210 @@
+#!/bin/sh
+# $Id: ypinit.sh,v 1.1 1995/11/01 16:56:29 deraadt Exp $
+#
+# ypinit.sh - setup an master or slave server.
+#
+DOMAINNAME=/bin/domainname
+HOSTNAME=/bin/hostname
+YPWHICH=/usr/bin/ypwhich
+YPXFR=/usr/sbin/ypxfr
+YP_DIR=/var/yp
+
+#set -xv
+
+ERROR=USAGE # assume usage error
+
+if [ $# -eq 1 ]
+then
+ if [ $1 = "-m" ] # ypinit -m
+ then
+ DOMAIN=`${DOMAINNAME}`
+ SERVERTYPE=MASTER
+ ERROR=
+ fi
+fi
+
+if [ $# -eq 2 ]
+then
+ if [ $1 = "-m" ] # ypinit -m domainname
+ then
+ DOMAIN=${2}
+ SERVERTYPE=MASTER
+ ERROR=
+ fi
+ if [ $1 = "-s" ] # ypinit -s master_server
+ then
+ DOMAIN=`${DOMAINNAME}`
+ SERVERTYPE=SLAVE
+ MASTER=${2}
+ ERROR=
+ fi
+fi
+
+if [ $# -eq 3 ]
+then
+ if [ $1 = "-s" ] # ypinit -s master_server domainname
+ then
+ DOMAIN=`${3}`
+ SERVERTYPE=MASTER
+ MASTER=${2}
+ ERROR=
+ fi
+fi
+
+if [ "${ERROR}" = "USAGE" ]
+then
+ echo "usage: ypinit -m [domainname]" 1>&2
+ echo " ypinit -s master_server [domainname]" 1>&2
+ echo "" 1>&2
+ echo "\
+where -m is used to build a master YP server data base, and -s is used for" 1>&2
+ echo "\
+a slave data base. master_server must be an existing reachable YP server." 1>&2
+ exit 1
+fi
+
+# Just allow master server for now!
+
+#if [ "${SERVERTYPE}" != "MASTER" ];
+#then
+# echo "Sorry, only master server is implemented. Support for slave server" 1>&2
+# echo "needs support for map transfer which isn't implemented yet." 1>&2
+# exit 1
+#fi
+
+# Check if domainname is set, don't accept an empty domainname
+
+if [ -z "${DOMAIN}" ]
+then
+ echo "The local host's domain name hasn't been set. Please set it." 1>&2
+ exit 1
+fi
+
+# Check if hostname is set, don't accept an empty hostname
+
+HOST=`${HOSTNAME}`
+
+if [ -z "${HOST}" ]
+then
+ echo "The local host's name hasn't been set. Please set it." 1>&2
+ exit 1
+fi
+
+# Check if the YP directory exists.
+
+if [ ! -d ${YP_DIR} -o -f ${YP_DIR} ]
+then
+ echo "The directory ${YP_DIR} doesn't exist. Restore it from the distribution." 1>&2
+ exit 1
+
+fi
+
+#echo "Server Type: ${SERVERTYPE} Domain: ${DOMAIN} Master: ${MASTER}"
+
+echo "Installing the YP data base will require that you answer a few questions."
+echo "Questions will all be asked at the beginning of the procedure."
+echo ""
+
+if [ -d ${YP_DIR}/${DOMAIN} ]; then
+
+ echo -n "Can we destroy the existing ${YP_DIR}/${DOMAIN} and its contents? [y/n: n] "
+ read KILL
+
+ ERROR=
+ case ${KILL} in
+ y*) ERROR=DELETE;;
+ Y*) ERROR=DELETE;;
+ *) ERROR=;;
+ esac
+
+ if [ -z "${ERROR}" ]
+ then
+ echo "OK, please clean it up by hand and start again. Bye"
+ exit 0
+ fi
+
+ if [ "${ERROR}" = "DELETE" ]
+ then
+ rm -r -f ${YP_DIR}/${DOMAIN}
+
+ if [ $? -ne 0 ]
+ then
+ echo "Can't clean up old directory ${YP_DIR}/${DOMAIN}. Fatal error." 1>&2
+ exit 1
+ fi
+ fi
+
+fi
+
+mkdir ${YP_DIR}/${DOMAIN}
+
+if [ $? -ne 0 ]
+then
+ echo "Can't make new directory ${YP_DIR}/${DOMAIN}. Fatal error." 1>&2
+ exit 1
+fi
+
+if [ "${SERVERTYPE}" = "MASTER" ];
+then
+
+ if [ ! -f ${YP_DIR}/Makefile ]
+ then
+ if [ ! -f ${YP_DIR}/Makefile.main ]
+ then
+ echo "Can't find ${YP_DIR}/Makefile.main. " 1>&2
+ exit 1
+ fi
+ cp ${YP_DIR}/Makefile.main ${YP_DIR}/Makefile
+ fi
+
+ SUBDIR=`grep "^SUBDIR=" ${YP_DIR}/Makefile`
+
+ if [ -z "${SUBDIR}" ]
+ then
+ echo "Can't find line starting with 'SUBDIR=' in ${YP_DIR}/Makefile. " 1>&2
+ exit 1
+ fi
+
+ NEWSUBDIR="SUBDIR="
+ for DIR in `echo ${SUBDIR} | cut -c8-255`
+ do
+ if [ ${DIR} != ${DOMAIN} ]
+ then
+ NEWSUBDIR="${NEWSUBDIR} ${DIR}"
+ fi
+ done
+ NEWSUBDIR="${NEWSUBDIR} ${DOMAIN}"
+
+ if [ -f ${YP_DIR}/Makefile.tmp ]
+ then
+ rm ${YP_DIR}/Makefile.tmp
+ fi
+
+ mv ${YP_DIR}/Makefile ${YP_DIR}/Makefile.tmp
+ sed -e "s/^${SUBDIR}/${NEWSUBDIR}/" ${YP_DIR}/Makefile.tmp > ${YP_DIR}/Makefile
+ rm ${YP_DIR}/Makefile.tmp
+
+ if [ ! -f ${YP_DIR}/Makefile.yp ]
+ then
+ echo "Can't find ${YP_DIR}/Makefile.yp. " 1>&2
+ exit 1
+ fi
+
+ cp ${YP_DIR}/Makefile.yp ${YP_DIR}/${DOMAIN}/Makefile
+
+fi
+
+if [ "${SERVERTYPE}" = "SLAVE" ];
+then
+
+ for MAP in `${YPWHICH} -d ${DOMAIN} -m | cut -d\ -f1`
+ do
+ ${YPXFR} -h ${MASTER} -c -d ${DOMAIN} ${MAP}
+
+ if [ $? -ne 0 ]
+ then
+ echo "Can't transfer map ${MAP}." 1>&2
+ exit 1
+ fi
+ done
+fi