Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/postinstall Reorganize items so that they're in alp...



details:   https://anonhg.NetBSD.org/src/rev/f1e0033d86ad
branches:  trunk
changeset: 584281:f1e0033d86ad
user:      lukem <lukem%NetBSD.org@localhost>
date:      Mon Sep 12 15:48:29 2005 +0000

description:
Reorganize items so that they're in alphabetical order except that
"obsolete" is moved to the end.
Clean up some comments.

diffstat:

 usr.sbin/postinstall/postinstall |  679 +++++++++++++++++++-------------------
 1 files changed, 340 insertions(+), 339 deletions(-)

diffs (truncated from 834 to 300 lines):

diff -r dbd3528b6622 -r f1e0033d86ad usr.sbin/postinstall/postinstall
--- a/usr.sbin/postinstall/postinstall  Mon Sep 12 15:47:09 2005 +0000
+++ b/usr.sbin/postinstall/postinstall  Mon Sep 12 15:48:29 2005 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: postinstall,v 1.5 2005/09/04 10:13:15 lukem Exp $
+# $NetBSD: postinstall,v 1.6 2005/09/12 15:48:29 lukem Exp $
 #
 # Copyright (c) 2002-2005 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -37,7 +37,7 @@
 # POSSIBILITY OF SUCH DAMAGE.
 #
 # postinstall
-#      check for or fix configuration changes that occur
+#      Check for or fix configuration changes that occur
 #      over time as NetBSD evolves.
 #
 
@@ -75,8 +75,25 @@
        echo "  $@"
 }
 
+mkdtemp()
+{
+       # Make sure we don't loop forever if mkdir will always fail.
+       [ -d /tmp ] || err 1 /tmp is not a directory
+       [ -w /tmp ] || err 1 /tmp is not writable
+
+       _base=/tmp/_postinstall.$$
+       _serial=0
+
+       while true; do
+               _dir=${_base}.${_serial}
+               mkdir -m 0700 ${_dir} && break
+               _serial=$((${_serial} + 1))
+       done
+       echo ${_dir}
+}
+
 # additem item description
-#      add item to list of supported items to check/fix
+#      Add item to list of supported items to check/fix.
 #
 additem()
 {
@@ -86,8 +103,8 @@
 }
 
 # checkdir op dir mode
-#      ensure dir exists, and if not, create it with the appropriate mode.
-#      returns 0 if ok, 1 otherwise.
+#      Ensure dir exists, and if not, create it with the appropriate mode.
+#      Returns 0 if ok, 1 otherwise.
 #
 check_dir()
 {
@@ -109,8 +126,8 @@
 }
 
 # check_ids op type file id [...]
-#      check if file of type "users" or "groups" contains the relevant ids
-#      returns 0 if ok, 1 otherwise.
+#      Check if file of type "users" or "groups" contains the relevant IDs
+#      Returns 0 if ok, 1 otherwise.
 #      
 check_ids()
 {
@@ -158,7 +175,7 @@
 
 # populate_dir op onlynew src dest mode file [file ...]
 #      Perform op ("check" or "fix") on files in src/ against dest/
-#      If op = "check" display missing or changed files, optionally with diffs
+#      If op = "check" display missing or changed files, optionally with diffs.
 #      If op != "check" copies any missing or changed files.
 #      If onlynew evaluates to true, changed files are ignored.
 #      Returns 0 if ok, 1 otherwise.
@@ -217,7 +234,7 @@
 
 # compare_dir op src dest mode file [file ...]
 #      Perform op ("check" or "fix") on files in src/ against dest/
-#      If op = "check" display missing or changed files, optionally with diffs
+#      If op = "check" display missing or changed files, optionally with diffs.
 #      If op != "check" copies any missing or changed files.
 #      Returns 0 if ok, 1 otherwise.
 #
@@ -235,8 +252,8 @@
 }
 
 # move_file op src dest --
-#      check (op == "check") or move (op != "check") from src to dest.
-#      returns 0 if ok, 1 otherwise.
+#      Check (op == "check") or move (op != "check") from src to dest.
+#      Returns 0 if ok, 1 otherwise.
 #
 move_file()
 {
@@ -260,10 +277,10 @@
 }
 
 # rcconf_is_set op name var [verbose] --
-#      load the rcconf for name, and check if obsolete rc.conf(5) variable
+#      Load the rcconf for name, and check if obsolete rc.conf(5) variable
 #      var is defined or not.
-#      returns 0 if defined (even to ""), otherwise 1.
-#      if verbose != "", print an obsolete warning if the var is defined.
+#      Returns 0 if defined (even to ""), otherwise 1.
+#      If verbose != "", print an obsolete warning if the var is defined.
 #
 rcconf_is_set()
 {
@@ -297,10 +314,10 @@
 }
 
 # find_file_in_dirlist() file message dir1 [...] --
-#      find which directory file is in, and sets ${dir} to match
-#      returns 0 if matched, otherwise 1 (and sets ${dir} to "").
+#      Find which directory file is in, and sets ${dir} to match.
+#      Returns 0 if matched, otherwise 1 (and sets ${dir} to "").
 #
-#      generally, check the directory for the "checking from source" case,
+#      Generally, check the directory for the "checking from source" case,
 #      and then the directory for the "checking from extracted etc.tgz" case.
 #
 find_file_in_dirlist()
@@ -325,9 +342,9 @@
 }
 
 # stat op format target value
-#      call stat on the given target according to the given format, if
-#      stat(1) is available (it is presumed to live in /usr/bin).  if
-#      it is not available, this routine will always succeed, otherwise
+#      Call stat(1) on the given target according to the given format,
+#      if stat(1) is available (it is presumed to live in /usr/bin).
+#      If it is not available, this routine will always succeed, otherwise
 #      it returns 0 or 1, depending on whether or not the output from
 #      stat(1) matches the expected value.
 #
@@ -349,8 +366,8 @@
 }
 
 # obsolete_paths op
-#      obsolete the list of paths provided on stdin.
-#      each path is relative to ${DEST_DIR}, and should
+#      Obsolete the list of paths provided on stdin.
+#      Each path is relative to ${DEST_DIR}, and should
 #      be an absolute path or start with `./'.
 #
 obsolete_paths()
@@ -385,10 +402,10 @@
 }
 
 # obsolete_libs dir
-#      display the minor/teeny shared libraries in dir that are considered
+#      Display the minor/teeny shared libraries in dir that are considered
 #      to be obsolete.
 #
-#      the implementation supports removing obsolete major libraries
+#      The implementation supports removing obsolete major libraries
 #      if the awk variable AllLibs is set, although there is no way to
 #      enable that in the enclosing shell function as this time.
 #
@@ -450,7 +467,7 @@
 }
 
 # modify_file op srcfile scratchfile awkprog
-#      apply awkprog to srcfile sending output to scratchfile, and
+#      Apply awkprog to srcfile sending output to scratchfile, and
 #      if appropriate replace srcfile with scratchfile.
 #
 modify_file()
@@ -508,6 +525,60 @@
 }
 
 #
+#      gid
+#
+additem gid "required groups in /etc/group"
+do_gid()
+{
+       [ -n "$1" ] || err 2 "USAGE: do_gid  fix|check"
+
+       check_ids $1 groups "${DEST_DIR}/etc/group" \
+           named ntpd sshd smmsp authpf _pflogd
+}
+
+#
+#      hosts
+#
+additem hosts "/etc/hosts being up to date"
+do_hosts()
+{
+       [ -n "$1" ] || err 2 "USAGE: do_hosts  fix|check"
+
+       modify_file "$1" ${DEST_DIR}/etc/hosts ${SCRATCHDIR}/hosts '
+               /^(127\.0\.0\.1|::1)[   ]+[^\.]*$/ {
+                       print $0, "localhost."
+                       next
+               }
+               { print }
+       '
+       return $?
+}
+
+#
+#      makedev
+#
+additem makedev "/dev/MAKEDEV being up to date"
+do_makedev()
+{
+       [ -n "$1" ] || err 2 "USAGE: do_makedev   fix|check"
+
+       if [ -f "${SRC_DIR}/etc/MAKEDEV.tmpl" ]; then
+                       # generate MAKEDEV from source if source is available
+               env MACHINE=${MACHINE} \
+                   MACHINE_ARCH=${MACHINE_ARCH} \
+                   NETBSDSRCDIR="${SRC_DIR}" \
+                   awk -f ${SRC_DIR}/etc/MAKEDEV.awk \
+                   ${SRC_DIR}/etc/MAKEDEV.tmpl > ${SCRATCHDIR}/MAKEDEV
+       fi
+
+       find_file_in_dirlist MAKEDEV "MAKEDEV" \
+           ${SCRATCHDIR} ${SRC_DIR}/dev \
+           || return 1
+
+       compare_dir $1 ${dir} ${DEST_DIR}/dev 555 MAKEDEV
+}
+
+#
 #      mtree
 #
 additem mtree "/etc/mtree/ being up to date"
@@ -520,30 +591,25 @@
 }
 
 #
-#      gid
-#
-additem gid "required GIDs"
-do_gid()
-{
-       [ -n "$1" ] || err 2 "USAGE: do_gid  fix|check"
-
-       check_ids $1 groups "${DEST_DIR}/etc/group" \
-           named ntpd sshd smmsp authpf _pflogd
-}
-
+#      pam
 #
-#      uid
-#
-additem uid "required UIDs"
-do_uid()
+# disabled for now
+additem pam "/etc/pam.d is populated"
+do_pam()
 {
-       [ -n "$1" ] || err 2 "USAGE: do_uid  fix|check"
+       [ -n "$1" ] || err 2 "USAGE: do_pam  fix|check"
+       op=$1
+       failed=0
 
-       check_ids $1 users "${DEST_DIR}/etc/master.passwd" \
-           named ntpd sshd smmsp _pflogd
+       populate_dir ${op} true ${SRC_DIR}/etc/pam.d ${DEST_DIR}/etc/pam.d 644 \
+               README display_manager ftpd gdm imap kde login other passwd \
+               pop3 ppp rexecd rsh sshd su system telnetd xdm xserver
+
+       failed=$(( ${failed} + $? ))
+
+       return ${failed}
 }
 
-
 #
 #      periodic
 #
@@ -557,6 +623,30 @@
 }
 
 #
+#      postfix
+#
+additem postfix "/etc/postfix/ being up to date"
+do_postfix()
+{
+       [ -n "$1" ] || err 2 "USAGE: do_postfix  fix|check"
+       op=$1
+       failed=0
+
+       find_file_in_dirlist postfix-script "postfix scripts" \
+           ${SRC_DIR}/gnu/dist/postfix/conf \
+           ${DEST_DIR}/usr/share/examples/postfix \
+           || return 1
+
+       compare_dir ${op} ${dir} ${DEST_DIR}/etc/postfix 555 postfix-script
+       failed=$(( ${failed} + $? ))
+       compare_dir ${op} ${dir} \
+           ${DEST_DIR}/etc/postfix 444 post-install postfix-files



Home | Main Index | Thread Index | Old Index