LES BSD Thread!

1101112131416»

Comments

  • Not_OlesNot_Oles Hosting ProviderContent Writer

    I updated the NetBSD-current sources on my @linveo VPS. Thanks @linveo!

    linveo# date
    linveo# cd /usr/src
    linveo# export CVS_RSH="ssh"
    linveo# cvs update -A -dP
    linveo# cd ../xsrc
    linveo# cvs update -A -dP
    linveo# cd /usr/src
    linveo# less UPDATING
    

    I also rebuilt the NetBSD-current userland.

    make distribution started at:  Thu Jan  9 20:34:10 UTC 2025
    make distribution finished at: Thu Jan  9 22:06:48 UTC 2025
    ===> Successful make distribution
    ===> build.sh ended:      Thu Jan  9 22:06:48 UTC 2025
    ===> Summary of results:
             build.sh command:    ./build.sh -j 2 -O ../obj -r -T ../tools -U distribution
             build.sh started:    Thu Jan  9 20:34:03 UTC 2025
             NetBSD version:      10.99.12
             MACHINE:             amd64
             MACHINE_ARCH:        x86_64
             Build platform:      NetBSD 10.99.12 amd64
             HOST_SH:             /bin/sh
             Bootstrapping nbmake
             share/mk MAKECONF:   /etc/mk.conf
             MAKECONF file:       /etc/mk.conf
             TOOLDIR path:        /usr/src/../tools
             DESTDIR path:        /usr/src/../obj/destdir.amd64
             RELEASEDIR path:     /usr/src/../obj/releasedir
             Removing /usr/src/../tools
             Removing /usr/src/../obj/destdir.amd64
             Created /usr/src/../tools/bin/nbmake
             Updated makewrapper: /usr/src/../tools/bin/nbmake-amd64
             Successful make distribution
             build.sh ended:      Thu Jan  9 22:06:48 UTC 2025
    ===> .
    

    Next up is rebuilding the kernel and the X Window System. Then backup, install the new kernel, and reboot,

    Finally, install the new userland and the new X. Then a final reboot to make sure that it can.

    What am I missing? :)

    I hope everyone gets the servers they want!

  • Not_OlesNot_Oles Hosting ProviderContent Writer

    Here is the Summary of the kernel rebuild.

    ===> Summary of results:
             build.sh command:    ./build.sh -j 2 -O ../obj -T ../tools -U kernel=GENERIC
             build.sh started:    Fri Jan 10 01:06:48 UTC 2025
             NetBSD version:      10.99.12
             MACHINE:             amd64
             MACHINE_ARCH:        x86_64
             Build platform:      NetBSD 10.99.12 amd64
             HOST_SH:             /bin/sh
             share/mk MAKECONF:   /etc/mk.conf
             MAKECONF file:       /etc/mk.conf
             TOOLDIR path:        /usr/src/../tools
             DESTDIR path:        /usr/src/../obj/destdir.amd64
             RELEASEDIR path:     /usr/src/../obj/releasedir
             Updated makewrapper: /usr/src/../tools/bin/nbmake-amd64
             Building kernel without building new tools
             Building kernel:     GENERIC
             Build directory:     /usr/src/../obj/sys/arch/amd64/compile/GENERIC
             Kernels built from GENERIC:
              /usr/src/../obj/sys/arch/amd64/compile/GENERIC/netbsd
             build.sh ended:      Fri Jan 10 01:13:39 UTC 2025
    ===> .
    

    I hope everyone gets the servers they want!

  • Not_OlesNot_Oles Hosting ProviderContent Writer
    edited January 10

    build.sh command: ./build.sh -j 2 -O ../obj -r -T ../tools -U distribution

    Nope! :)

    I forgot the -x flag to add X Windows!

    So, probably, something like

    build.sh command: ./build.sh -j 2 -O ../obj -r -T ../tools -U -x distribution

    might work.

    I hope everyone gets the servers they want!

  • Not_OlesNot_Oles Hosting ProviderContent Writer

    Okay, done with the X Window System enabled distribution build.

    I think I wouldn't have to rebuild the kernel again, right?

    ===> Successful make distribution
    ===> build.sh ended:      Fri Jan 10 04:18:03 UTC 2025
    ===> Summary of results:
             build.sh command:    ./build.sh -j 2 -O ../obj -r -T ../tools -U -x distribution
             build.sh started:    Fri Jan 10 01:46:09 UTC 2025
             NetBSD version:      10.99.12
             MACHINE:             amd64
             MACHINE_ARCH:        x86_64
             Build platform:      NetBSD 10.99.12 amd64
             HOST_SH:             /bin/sh
             Bootstrapping nbmake
             share/mk MAKECONF:   /etc/mk.conf
             MAKECONF file:       /etc/mk.conf
             TOOLDIR path:        /usr/src/../tools
             DESTDIR path:        /usr/src/../obj/destdir.amd64
             RELEASEDIR path:     /usr/src/../obj/releasedir
             Removing /usr/src/../tools
             Removing /usr/src/../obj/destdir.amd64
             Created /usr/src/../tools/bin/nbmake
             Updated makewrapper: /usr/src/../tools/bin/nbmake-amd64
             Successful make distribution
             build.sh ended:      Fri Jan 10 04:18:03 UTC 2025
    ===> .
    

    I hope everyone gets the servers they want!

  • Not_OlesNot_Oles Hosting ProviderContent Writer

    Well . . . I did build the kernel again. . . .

    I'm not sure whether having the "-x" flag in the kernel build changes anything. But it might.

    Tomorrow, maybe we will see if the VPS reboots with the newly updated and recompiled kernel.

    Thanks to @linveo for lots of NetBSD fun, :star: and for very fast builds! <3

    ===> Summary of results:
             build.sh command:    ./build.sh -j 2 -O ../obj -T ../tools -U -x kernel=GENERIC
             build.sh started:    Fri Jan 10 05:13:51 UTC 2025
             NetBSD version:      10.99.12
             MACHINE:             amd64
             MACHINE_ARCH:        x86_64
             Build platform:      NetBSD 10.99.12 amd64
             HOST_SH:             /bin/sh
             share/mk MAKECONF:   /etc/mk.conf
             MAKECONF file:       /etc/mk.conf
             TOOLDIR path:        /usr/src/../tools
             DESTDIR path:        /usr/src/../obj/destdir.amd64
             RELEASEDIR path:     /usr/src/../obj/releasedir
             Updated makewrapper: /usr/src/../tools/bin/nbmake-amd64
             Building kernel without building new tools
             Building kernel:     GENERIC
             Build directory:     /usr/src/../obj/sys/arch/amd64/compile/GENERIC
             Kernels built from GENERIC:
              /usr/src/../obj/sys/arch/amd64/compile/GENERIC/netbsd
             build.sh ended:      Fri Jan 10 05:20:55 UTC 2025
    ===> .
    

    I hope everyone gets the servers they want!

  • Not_OlesNot_Oles Hosting ProviderContent Writer
    edited January 11

    Welp, what do you think? Did the reboot work?

    Rebuilding and updating NetBSD-current seems more suspense-filled than I remember from the old days. . . .

    Here is moving the new kernel into place:

    linveo# mv /netbsd /netbsd.old
    linveo# mv /usr/obj/sys/arch/amd64/compile/GENERIC/netbsd /
    linveo# ls -l /netbsd*
    -rwxr-xr-x  1 root  wheel  29583936 Jan 10 05:20 /netbsd
    -rwxr-xr-x  1 root  wheel  29574592 Dec  1 19:29 /netbsd.old
    linveo# date; shutdown -r now
    Sat Jan 11 05:16:12 UTC 2025
    Shutdown NOW!
    shutdown: [pid 20432]
    linveo#                                                                                
    *** FINAL System shutdown message from [email protected] ***          
    System going down IMMEDIATELY                                                  
                                                                                   
                                                                                   
    
    System shutdown time has arrived
    
    About to run shutdown hooks...
    Stopping cron.
    Stopping inetd.
    Saved entropy to /var/db/entropy-file.
    Forcibly unmounting /tmp
    Forcibly unmounting /var/shm
    Removing block-type swap devices
    swapctl: removing /dev/dk1 as swap device
    Sat Jan 11 05:16:15 UTC 2025
    
    Done running shutdown hooks.
    Connection to xxx.xxx.xxx.xxx closed by remote host.
    Connection to xxx.xxx.xxx.xxx closed.
    chronos@penguin:~/servers/linveo$ 
    

    And here is . . . what . . . happened . . . after I tried to reboot. . . .

    chronos@penguin:~/servers/linveo$ `head -n 1 login`
    Last login: Sat Jan 11 05:13:07 2025 from xxx.xxx.xxx.xxx
    NetBSD 10.99.12 (GENERIC) #3: Fri Jan 10 05:20:35 UTC 2025
    
    Welcome to NetBSD!
    
    We recommend that you create a non-root account and use su(1) for root access.
    linveo# date
    Sat Jan 11 05:19:35 UTC 2025
    linveo# uptime
     5:19AM  up 3 mins, 1 user, load averages: 0.00, 0.00, 0.00
    linveo# 
    

    Aaannd. . . .

    Thanks @Linveo for the really nice, really fast server! Thanks @cmeerw for the NetBSD 10 image which got me started!

    Also. . . .

    I probably will post about updating the NetBSD-current distribution userland and also about updating the pkgsrc extras. After that, I expect to stop posting about "routine" updates, even if they are magnificent, amazing, and wonderful each and every time!

    I hope everyone gets the servers they want!

  • Not_OlesNot_Oles Hosting ProviderContent Writer

    I installed all the newly compiled userland binaries, and then rebooted again.

    It seems to have worked. I'm cautiously optimistic!

    Install

    ===> Successful installworld to /
    ===> build.sh ended:      Mon Jan 13 01:52:30 UTC 2025
    ===> Summary of results:
             build.sh command:    ./build.sh -j 2 -O ../obj -T ../tools -U -x install=/
             build.sh started:    Mon Jan 13 01:51:03 UTC 2025
             NetBSD version:      10.99.12
             MACHINE:             amd64
             MACHINE_ARCH:        x86_64
             Build platform:      NetBSD 10.99.12 amd64
             HOST_SH:             /bin/sh
             share/mk MAKECONF:   /etc/mk.conf
             MAKECONF file:       /etc/mk.conf
             TOOLDIR path:        /usr/src/../tools
             DESTDIR path:        /usr/src/../obj/destdir.amd64
             RELEASEDIR path:     /usr/src/../obj/releasedir
             Updated makewrapper: /usr/src/../tools/bin/nbmake-amd64
             Successful installworld to /
             build.sh ended:      Mon Jan 13 01:52:30 UTC 2025
    ===> .
    

    Reboot

    chronos@penguin:~/servers/linveo$ `head -n 1 login`
    Last login: Mon Jan 13 01:47:49 2025 from xxx.xxx.xxx.xxx
    NetBSD 10.99.12 (GENERIC) #3: Fri Jan 10 05:20:35 UTC 2025
    
    Welcome to NetBSD!
    
    We recommend that you create a non-root account and use su(1) for root access.
    linveo# date
    Mon Jan 13 01:59:38 UTC 2025
    linveo# uptime
     1:59AM  up 2 mins, 1 user, load averages: 0.02, 0.01, 0.00
    linveo# 
    

    Now we seem to be running NetBSD-current on our newly updated and self-compiled kernel and base system userland binaries! These all were built with our newly updated and compiled build tools. That's pretty cool, I think!

    Just for fun, let's check the dates of the files in /bin. :)

    linveo# ls -l /bin
    total 1934
    -r-xr-xr-x  2 root  wheel   22056 Jan 10 04:14 [
    -r-xr-xr-x  1 root  wheel   22024 Jan 10 04:14 cat
    lrwxr-xr-x  1 root  wheel      11 Jan 10 04:14 chgrp -> /sbin/chown
    -r-xr-xr-x  1 root  wheel   22232 Jan 10 04:14 chio
    -r-xr-xr-x  1 root  wheel   17584 Jan 10 04:14 chmod
    -r-xr-xr-x  1 root  wheel   33528 Jan 10 04:14 cp
    -r-xr-xr-x  1 root  wheel   57720 Jan 10 04:13 cpio
    -r-xr-xr-x  1 root  wheel  190888 Jan 10 04:14 csh
    -r-xr-xr-x  1 root  wheel   27264 Jan 10 04:14 date
    -r-xr-xr-x  1 root  wheel   41384 Jan 10 04:14 dd
    -r-xr-xr-x  1 root  wheel   22744 Jan 10 04:14 df
    -r-xr-xr-x  1 root  wheel   17024 Jan 10 04:14 domainname
    -r-xr-xr-x  1 root  wheel   16832 Jan 10 04:14 echo
    -r-xr-xr-x  1 root  wheel   66048 Jan 10 04:14 ed
    -r-xr-xr-x  1 root  wheel   26088 Jan 10 04:14 expr
    -r-xr-xr-x  1 root  wheel   17808 Jan 10 04:14 getfacl
    -r-xr-xr-x  1 root  wheel   17064 Jan 10 04:14 hostname
    -r-xr-xr-x  1 root  wheel   17632 Jan 10 04:14 kill
    -r-xr-xr-x  1 root  wheel  290256 Jan 10 04:14 ksh
    -r-xr-xr-x  1 root  wheel   17688 Jan 10 04:14 ln
    -r-xr-xr-x  1 root  wheel   37824 Jan 10 04:14 ls
    -r-xr-xr-x  1 root  wheel   17360 Jan 10 04:14 mkdir
    -r-xr-xr-x  1 root  wheel   27288 Jan 10 04:14 mt
    -r-xr-xr-x  1 root  wheel   26776 Jan 10 04:14 mv
    -r-xr-xr-x  1 root  wheel  165216 Jan 10 04:14 pax
    -r-xr-xr-x  1 root  wheel   71160 Jan 10 04:14 ps
    -r-xr-xr-x  1 root  wheel   17168 Jan 10 04:14 pwd
    -r-sr-xr-x  1 root  wheel   22536 Jan 10 04:14 rcmd
    -r-xr-xr-x  1 root  wheel   32096 Jan 10 04:14 rcp
    -r-xr-xr-x  1 root  wheel   26848 Jan 10 04:14 rm
    -r-xr-xr-x  1 root  wheel   16984 Jan 10 04:14 rmdir
    -r-xr-xr-x  1 root  wheel   41832 Jan 10 04:14 rump.dd
    -r-xr-xr-x  1 root  wheel   32296 Jan 10 04:14 setfacl
    -r-xr-xr-x  1 root  wheel  239776 Jan 10 04:14 sh
    -r-xr-xr-x  1 root  wheel   17536 Jan 10 04:14 sleep
    -r-xr-xr-x  1 root  wheel   36496 Jan 10 04:14 stty
    -r-xr-xr-x  1 root  wheel   16568 Jan 10 04:14 sync
    -r-xr-xr-x  1 root  wheel   85432 Jan 10 04:13 tar
    -r-xr-xr-x  2 root  wheel   22056 Jan 10 04:14 test
    linveo# 
    

    Next up is to try to figure out the etcupdate, which I almost certainly should have run before rebooting. Maybe etcupdate should have been run before installing.

    After etcupdate it's probably time to check whether any of the pkgsrc programs have been updated and therefore need rebuilding.

    I plan to stop posting routine NetBSD build updates to this thread when etcupdate and pkgsrc are done. We will have upgraded NetBSD 10 to NetBSD-current, installed X Windows and Wireshark, then done another upgrade as time progressed. Maybe there will be enough here so that anyone interested can try self-compiling NetBSD-current!

    Yeah, all self-compiled, except for our initial NetBSD 10 image kindly provided by @cmeerw. <3 Thanks @linveo for the nice, fast VPS! <3 Thanks NetBSD! <3 Thanks LESbians! <3

    If anyone catches my mistakes, please do let me know! <3

    Best wishes!

    I hope everyone gets the servers they want!

  • Not_OlesNot_Oles Hosting ProviderContent Writer

    Already found a mistake! :)

    I needed to run postinstall. In the output of the successful install, it says:

    obsolete check:
            Remove obsolete file /usr/lib/libcurses.so.9.1
            Remove obsolete file /usr/lib/i386/libcurses.so.9.1
    postinstall checks passed: atf autofsconfig blocklist bluetooth catpages ddbonpanic defaults dhcpc
    d dhcpcdrundir envsys fontconfig gid gpio hosts iscsi manconf motd named opensslcertsconf opensslc
    ertsrehash pam periodic pf ptyfsoldnodes pwd_mkdb ssh tcpdumpchroot uid varrwho varshm wscons x11 
    xkb
    postinstall checks failed: makedev mtree rc obsolete
    To fix, run:
        /bin/sh /usr/src/../obj/usr.sbin/postinstall/postinstall -s /usr/src -x /usr/xsrc -d / fix mak
    edev mtree rc obsolete
    Note that this may overwrite local changes.
    

    And here's what happened when I ran the suggested fix:

    linveo# /bin/sh /usr/src/../obj/usr.sbin/postinstall/postinstall -s /usr/src -x /usr/xsrc -d / fix makedev mtree rc obsolete
    Source directory: /usr/src
    Target directory: /
    makedev fix:
            Copied /tmp/_postinstall.1085.0/MAKEDEV to /dev/MAKEDEV
    mtree fix:
    rc fix:
            Copied /usr/src/etc/rc.shutdown to /etc/rc.shutdown
    obsolete fix:
            Removed obsolete file /usr/lib/libcurses.so.9.1
            Removed obsolete file /usr/lib/i386/libcurses.so.9.1
    postinstall fixes passed: makedev mtree rc obsolete
    postinstall fixes failed:
    linveo# 
    

    I hope everyone gets the servers they want!

  • Quite interesting thread over in NetBSD land. Two things to note:

    • there is actually a simpler way (in NetBSD) to configure IPv6 where you get a /64, but the gateway has an IP address that is not from the /64, e.g. route add default 2001:0db8:1::1 -connected -ifp vioif0
    • when sending (solicited) neighbor advertisement, Linux uses the global-scope IPv6 address as the source IP address of the neighbor advertisement, but NetBSD (and also the other BSDs) use a link-local IPv6 address as the source IP address; and at least one VPS provider appears to filter those neighbor advertisements (probably trying to prevent a VPS from using IPv6 addresses that are not assigned to that VPS)
    Thanked by (1)Not_Oles
  • Not_OlesNot_Oles Hosting ProviderContent Writer

    Hello!

    I got the OpenBSD installer running inside Qemu running on a Linux server. My goal for now was just to make sure I could boot the installer, so I did not (yet) make a qcow2 file for a persistent installation. Instead, I stopped when I reached an sh shell inside the installer. Eventually I want to try compiling OpenBSD-current from source.

    I didn't (yet) add kvm or networking options to the qemu command. Not using KVM makes everything run slower, so I have a better chance of being able to read terminal output as it scrolls up. It looks like the OpenBSD installer doesn't automagically connect to qemu slirp, so I have to figure that out.

    In case anyone else here might want to try this, here are a few notes and a screenshot.

    # Downloads
    https://mirrors.mit.edu/pub/OpenBSD/snapshots/amd64/cd76.iso
    https://mirrors.mit.edu/pub/OpenBSD/snapshots/amd64/SHA256
    https://mirrors.mit.edu/pub/OpenBSD/snapshots/amd64/SHA256.sig
    
    # "iso" is a symlink to /var/iso/openbsd-current-snapshot-cd76.iso
    
    # Commands
    tmux
    qemu-system-x86_64 -cdrom iso -nographic
    
    # To avoid freeze "Entry point at 0xffffffff8100100"
    # enter these commands at boot prompt
    stty com0 115200
    set tty com0
    boot
    

    I hope everyone gets the servers they want!

  • Not_OlesNot_Oles Hosting ProviderContent Writer

    Okay, networking seems to work after I asked the installer to run dhcp.

    openbsd# ping -c 2 1.1.1.1
    PING 1.1.1.1 (1.1.1.1): 56 data bytes
    64 bytes from 1.1.1.1: icmp_seq=0 ttl=255 time=47.517 ms
    64 bytes from 1.1.1.1: icmp_seq=1 ttl=255 time=45.687 ms
    
    --- 1.1.1.1 ping statistics ---
    2 packets transmitted, 2 packets received, 0.0% packet loss
    round-trip min/avg/max/std-dev = 45.687/46.602/47.517/0.915 ms
    openbsd# 
    

    I hope everyone gets the servers they want!

  • Not_OlesNot_Oles Hosting ProviderContent Writer
    edited January 25

    @Not_Oles said: Next up is to try to figure out the etcupdate

    NetBSD's etcupdate is a shell script written in the POSIX version of the Bourne shell "sh" programming language.

    etcupdate is called after an update, rebuild, and reinstall of NetBSD from source code on a running system. The idea behind etcupdate is to make sure that the files in the running system's /etc provide the configuration parameters expected by the newly reinstalled software, and, where configuration choices are made, match the desires of the system administrator.

    In addition to adjusting configuration files to provide new or changed parameters, it also seems like it would be necessary to add and adjust any completely new configurations for completely new programs recently added to the sources and possibly to remove configurations for programs which no longer are included in the sources.

    linveo# uname; uname -r
    NetBSD
    10.99.12 # This is NetBSD-current.
    linveo# which etcupdate
    /usr/sbin/etcupdate
    linveo# which file
    /usr/bin/file
    linveo# file /usr/sbin/etcupdate
    /usr/sbin/etcupdate: POSIX shell script, ASCII text executable
    linveo# 
    

    More soon on etcupdate. Thanks @linveo for the speedy NetBSD VPS! <3

    I hope everyone gets the servers they want!

  • Not_OlesNot_Oles Hosting ProviderContent Writer

    Looks like there currently are a lot of directories and files in /etc.

    linveo# ls -lR /etc | wc -l
         831
    linveo# 
    

    If you want to look under the spoiler at the top level ls -l listing, Jan 10 was the date of the most recent rebuild and reinstall. Therefore, at least some of these files and directories seem to have been touched by the January 10 rebuild and reinstall even though etcupdate wasn't run.

    linveo# cd /etc
    linveo# ls -l
    total 4548
    drwxr-xr-x  11 root  wheel         512 Jan 10 02:00 X11
    drwxr-xr-x   2 root  wheel         512 Jan 10 04:17 atf
    -rw-r--r--   1 root  wheel         342 Mar 28  2024 auto_master
    drwxr-xr-x   2 root  wheel         512 Jan 10 04:17 autofs
    drwxr-xr-x   2 root  wheel         512 Mar 28  2024 bluetooth
    -rw-r--r--   1 root  wheel        2888 Mar 28  2024 bootptab
    drwx------   2 root  wheel         512 Jan 10 02:00 cgd
    -rw-r--r--   1 root  wheel         388 Mar 28  2024 changelist
    -rw-r--r--   1 root  wheel         101 Mar 28  2024 csh.cshrc
    -rw-r--r--   1 root  wheel         101 Mar 28  2024 csh.login
    -rw-r--r--   1 root  wheel         103 Mar 28  2024 csh.logout
    -rw-r--r--   1 root  wheel        7536 Mar 28  2024 daily
    -rw-r--r--   1 root  wheel         240 Oct  7 18:15 daily.conf
    drwxr-xr-x   2 root  wheel         512 Jan 10 04:17 defaults
    -rw-r--r--   1 root  wheel        1429 Mar 28  2024 dhcpcd.conf
    -rw-r--r--   1 root  wheel         313 Mar 28  2024 disktab
    -rw-r--r--   1 root  wheel         468 Mar 28  2024 dm.conf
    -rw-rw-r--   1 root  operator        0 Mar 28  2024 dumpdates
    -rw-r--r--   1 root  wheel        2298 Mar 28  2024 envsys.conf
    -rw-r--r--   1 root  wheel        1197 Mar 28  2024 floppytab
    drwxr-xr-x   3 root  wheel         512 Dec 12 00:28 fltk
    drwxr-xr-x   4 root  wheel         512 Jan 10 04:17 fonts
    -rw-r--r--   1 root  wheel         329 Oct  7 18:15 fstab
    -rw-r--r--   1 root  wheel         140 Mar 28  2024 ftpchroot
    -rw-r--r--   1 root  wheel         401 Mar 28  2024 ftpusers
    -rw-r--r--   1 root  wheel        3507 Mar 28  2024 gettytab
    -rw-r--r--   1 root  wheel         350 Mar 28  2024 gpio.conf
    -rw-r--r--   1 root  wheel         632 Dec 17 04:16 group
    -rw-r--r--   1 root  wheel         731 Mar 28  2024 hosts
    -rw-------   1 root  wheel           2 Mar 28  2024 hosts.equiv
    -rw-r--r--   1 root  wheel           2 Mar 28  2024 hosts.lpd
    -rw-r--r--   1 root  wheel          58 Nov 13 22:09 ifconfig.vioif0
    -rw-r--r--   1 root  wheel        4036 Mar 28  2024 inetd.conf
    drwxr-xr-x   2 root  wheel         512 Jan 10 04:17 iscsi
    drwxr-xr-x   2 root  wheel         512 Jan 10 02:00 kerberosV
    drwxr-xr-x   2 root  wheel         512 Jan 10 02:00 kyua
    lrwxr-xr-x   1 root  wheel          23 Mar 28  2024 localtime -> /usr/share/zoneinfo/UTC
    -rw-r--r--   1 root  wheel        1023 Mar 28  2024 locate.conf
    -rw-r--r--   1 root  wheel        1105 Mar 28  2024 login.conf
    drwxr-xr-x   2 root  wheel         512 Jan 10 04:17 mail
    -rw-r--r--   1 root  wheel         170 Mar 28  2024 mail.rc
    -rw-r--r--   1 root  wheel         921 Mar 28  2024 mailer.conf
    -rw-r--r--   1 root  wheel        2062 Mar 28  2024 man.conf
    -rw-------   1 root  wheel        2212 Dec 17 04:16 master.passwd
    -rw-r--r--   1 root  wheel          35 Dec 12 05:42 mk.conf
    -r--r--r--   1 root  wheel      587027 Mar 28  2024 moduli
    -rw-r--r--   1 root  wheel         811 Mar 28  2024 monthly
    -rw-r--r--   1 root  wheel         216 Mar 28  2024 monthly.conf
    -rw-rw-r--   1 root  wheel          80 Jan 11 05:16 motd
    -rw-r--r--   1 root  wheel        1597 Mar 28  2024 mrouted.conf
    drwxr-xr-x   2 root  wheel         512 Jan 13 01:52 mtree
    -rw-r--r--   1 root  wheel          12 Nov 13 22:09 mygate
    -rw-r--r--   1 root  wheel          15 Nov 13 22:09 mygate6
    -rw-r--r--   1 root  wheel          20 Nov 13 22:09 myname
    -rw-r--r--   1 root  wheel        1626 Mar 28  2024 named.conf
    drwxr-xr-x   2 root  wheel         512 Jan 10 04:17 namedb
    -rw-r--r--   1 root  wheel         774 Mar 28  2024 netconfig
    -rw-r--r--   1 root  wheel         411 Mar 28  2024 networks
    -rw-r--r--   1 root  wheel         669 Mar 28  2024 newsyslog.conf
    drwxr-xr-x   2 root  wheel         512 Jan 10 02:00 nsd
    -rw-r--r--   1 root  wheel         621 Mar 28  2024 nsswitch.conf
    -rw-r--r--   1 root  wheel        5316 Mar 28  2024 ntp.conf
    drwxr-xr-x   2 root  wheel         512 Jan 10 02:00 openldap
    drwxr-xr-x   5 root  wheel         512 Jan 10 04:17 openssl
    drwxr-xr-x   2 root  wheel         512 Jan 10 04:17 pam.d
    -rw-r--r--   1 root  wheel        1812 Dec 17 04:16 passwd
    -rw-r--r--   1 root  wheel         162 Mar 28  2024 passwd.conf
    -rw-r--r--   1 root  wheel        1028 Mar 28  2024 pf.conf
    -r--r--r--   1 root  wheel       29327 Mar 28  2024 pf.os
    -rw-r--r--   1 root  wheel         217 Mar 28  2024 phones
    -rw-r--r--   1 root  wheel          74 Oct  7 18:15 pkg_install.conf
    -rw-r--r--   1 root  wheel         202 Mar 28  2024 pkgpath.conf
    drwxr-xr-x   2 root  wheel         512 Jan 10 04:17 postfix
    drwxr-xr-x   3 root  wheel         512 Jan 10 02:00 powerd
    -rw-r--r--   1 root  wheel        1579 Mar 28  2024 printcap
    -rw-r--r--   1 root  wheel          98 Mar 28  2024 profile
    -rw-r--r--   1 root  wheel       28961 Mar 28  2024 protocols
    -rw-r--r--   1 root  wheel       40960 Dec 17 04:16 pwd.db
    drwxr-xr-x   2 root  wheel         512 Jan 10 02:00 racoon
    -rw-r--r--   1 root  wheel         350 Mar 28  2024 rbootd.conf
    -rw-r--r--   1 root  wheel       12927 Mar 28  2024 rc
    -rw-r--r--   1 root  wheel         660 Nov 13 22:09 rc.conf
    drwxr-xr-x   2 root  wheel         512 Jan 10 02:00 rc.conf.d
    drwxr-xr-x   2 root  wheel        2560 Jan 10 04:17 rc.d
    -rw-r--r--   1 root  wheel         562 Mar 28  2024 rc.local
    -rw-r--r--   1 root  wheel        1770 Jan 13 02:41 rc.shutdown
    -rw-r--r--   1 root  wheel       34558 Mar 28  2024 rc.subr
    -r--r--r--   1 root  wheel        4939 Jan 10 04:17 release
    -rw-r--r--   1 root  wheel        1454 Mar 28  2024 remote
    -rw-r--r--   1 root  wheel         102 Nov 13 22:09 resolv.conf
    lrwxr-xr-x   1 root  wheel          13 Mar 28  2024 rmt -> /usr/sbin/rmt
    -rw-r--r--   1 root  wheel         831 Mar 28  2024 rpc
    drwxr-xr-x   4 root  wheel         512 Mar 28  2024 saslc.d
    -rw-r--r--   1 root  wheel       29368 Nov 14 03:17 security
    -rw-r--r--   1 root  wheel         220 Mar 28  2024 security.conf
    -rw-r--r--   1 root  wheel     3555799 Mar 28  2024 services
    -rw-r--r--   1 root  wheel         249 Nov 16 19:22 shells
    -rw-r--r--   1 root  wheel         419 Mar 28  2024 shrc
    drwxr-xr-x   2 root  wheel         512 Jan 10 04:17 skel
    -rw-------   1 root  operator        0 Mar 28  2024 skeykeys
    drwxr-xr-x   2 root  wheel         512 Jan 10 02:00 sliphome
    -rw-------   1 root  wheel       40960 Dec 17 04:16 spwd.db
    drwxr-xr-x   2 root  wheel         512 Jan 10 04:17 ssh
    -rw-r--r--   1 root  wheel         797 Mar 28  2024 sysctl.conf
    -rw-r--r--   1 root  wheel         597 Mar 28  2024 syslog.conf
    -rw-r--r--   1 root  wheel         123 Mar 28  2024 ttyaction
    -rw-r--r--   1 root  wheel         871 Mar 28  2024 ttys
    drwxr-xr-x   2 root  wheel         512 Jan 10 02:00 unbound
    -rw-r--r--   1 root  wheel         142 Nov 13 22:09 usermgmt.conf
    -rw-r--r--   1 root  wheel        2344 Mar 28  2024 weekly
    -rw-r--r--   1 root  wheel         212 Mar 28  2024 weekly.conf
    -rw-------   1 root  wheel         197 Mar 28  2024 wpa_supplicant.conf
    -rw-r--r--   1 root  wheel        2575 Mar 28  2024 wscons.conf
    drwxr-xr-x   2 root  wheel         512 Jan 10 02:00 zfs
    linveo# 
    

    I hope everyone gets the servers they want!

  • Not_OlesNot_Oles Hosting ProviderContent Writer

    etcupdate has a man page which isn't too long.

    linveo# nroff -man /usr/share/man/man8/etcupdate.8 | wc -l
         234
    linveo# 
    

    Here is the full etcupdate(8) man page, if you want to take a peek under the spoiler.

    NetBSD also has its man pages online. man etcupdate(8) from NetBSD-current for amd64 is at https://man.netbsd.org/amd64/etcupdate.8.

    linveo# nroff -man /usr/share/man/man8/etcupdate.8 
    ETCUPDATE(8)            NetBSD System Manager's Manual            ETCUPDATE(8)
    
    NAME
         etcupdate -- update the configuration and startup files in /etc
    
    SYNOPSIS
         etcupdate [-alv] [-d destdir] [-p pager] [-s (srcdir | tgzdir | tgzfile)]
                   [-t temproot] [-w width]
         etcupdate (-h | -?)
    
    DESCRIPTION
         etcupdate is a tool that lets the administrator update the configuration
         and startup files in /etc (and some other directories like /dev, /root
         and /var) without having to manually check and modify every file.  The
         administrator should run this script after performing an operating system
         update (e.g. after running make build in /usr/src or after extracting new
         binary distribution files) to update to the latest configuration and
         startup files.
    
         etcupdate compares the new configuration files against the currently
         installed files.  The user is given the option of installing, merging or
         deleting each modified or missing file.  The user can also view the dif-
         ferences between the files.  By default, it shows the differences in the
         unified diff format.  The default format can be toggled to show the dif-
         ferences in unified, context, or side by side formats or an user-defined
         command may be used to view differences.  (And if wdiff is installed, it
         can also show differences on a word by word basis.)
    
         etcupdate also detects if the user installs certain special files and
         performs corresponding tasks like remaking device nodes or rebuilding a
         database from the aliases(5) file.  Finally, etcupdate runs
         postinstall(8) to check the results.
    
         etcupdate needs a clean set of new configuration files to compare the
         existing files against.  These files, called the ``reference files'' in
         this manual, may be derived from either a source or binary distribution
         of NetBSD.
    
         If the user is updating from sources (which is the default mode),
         etcupdate will first create a copy of the reference files by running make
         distribution in /usr/src/etc, installing the files to a so-called
         temproot.  (See usage of the -s srcdir and -t temproot options later in
         this manual page.)  Although this is the default mode, it is not recom-
         mended (see the ``BUGS'' section).
    
         Instead of using sources, it is recommended that the user should extract
         one or more binary distribution sets in a special location and use those
         as the reference files (see usage of the -s tgzdir option later in this
         manual page), or specify one or more binary distribution sets directly
         (see usage of the -s tgzfile option later in this manual page).
    
         The following options are available:
    
         -a             etcupdate can automatically update files which have not
                        been modified locally.  The -a flag instructs etcupdate to
                        store MD5 checksums in /var/etcupdate and use these check-
                        sums to determine if there have been any local modifica-
                        tions.
    
         -d destdir     Use destdir instead of / as the top of the file system
                        hierarchy to be updated.  For example, destdir/etc will be
                        used instead of /etc.
    
         -h             Display help to stdout, and exit.
    
         -l             Automatically skip files with unchanged RCS IDs.  This has
                        the effect of leaving alone files that have been altered
                        locally but which have not been changed in the reference
                        files.  Since this works using RCS IDs, files without RCS
                        IDs will not be skipped even if only modified locally.
                        This flag may be used together with the -a flag described
                        above.
    
         -p pager       The pager to use when displaying files.  By default this
                        is more(1) but it can be changed either with this option
                        or by defining the PAGER variable.
    
         -s (srcdir | tgzdir | tgzfile)
                        The location of the reference files, or the NetBSD source
                        files used to create the reference files.  This may be
                        specified in one of three ways:
    
                        -s srcdir      The top level directory of the NetBSD
                                       source tree.  By default this is /usr/src
                                       but it can be changed either with this
                                       option or the SRCDIR variable.  The refer-
                                       ence files will be created by running
                                       ``make distribution'' in the srcdir/etc
                                       directory.  Note that srcdir should refer
                                       to the top of the source directory tree;
                                       earlier versions of etcupdate expected
                                       srcdir to refer to the etc subdirectory
                                       within the source tree.
    
                        -s tgzdir      A directory in which reference files have
                                       been extracted from a binary distribution
                                       of NetBSD.  The files that are distributed
                                       in the ``etc.tgz'' or ``etc.tar.xz'' set
                                       file must be present.  The files that are
                                       distributed in the ``xetc.tgz'' or
                                       ``xetc.tar.xz'' set file are optional.  The
                                       reference files from the specified direc-
                                       tory will be copied to the temproot direc-
                                       tory.
    
                        -s tgzfile     The location of a set file (or ``tgz
                                       file'') such as ``etc.tgz'', ``etc.tar.xz''
                                       or ``xetc.tgz'' from a binary distribution
                                       of NetBSD.  Each set file is a compressed
                                       archive containing reference files, which
                                       will be extracted to the temproot direc-
                                       tory.  Multiple -s options may be used to
                                       specify multiple set files.  The
                                       ``etc.tgz'' or ``etc.tar.xz'' set file must
                                       be specified.  The ``xetc.tgz'' or
                                       ``xetc.tar.xz'' set file is optional.
    
         -t temproot    Specifies the location of the temproot directory.  This
                        directory will be used for a temporary copy of the refer-
                        ence files created by running ``make distribution'' in the
                        source directory specified by -s srcdir, or a temporary
                        copy of the reference files extracted from the binary sets
                        specified by -s tgzfile, or a temporary copy of the refer-
                        ence files from the directory specified by -s tempdir.  By
                        default this is /tmp/temproot but can be changed either
                        with this option or the TEMPROOT environment variable.
    
         -v             Makes etcupdate verbose about its actions.
    
         -w width       Sets screen width used during interactive merge.  By
                        default this is the number of columns stty(1) reports but
                        it can be changed either with this option or by defining
                        the WIDTH variable.  This is useful for xterm(1) users
                        with wider shell windows.
    
         -?             Display help to stdout, and exit.
    
    ENVIRONMENT
         TEMPROOT       Sets a default value for temproot.  See -t above.
    
         SRCDIR         The location of the NetBSD sources files.  See -s above.
    
         PAGER          The pager to use when displaying files.  See -p above.
    
         WIDTH          The screen width used during interactive merge.  See -w
                        above.
    
         IGNOREFILES    A list of files that etcupdate should ignore.  Files
                        listed in this variable will never be considered for
                        updating by etcupdate.
    
    FILES
         The environment variables can also be defined in the following configura-
         tion files.  The user's personal configuration file settings override the
         global settings.
    
         /etc/etcupdate.conf
    
         ~/.etcupdaterc
    
    EXAMPLES
         You have just upgraded your NetBSD host from 3.0 to 4.0 and now it's time
         to update the configuration files as well.  To update the configuration
         files from the sources (if you have the /usr/src/etc directory):
    
               etcupdate
    
         The default location of the source files is /usr/src but this may be
         overridden with the -s srcdir command line argument:
    
               etcupdate -s /some/where/src
    
         To update the configuration files from binary distribution sets do some-
         thing like this:
    
               etcupdate -s /some/where/etc.tgz -s /some/where/xetc.tgz
    
         or like this:
    
               mkdir /tmp/temproot
               cd /tmp/temproot
               tar -xpzf /some/where/etc.tgz
               tar -xpzf /some/where/xetc.tgz
               etcupdate -s /tmp/temproot
    
         You have modified only few files in the /etc directory so you would like
         install most of the updates without being asked.  To automatically update
         the unmodified configuration files:
    
               etcupdate -a
    
         To get a better idea what's going on, use the -v flag:
    
               etcupdate -v
    
    SEE ALSO
         cmp(1), more(1), rcs(1), sdiff(1), stty(1), aliases(5), postinstall(8)
    
    HISTORY
         The etcupdate command appeared in NetBSD 1.6.
    
         In NetBSD 4.0, the -s tgzfile option was added, the -b tempdir option was
         converted to -s tgzdir, and the -s srcdir option was changed to refer to
         the top of the source directory tree rather than to the etc subdirectory.
    
         In NetBSD 5.0, the ability to specify multiple colon-separated files with
         a single -s option was deprecated, and options deprecated in NetBSD 4.0
         were removed.
    
         In NetBSD 7.0, the ability to specify multiple colon-separated files with
         a single -s option was removed (multiple -s options must be used
         instead), and the -d destdir option was added.
    
    AUTHORS
         The script was written by Martti Kuparinen <[email protected]> and
         improved by several other NetBSD users.
    
         The idea for this script (including code fragments, variable names etc.)
         came from the FreeBSD mergemaster (by Douglas Barton).  Unlike the
         FreeBSD mergemaster, this does not use CVS version tags by default to
         compare if the files need to be updated.  Files are compared with cmp(1)
         as this is more reliable and the only way if the version numbers are the
         same even though the files are different.
    
    BUGS
         If a source directory is specified via the ``-s srcdir'' option (or if
         the /usr/src directory is used by default), then etcupdate will run
         ``make distribution'' in the etc subdirectory of the source directory,
         but it will not use the same options or environment variables that would
         be used during a full build of the operating system.  For this reason,
         use of the ``-s srcdir'' option is not recommended, and use of the ``-s
         tgzdir'' or ``-s tgzfile'' options is recommended.
    
    NetBSD 10.99                   January 15, 2022                   NetBSD 10.99
    linveo# 
    

    I hope everyone gets the servers they want!

  • Not_OlesNot_Oles Hosting ProviderContent Writer

    Now, etcupdate itself.

    linveo# wc -l $(which etcupdate)
         855 /usr/sbin/etcupdate
    linveo# 
    
    linveo# cat -n /usr/sbin/etcupdate
         1  #!/bin/sh
         2  #
         3  # $NetBSD: etcupdate,v 1.65 2022/01/17 08:47:03 lukem Exp $
         4  #
         5  # Copyright (c) 2001-2022 The NetBSD Foundation, Inc.
         6  # All rights reserved.
         7  #
         8  # This code is derived from software contributed to The NetBSD Foundation
         9  # by Martti Kuparinen.
        10  #
        11  # Redistribution and use in source and binary forms, with or without
        12  # modification, are permitted provided that the following conditions
        13  # are met:
        14  # 1. Redistributions of source code must retain the above copyright
        15  #    notice, this list of conditions and the following disclaimer.
        16  # 2. Redistributions in binary form must reproduce the above copyright
        17  #    notice, this list of conditions and the following disclaimer in the
        18  #    documentation and/or other materials provided with the distribution.
        19  #
        20  # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
        21  # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
        22  # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
        23  # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
        24  # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
        25  # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
        26  # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
        27  # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
        28  # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
        29  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
        30  # POSSIBILITY OF SUCH DAMAGE.
        31  #
        32  #
        33  # This script helps you to update the configuration files in /etc
        34  # after an operating system upgrade. Instead of running "make distribution"
        35  # in /usr/src/etc (and losing your current configuration) you can easily
        36  # see the modifications and either install the new version or merge the
        37  # changes in to your current configuration files.
        38  #
        39  # This script was written by Martti Kuparinen <[email protected]> and
        40  # improved by several other NetBSD users.
        41  #
        42  # The idea for this script (including code fragments, variable names etc.)
        43  # came from the FreeBSD mergemaster (by Douglas Barton).
        44  #
        45  PATH="/sbin:/usr/sbin:/bin:/usr/bin:${PATH}"
        46
        47  # Default settings
        48  PROG="${0##*/}"
        49  DESTDIR=""              # must not have a trailing slash
        50  DESTDIR_BRE=""          # basic regex to match ${DESTDIR}
        51  TEMPROOT="${TEMPROOT:=/tmp/temproot}"
        52  PAGER="${PAGER:=/usr/bin/more}"
        53  SWIDTH="$(stty size | awk '{w=$2}END{if(w==0){w=80}print w}')"
        54  WIDTH="${WIDTH:="${SWIDTH}"}"
        55  DIFF_COMMAND="diff -u"
        56  VERBOSE=false
        57  CONTINUE=false
        58  SOURCEMODE=false        # true for "-s source_dir"
        59  SRCDIR=                 # directory for SOURCEMODE
        60  BINARYMODE=false        # true for both BINARYDIRMODE and BINARYTGZMODE
        61  BINARYDIRMODE=false     # true for "-s extracted_dir"
        62  BINARYDIR=              # directory name for BINARYDIRMODE
        63  BINARYTGZMODE=false     # true for "-s etc.tgz"
        64  TGZLIST=                # quoted list list of files for BINARYTGZMODE
        65  SRC_ARGLIST=            # quoted list of "-s" args
        66  N_SRC_ARGS=0            # number of "-s" args
        67  AUTOMATIC=false
        68  LOCALSKIP=false
        69  MACHINE="${MACHINE:="$(uname -m)"}"
        70  export MACHINE
        71  MACHINE_ARCH="${MACHINE_ARCH:="$(uname -p)"}"
        72  export MACHINE_ARCH
        73
        74  # Settings for post-installation procedures
        75  NEED_ANYTHING=false
        76  NEED_MAKEDEV=false
        77  NEED_MTREE=false
        78  NEED_NEWALIASES=false
        79  NEED_PWD_MKDB=false
        80  NEED_SERVICES_MKDB=false
        81
        82
        83  help()
        84  {
        85          cat << EOF
        86
        87  Usage: ${PROG} [-alv] [-d DESTDIR] [-p PAGER] [-s SRC_ARG] [-t TEMPROOT] [-w WIDTH]
        88         ${PROG} ( -h | -? )
        89
        90  Options:
        91
        92    -a           Automatically update unmodified files.
        93    -d DESTDIR   Destination directory to check. [/]
        94    -h           Display this help, and exit.
        95    -l           Automatically skip files with strictly local changes
        96                 (this option has no effect on files lacking RCS Ids).
        97    -p PAGER     Which pager to use              [/usr/bin/more]
        98    -s SRC_ARG   Location of the source files.   [/usr/src]
        99                 This may be any of the following:
       100                   -s SRC_DIR   A directory that contains a NetBSD
       101                                source tree.
       102                   -s TGZ_DIR   A directory in which one or both of
       103                                "etc.tgz" and "xetc.tgz" have been extracted.
       104                   -s TGZ_FILE  A distribution set file such as "etc.tgz" or
       105                                "xetc.tgz".  May be specified multiple times.
       106    -t TEMPROOT  Where to store temporary files. [/tmp/temproot]
       107    -w WIDTH     Screen width.                   [80]
       108    -v           Be more verbose.
       109    -?           Display this help, and exit.
       110
       111  EOF
       112  }
       113
       114  usage()
       115  {
       116          help 1>&2
       117          exit 1
       118  }
       119
       120  verbose()
       121  {
       122          # $* = message to display if in verbose mode
       123
       124          ${VERBOSE} && echo "${@}"
       125  }
       126
       127  yesno()
       128  {
       129          # $* = message to display
       130
       131          echo -n "${@}? (y/[n]) "
       132          read ANSWER
       133          case "${ANSWER}" in
       134                  y|Y)
       135                          return 0
       136                          ;;
       137                  *)
       138                          return 1
       139                          ;;
       140          esac
       141  }
       142
       143  # Quote args to make them safe in the shell.
       144  # Usage: quotedlist="$(shell_quote args...)"
       145  #
       146  # After building up a quoted list, use it by evaling it inside
       147  # double quotes, like this:
       148  #    eval "set -- $quotedlist"
       149  # or like this:
       150  #    eval "\$command $quotedlist \$filename"
       151  #
       152  shell_quote()
       153  {(
       154          local result=''
       155          local arg qarg
       156          LC_COLLATE=C ; export LC_COLLATE # so [a-zA-Z0-9] works in ASCII
       157          for arg in "$@" ; do
       158                  case "${arg}" in
       159                  '')
       160                          qarg="''"
       161                          ;;
       162                  *[!-./a-zA-Z0-9]*)
       163                          # Convert each embedded ' to '\'',
       164                          # then insert ' at the beginning of the first line,
       165                          # and append ' at the end of the last line.
       166                          # Finally, elide unnecessary '' pairs at the
       167                          # beginning and end of the result and as part of
       168                          # '\'''\'' sequences that result from multiple
       169                          # adjacent quotes in he input.
       170                          qarg="$(printf "%s\n" "$arg" | \
       171                              ${SED:-sed} -e "s/'/'\\\\''/g" \
       172                                  -e "1s/^/'/" -e "\$s/\$/'/" \
       173                                  -e "1s/^''//" -e "\$s/''\$//" \
       174                                  -e "s/'''/'/g"
       175                                  )"
       176                          ;;
       177                  *)
       178                          # Arg is not the empty string, and does not contain
       179                          # any unsafe characters.  Leave it unchanged for
       180                          # readability.
       181                          qarg="${arg}"
       182                          ;;
       183                  esac
       184                  result="${result}${result:+ }${qarg}"
       185          done
       186          printf "%s\n" "$result"
       187  )}
       188
       189  # Convert arg $1 to a basic regular expression (as in sed)
       190  # that will match the arg.  This works by inserting backslashes
       191  # before characters that are special in basic regular expressions.
       192  # It also inserts backslashes before the extra characters specified
       193  # in $2 (which defaults to "/,").
       194  # XXX: Does not handle embedded newlines.
       195  # Usage: regex="$(bre_quote "${string}")"
       196  bre_quote()
       197  {
       198          local arg="$1"
       199          local extra="${2-/,}"
       200          printf "%s\n" "${arg}" | sed -e 's/[][^$.*\\'"${extra}"']/\\&/g'
       201  }
       202
       203  install_dir()
       204  {
       205          # $1 = target directory (relative to ${DESTDIR})
       206
       207          NEED_ANYTHING=true
       208          if yesno "Create ${DESTDIR}${1}"; then
       209                  verbose "Creating ${DESTDIR}${1}"
       210                  mkdir -p "${DESTDIR}${1}" || exit 1
       211                  NEED_MTREE=true
       212          fi
       213  }
       214
       215  install_file()
       216  {
       217          # $1 = target file (relative to ${DESTDIR})
       218
       219          NEED_ANYTHING=true
       220          # Install the new file
       221          verbose "Installing ${DESTDIR}${1}"
       222          cp -p "${TEMPROOT}${1}" "${DESTDIR}${1}" && rm -f "${TEMPROOT}${1}"
       223
       224          # Check if this was a special file
       225          case "${1}" in
       226          /dev/MAKEDEV)
       227                  NEED_MAKEDEV=true
       228                  ;;
       229          /dev/MAKEDEV.local)
       230                  NEED_MAKEDEV=true
       231                  ;;
       232          /etc/mail/aliases)
       233                  NEED_NEWALIASES=true
       234                  ;;
       235          /etc/master.passwd)
       236                  NEED_PWD_MKDB=true
       237                  ;;
       238          /etc/services)
       239                  NEED_SERVICES_MKDB=true
       240                  ;;
       241          esac
       242  }
       243
       244  install_checksum()
       245  {
       246          # $1 = target file (relative to ${DESTDIR})
       247
       248          ${AUTOMATIC} || return
       249
       250          NEED_ANYTHING=true
       251          D="$(dirname "${1}")"
       252          mkdir -p "${DESTDIR}/var/etcupdate/${D}"
       253          verbose "Saving MD5 checksum for ${DESTDIR}${1} to" \
       254              "${DESTDIR}/var/etcupdate/${1}"
       255          # The sed part of the following pipeline changes things like
       256          # "MD5 (/path/to/dest/dir/etc/filename) = abc123" to
       257          # "MD5 (/etc/filename) = abc123".
       258          md5 "${DESTDIR}${1}" | sed -e "s,(${DESTDIR_BRE},(," \
       259              > "${DESTDIR}/var/etcupdate/${1}"
       260  }
       261
       262  # Initialise the DIFF_EXTRA_OPTIONS variable.
       263  init_diff_extra_options()
       264  {
       265          #
       266          # Start with a few options that are always available.
       267          #
       268          DIFF_EXTRA_OPTIONS=\
       269  "  su  Show differences in unified format (\"diff -u\")
       270    sc  Show differences in context format (\"diff -c\")
       271    ss  Show differences side by side (\"sdiff -w${WIDTH}\")"
       272          #
       273          # wdiff is not part of the base system, but the
       274          # user might have installed it from pkgsrc.  It is
       275          # useful to show differences on a word by word basis
       276          # instead of line by line.  If it is executable
       277          # then offer to use it in the menu.
       278          #
       279          if (wdiff /dev/null /dev/null) >/dev/null 2>&1 ; then
       280                  DIFF_EXTRA_OPTIONS="${DIFF_EXTRA_OPTIONS}
       281    sw  Show differences word by word (\"wdiff -n -l\")"
       282          fi
       283          #
       284          # End with an option to use a user-specified diff-like command.
       285          #
       286          DIFF_EXTRA_OPTIONS="${DIFF_EXTRA_OPTIONS}
       287    scommand Show differences using the specified diff-like command"
       288  }
       289
       290  diff_and_merge_file()
       291  {
       292          # $1 = target file (relative to ${DESTDIR})
       293
       294          if cmp -s "${TEMPROOT}${1}" "${DESTDIR}${1}"; then
       295                  verbose "===> ${1} (ok)"
       296                  rm -f "${TEMPROOT}${1}"
       297                  install_checksum "${1}"
       298                  return
       299          fi
       300
       301          if ${AUTOMATIC} && [ -f "${DESTDIR}/var/etcupdate/${1}" ]; then
       302                  SUM1="$(md5 "${1}")"
       303                  SUM2="$(cat "${DESTDIR}/var/etcupdate/${1}")"
       304                  if [ "${SUM1}" = "${SUM2}" ]; then
       305                          install_file "${1}"
       306                          install_checksum "${1}"
       307                          return
       308                  fi
       309          fi
       310
       311          if ${LOCALSKIP}; then
       312                  ID1="$(ident -q "${TEMPROOT}${1}" | sed -n 2p)"
       313                  ID1="${ID1:-0}"
       314                  ID2="$(ident -q "${DESTDIR}${1}" | sed -n 2p)"
       315                  ID2="${ID2:-1}"
       316                  if [ "${ID1}" = "${ID2}" ]; then
       317                          verbose "===> ${1} (ok:RCS)"
       318                          rm -f "${TEMPROOT}${1}"
       319                          return
       320                  fi
       321          fi
       322
       323          clear
       324          if [ ! -f "${DESTDIR}${1}" ]; then
       325                  verbose "===> ${DESTDIR}${1} (missing)"
       326                  DOES_EXIST=false
       327          else
       328                  verbose "===> ${DESTDIR}${1} (modified)"
       329                  verbose ""
       330                  DOES_EXIST=true
       331                  diff -u "${DESTDIR}${1}" "${TEMPROOT}${1}" | ${PAGER}
       332          fi
       333
       334          STAY_HERE=true
       335          ALREADY_MERGED=false
       336
       337          # Determine name for the backup file (/foo/._etcupdate.bar)
       338          D="$(dirname  "${TEMPROOT}${1}")"
       339          F="$(basename "${TEMPROOT}${1}")"
       340          B="${D}/.etcupdate.${F}"
       341          F="${D}/${F}"
       342
       343          while ${STAY_HERE}; do
       344
       345                  # Ask the user if (s)he wants to install the new
       346                  # version or perform a more complicated manual work.
       347                  echo ""
       348                  echo -n "File: ${DESTDIR}${1}"
       349                  if [ ! -f "${DESTDIR}${1}" ]; then
       350                          echo -n " (missing)"
       351                  else
       352                          echo -n " (modified)"
       353                  fi
       354                  echo ""
       355                  echo ""
       356                  echo "Please select one of the following operations:"
       357                  echo ""
       358                  if ! ${DOES_EXIST}; then
       359                          cat << EOF
       360    d  Don't install the missing file
       361    i  Install the missing file
       362    v  Show the missing file
       363
       364  EOF
       365                  elif ! ${ALREADY_MERGED}; then
       366                          cat << EOF
       367    d  Don't install the new file (keep your old file)
       368    i  Install the new file (overwrites your local modifications!)
       369    m  Merge the currently installed and new files
       370    s  Show the differences between the currently installed and new files
       371  ${DIFF_EXTRA_OPTIONS}
       372    v  Show the new file
       373
       374  EOF
       375                  else
       376                          cat << EOF
       377    d  Don't install the merged file (keep your old file)
       378    i  Install the merged file (overwrites your old file)
       379    m  Merge again (your old file against the result from the previous merge)
       380    s  Show the differences between the currently installed and new merged files
       381  ${DIFF_EXTRA_OPTIONS}
       382    u  Undo merge (start again with the original version of the new file)
       383    v  Show the merged file
       384
       385  EOF
       386                  fi
       387                  echo -n "What do you want to do? [Leave it for later] "
       388                  read ANSWER
       389                  case "${ANSWER}" in
       390
       391                  [dD])
       392                          verbose "Removing ${TEMPROOT}${1}"
       393                          rm -f "${TEMPROOT}${1}"
       394                          STAY_HERE=false
       395                          ;;
       396                  [iI])
       397                          install_file "${1}"
       398                          if ! ${ALREADY_MERGED}; then
       399                                  install_checksum "${1}"
       400                          fi
       401                          STAY_HERE=false
       402                          ;;
       403                  [mM])
       404                          ${DOES_EXIST} || continue
       405                          [ ! -f "${B}" ] && cp "${F}" "${B}"
       406                          cp "${TEMPROOT}${1}" "${TEMPROOT}${1}.merged"
       407                          sdiff -o "${TEMPROOT}${1}.merged"       \
       408                                  --width=${WIDTH}                \
       409                                  --suppress-common-lines --text  \
       410                                  "${DESTDIR}${1}" "${TEMPROOT}${1}"
       411                          mv -f "${TEMPROOT}${1}.merged" "${TEMPROOT}${1}"
       412                          ALREADY_MERGED=true
       413                          ;;
       414                  [sS]*)
       415                          ${DOES_EXIST} || continue
       416                          case "${ANSWER}" in
       417                          [sS])   : no change ;;
       418                          [sS]u)  DIFF_COMMAND="diff -u" ;;
       419                          [sS]c)  DIFF_COMMAND="diff -c" ;;
       420                          [sS]s)  DIFF_COMMAND="sdiff -w${WIDTH}" ;;
       421                          [sS]w)  DIFF_COMMAND="wdiff -n -l" ;;
       422                          [sS]*)  DIFF_COMMAND="${ANSWER#?}" ;;
       423                          esac
       424                          ${DIFF_COMMAND} "${DESTDIR}${1}" "${TEMPROOT}${1}" \
       425                                  | ${PAGER}
       426                          ;;
       427                  [uU])
       428                          if [ -f "${B}" ]; then
       429                                  echo "*** Restoring ${F}"
       430                                  mv -f "${B}" "${F}"
       431                          fi
       432                          ALREADY_MERGED=false
       433                          ;;
       434                  [vV])
       435                          ${PAGER} "${TEMPROOT}${1}"
       436                          ;;
       437                  "")
       438                          STAY_HERE=false
       439                          ;;
       440                  *)
       441                          echo "*** Invalid selection!"
       442                          ;;
       443                  esac
       444          done
       445          rm -f "$B"
       446  }
       447
       448  # Set the environment for make.
       449  set_makeenv()
       450  {
       451          #
       452          # INSTALL_DONE=1 prevents installation of unwanted
       453          # files (things that are not part of the etc set).
       454          # BUILD=1 allows building of files that are wanted.
       455          #
       456          MAKE_ENV="                      \
       457                  NETBSDSRCDIR=$(shell_quote "${SRCDIR}") \
       458                  DESTDIR=$(shell_quote "${TEMPROOT}")    \
       459                  MAKE=make               \
       460                  MTREE=mtree             \
       461                  TOOL_MTREE=mtree        \
       462                  INSTALL_DONE=1          \
       463                  BUILD=1                 \
       464                  USETOOLS=never"
       465  }
       466
       467  #
       468  # main()
       469  #
       470
       471  # Read global configuration
       472  GLOBALRC="/etc/${PROG}.conf"
       473  [ -r ${GLOBALRC} ] && . ${GLOBALRC}
       474
       475  # Read user configuration
       476  USERRC="${HOME}/.{PROG}rc"
       477  [ -r ${USERRC} ] && . ${USERRC}
       478
       479  # Read command line arguments
       480  while getopts :ad:hlp:s:t:vw: i
       481  do
       482          case "${i}" in
       483          a)
       484                  AUTOMATIC=true
       485                  ;;
       486          d)
       487                  DESTDIR="${OPTARG}"
       488                  ;;
       489          h)
       490                  help
       491                  exit 0
       492                  ;;
       493          l)
       494                  LOCALSKIP=true
       495                  ;;
       496          p)
       497                  PAGER="${OPTARG}"
       498                  ;;
       499          s)
       500                  # Three cases:
       501                  # -s tgzfile       (may be repeated)
       502                  # -s srcdir        (may not be repeated)
       503                  # -s extracted_dir (may not be repeated)
       504                  arg="${OPTARG}"
       505                  qarg="$(shell_quote "${OPTARG}")"
       506                  N_SRC_ARGS=$(( N_SRC_ARGS + 1 ))
       507                  SRC_ARGLIST="${SRC_ARGLIST}${SRC_ARGLIST:+ }-s ${qarg}"
       508                  if [ -f "${arg}" ]; then
       509                          # arg refers to a *.tgz file.
       510                          # This may happen twice, for both etc.tgz and
       511                          # xetc.tgz, so we build up a list in TGZLIST.
       512                          BINARYMODE=true
       513                          BINARYTGZMODE=true
       514                          TGZLIST="${TGZLIST}${TGZLIST:+ }${qarg}"
       515                  elif [ -d "${arg}" ] && [ -f "${arg}/etc/Makefile" ]; then
       516                          # arg refers to a source directory
       517                          SOURCEMODE=true
       518                          SRCDIR="${arg}"
       519                  elif [ -d "${arg}" ] && [ -d "${arg}/etc" ] \
       520                          && ! [ -f "${arg}/etc/Makefile" ]
       521                  then
       522                          # arg refers to a directory where the
       523                          # sets have already been extracted
       524                          BINARYMODE=true
       525                          BINARYDIRMODE=true
       526                          BINARYDIR="${arg}"
       527                  else
       528                          echo "*** Nonexistent or invalid file or directory" \
       529                               "for -s ${arg}"
       530                          usage
       531                  fi
       532                  ;;
       533          t)
       534                  TEMPROOT="${OPTARG}"
       535                  ;;
       536          v)
       537                  VERBOSE=true
       538                  ;;
       539          w)
       540                  WIDTH="${OPTARG}"
       541                  ;;
       542          "?")
       543                  if [ "${OPTARG}" = "?" ]; then
       544                          help
       545                          exit 0
       546                  fi
       547                  echo 1>&2 "${PROG}: Unknown option -${OPTARG}"
       548                  usage
       549                  ;;
       550
       551          :)
       552                  echo 1>&2 "${PROG}: Missing argument for option -${OPTARG}"
       553                  usage
       554                  ;;
       555
       556          *)
       557                  echo 1>&2 "${PROG}: Unimplemented option -${i}"
       558                  exit 3
       559                  ;;
       560          esac
       561  done
       562  shift $((${OPTIND} - 1))
       563  if [ $# -ne 0 ] ; then
       564          echo 1>&2 "${PROG}: Unknown extra arguments"
       565          usage
       566  fi
       567
       568  # Last minute sanity checks
       569  if [ "$(id -u)" -ne 0 ]; then
       570          echo "*** ERROR: You MUST be root"
       571          exit 1
       572  fi
       573  DESTDIR="${DESTDIR%/}" # remove trailing slash, if any.  result might be "".
       574  DESTDIR_BRE="$(bre_quote "${DESTDIR}")"
       575  if [ "${N_SRC_ARGS}" -gt 1 ] && ( ${SOURCEMODE} || ${BINARYDIRMODE} ); then
       576          echo 1>&2 "${PROG}: Multiple -s args are allowed only with tgz files"
       577          usage
       578  fi
       579  case "${TEMPROOT}" in
       580  /*) : OK ;;
       581  *)  new="${PWD:-$(pwd)}/${TEMPROOT}"
       582      echo "*** NOTE: Using TEMPROOT \"${new}\" instead of \"${TEMPROOT}\""
       583      TEMPROOT="${new}"
       584      ;;
       585  esac
       586  if ${BINARYDIRMODE}; then
       587          SRCDIR="${TEMPROOT}"
       588  fi
       589  if ${BINARYTGZMODE}; then
       590          SRCDIR="${TEMPROOT}"
       591  fi
       592  if [ "${N_SRC_ARGS}" -eq 0 ]; then
       593          # default if no "-s" option was specified
       594          SOURCEMODE=true
       595          SRCDIR="/usr/src"
       596          SRC_ARGLIST="-s $(shell_quote "${SRCDIR}")"
       597  fi
       598  if [ -z "${SRCDIR}" -o -z "${TEMPROOT}" ]; then
       599          echo "*** ERROR: One of the following variables is undefined"
       600          echo ""
       601          echo "SRCDIR=\"${SRCDIR}\""
       602          echo "TEMPROOT=\"${TEMPROOT}\""
       603          echo ""
       604          exit 1
       605  fi
       606  if [ -r "${TEMPROOT}" ]; then
       607          echo ""
       608          echo "*** WARNING: ${TEMPROOT} already exists"
       609          echo ""
       610          if yesno "Continue previously aborted update"; then
       611                  CONTINUE=true
       612          elif yesno "Remove the old ${TEMPROOT}"; then
       613                  echo "*** Removing ${TEMPROOT}"
       614                  rm -rf "${TEMPROOT}"
       615          fi
       616  fi
       617
       618  if ! ${CONTINUE}; then
       619          # Create the temporary root directory
       620          echo "*** Creating ${TEMPROOT}"
       621          mkdir -p "${TEMPROOT}"
       622          if [ ! -d "${TEMPROOT}" ]; then
       623                  echo "*** ERROR: Unable to create ${TEMPROOT}"
       624                  exit 1
       625          fi
       626          # Are we using the sources or binaries?
       627          if ${BINARYTGZMODE}; then
       628                  # Populate ${TEMPROOT} from ${TGZLIST}
       629                  eval "set -- ${TGZLIST}"
       630                  for tgz in "$@"; do
       631                          if [ ! -f "${tgz}" ]; then
       632                                  echo "*** ERROR: Unable to find ${tgz}"
       633                                  exit 1
       634                          fi
       635                          echo "*** Populating ${TEMPROOT} from ${tgz}"
       636                          tar -zxpf "${tgz}" -C "${TEMPROOT}"
       637                          [ $? -ne 0 ] && exit 1
       638                  done
       639          elif ${BINARYDIRMODE}; then
       640                  # Populate ${TEMPROOT} from ${SRCDIR} by copying.
       641                  # Copy only the files that belong to the etc and xetc sets.
       642                  echo "*** Populating ${TEMPROOT} from ${BINARYDIR} (copying)"
       643                  for setname in etc xetc; do
       644                          mtreefile="${BINARYDIR}/etc/mtree/set.${setname}"
       645                          if ${VERBOSE}; then vflag="-v"; else vflag=""; fi
       646                          if [ -f "${mtreefile}" ]; then
       647                                  echo "*** Copying files belonging to" \
       648                                       "${setname} set"
       649                                  (cd "${BINARYDIR}" \
       650                                   && pax -rwdM ${vflag} "${TEMPROOT%/}/."
       651                                  ) <"${mtreefile}"
       652                                  [ $? -ne 0 ] && exit 1
       653                          else
       654                                  echo "*** Not copying files belonging to" \
       655                                       "${setname} set: ${mtreefile} not found"
       656                          fi
       657                  done
       658          elif ${SOURCEMODE}; then
       659                  # Populate ${TEMPROOT} from ${SRCDIR} by running make
       660                  if [ ! -f "${SRCDIR}/etc/Makefile" ]; then
       661                          echo "*** ERROR: Unable to find ${SRCDIR}/etc/Makefile"
       662                          exit 1
       663                  fi
       664                  set_makeenv
       665                  echo "*** Populating ${TEMPROOT} from ${SRCDIR} (make distribution)"
       666                  cd ${SRCDIR}/etc
       667                  if ! ${VERBOSE}; then
       668                          eval "${MAKE_ENV} make distribution > /dev/null"
       669                  else
       670                          eval "${MAKE_ENV} make distribution"
       671                  fi
       672                  [ $? -ne 0 ] && exit 1
       673          fi
       674          if ! [ -f "${TEMPROOT}/etc/mtree/set.etc" ]; then
       675                  echo "*** ERROR: Files from the etc.tgz set are missing"
       676                  exit 1
       677          fi
       678          if [ ! -f "${TEMPROOT}/dev/MAKEDEV" ]; then
       679                  echo ""
       680                  echo "*** WARNING: ${TEMPROOT}/dev/MAKEDEV not found"
       681                  echo "Make sure you update /dev/MAKEDEV later and run"
       682                  echo "(cd /dev && ./MAKEDEV all) to rebuild the device nodes"
       683                  echo ""
       684          fi
       685
       686          # Ignore the following files during comparison
       687          rm -f "${TEMPROOT}"/etc/passwd
       688          rm -f "${TEMPROOT}"/etc/pwd.db
       689          rm -f "${TEMPROOT}"/etc/spwd.db
       690          find "${TEMPROOT}" -type f -size 0 -exec rm {} \;
       691
       692          # Ignore files we're told to ignore
       693          if [ ! -z "${IGNOREFILES}" ]; then
       694                  echo "*** Ignoring files: ${IGNOREFILES}"
       695                  for file in ${IGNOREFILES}; do
       696                          rm -f "${TEMPROOT}"${file}
       697                  done
       698          fi
       699
       700          # Are there any new directories?
       701          echo "*** Checking for new directories"
       702          exec 3<&0
       703          find "${TEMPROOT}" -type d | \
       704          while read i; do
       705                  D="${i#"${TEMPROOT}"}"
       706                  [ "x${i}" = "x${TEMPROOT}" ] && continue
       707                  [ ! -d "${D}" ] && install_dir "${D}" <&3
       708          done
       709  fi
       710
       711  # Start the comparison
       712  echo "*** Checking for added/modified files"
       713  init_diff_extra_options
       714  exec 3<&0
       715  find "${TEMPROOT}" -type f  -a ! -name \*.etcupdate.\* | \
       716  while read i; do
       717          D="${i#"${TEMPROOT}"}"
       718          diff_and_merge_file "${D}" <&3
       719  done
       720
       721  # Do we have files which were not processed?
       722  REMAINING="$(find "${TEMPROOT}" -type f -a ! -name \*.etcupdate.\*)"
       723  if [ ! -z "${REMAINING}" ]; then
       724          echo ""
       725          echo "*** The following files need your attention:"
       726          echo ""
       727          echo "${REMAINING}" | sed -e 's/^/  /'
       728          echo ""
       729  elif ! ${NEED_ANYTHING}; then
       730          echo ""
       731          echo "*** No changes were needed"
       732          echo ""
       733  fi
       734  if yesno "Remove ${TEMPROOT}"; then
       735          echo "*** Removing ${TEMPROOT}"
       736          rm -rf "${TEMPROOT}"
       737  else
       738          echo "*** Keeping ${TEMPROOT}"
       739  fi
       740
       741  # Clean up after "make distribution"
       742  if ${SOURCEMODE}; then
       743          echo "*** Cleaning up in ${SRCDIR}/etc"
       744          set_makeenv
       745          cd ${SRCDIR}/etc
       746          if ! ${VERBOSE}; then
       747                  eval "${MAKE_ENV} make clean > /dev/null"
       748          else
       749                  eval "${MAKE_ENV} make clean"
       750          fi
       751  fi
       752
       753  # Do some post-installation tasks
       754  if ${NEED_PWD_MKDB}; then
       755          pwd_mkdb_cmd="$(shell_quote \
       756              pwd_mkdb ${DESTDIR:+-d "${DESTDIR}"} \
       757              -p "${DESTDIR}/etc/master.passwd")"
       758          if yesno "Do you want to rebuild the password databases from the" \
       759                   "new ${DESTDIR}/etc/master.passwd"
       760          then
       761                  verbose "Running pwd_mkdb"
       762                  eval "${pwd_mkdb_cmd}"
       763          else
       764                  echo ""
       765                  echo "*** You MUST rebuild the password databases to make" \
       766                       "the changes visible"
       767                  echo "*** This is done by running \"${pwd_mkdb_cmd}\" as root"
       768                  echo ""
       769          fi
       770  fi
       771
       772  if ! ${NEED_SERVICES_MKDB}; then
       773          if test -e "${DESTDIR}/var/db/services.db" \
       774             -a ! -e "${DESTDIR}/var/db/services.cdb"
       775          then
       776                  NEED_SERVICES_MKDB=true
       777          fi
       778  fi
       779
       780  if ${NEED_SERVICES_MKDB}; then
       781          services_mkdb_cmd="$(shell_quote services_mkdb -V cdb \
       782              -o "${DESTDIR}/var/db/services.cdb" \
       783              "${DESTDIR}/etc/services")"
       784          if yesno "Do you want to rebuild the services databases from the" \
       785                   "new ${DESTDIR}/etc/services"
       786          then
       787                  verbose "Running services_mkdb"
       788                  eval "${services_mkdb_cmd}"
       789          else
       790                  echo ""
       791                  echo "*** You SHOULD rebuild the services databases to make" \
       792                       "the changes visible"
       793                  echo "*** This is done by running \"${services_mkdb_cmd}\"" \
       794                       "as root"
       795                  echo ""
       796          fi
       797  fi
       798  if ${NEED_MTREE}; then
       799          if yesno "You have created new directories. Run mtree to set" \
       800                   "permissions"
       801          then
       802                  (cd "${DESTDIR:-/}" && \
       803                      mtree -Udef "${DESTDIR}/etc/mtree/NetBSD.dist")
       804          fi
       805  fi
       806  if ${NEED_MAKEDEV}; then
       807          makedev_cmd="($(shell_quote cd "${DESTDIR}/dev") && ./MAKEDEV all)"
       808          if yesno "Do you want to rebuild the device nodes in ${DESTDIR}/dev"
       809          then
       810                  verbose "Running MAKEDEV in /dev"
       811                  eval "${makedev_cmd}"
       812          else
       813                  echo ""
       814                  echo "*** You SHOULD rebuild the device nodes in" \
       815                       "${DESTDIR}/dev"
       816                  echo "*** This is done by running \"${makedev_cmd}\" as root."
       817                  echo ""
       818          fi
       819  fi
       820  if ${NEED_NEWALIASES}; then
       821          newaliases_cmd="newaliases"
       822          # XXX newaliases doesn't work with DESTDIR.
       823          # We could check whether the system configuration is
       824          # sufficiently standard, and then run postalias(1) with the
       825          # right args to make it work, but changes to /etc/mail/aliases
       826          # are so rare that it doesn't seem worth the effort of checking
       827          # that the system's mail configuration is standard.
       828          if [ -z "${DESTDIR}" ] && \
       829              yesno "Do you want to rebuild the mail alias database"
       830          then
       831                  verbose "Running newaliases"
       832                  eval "${newaliases_cmd}"
       833          else
       834                  echo ""
       835                  echo "*** You MUST rebuild the mail alias database to make" \
       836                       "the changes visible"
       837                  echo "*** This is done by running \"${newaliases_cmd}\" as root"
       838                  if [ -n "${DESTDIR}" ]; then
       839                      postalias_cmd="$(shell_quote \
       840                          postalias "hash:${DESTDIR}/etc/mail/aliases")"
       841                      echo "*** but it won't work with DESTDIR=${DESTDIR}."
       842                      echo "*** If you use postfix(1) with the default" \
       843                           "configuration, then you can try"
       844                      echo "*** running \"${postalias_cmd}\" as root."
       845                  fi
       846                  echo ""
       847          fi
       848  fi
       849  if [ -x "${DESTDIR}/usr/sbin/postinstall" ]; then
       850          postinstall_cmd="$(shell_quote "${DESTDIR}/usr/sbin/postinstall" \
       851              ${DESTDIR:+-d "${DESTDIR}"}) ${SRC_ARGLIST} check"
       852          echo "*** Running ${DESTDIR}/usr/sbin/postinstall"
       853          eval "${postinstall_cmd}"
       854  fi
       855  echo "*** All done"
    linveo# 
    

    I hope everyone gets the servers they want!

  • Not_OlesNot_Oles Hosting ProviderContent Writer
    edited January 25

    When I tried etcupdate previously, I had seen, if I remember correctly, Section 35.1.4 of the NetBSD Guide.

    Section 35.1.4 says:

    Updating your system's configuration files is done in two steps. First, postinstall(8) is used to check and fix things that can be easily automated. Afterwards, etcupdate(8) is used to merge the remaining configuration file changes.

    # /usr/sbin/postinstall -s /usr/src check
    # /usr/sbin/postinstall -s /usr/src fix
    # /usr/sbin/etcupdate -s /usr/src
    

    So I think I might have gone ahead and tried /usr/sbin/etcupdate -s /usr/src. What seemed to happen might have been that etcupdate was trying to update /etc for every NetBSD architecture. Since I had built only on and for amd64, I didn't want to check every architecture.

    A few days later, on my second pass, I looked at the etcupdate man page and at the script itself. The man page mentioned that by default etcupdate works from a source directory. However, the man page also says that working from a source directory is not recommended:

         If the user is updating from sources (which is the default mode),
         etcupdate will first create a copy of the reference files by running make
         distribution in /usr/src/etc, installing the files to a so-called
         temproot.  (See usage of the -s srcdir and -t temproot options later in
         this manual page.)  Although this is the default mode, it is not
         recommended (see the "BUGS" section).
    
         Instead of using sources, it is recommended that the user should extract
         one or more binary distribution sets in a special location and use those
         as the reference files (see usage of the -s tgzdir option later in this
         manual page), or specify one or more binary distribution sets directly
         (see usage of the -s tgzfile option later in this manual page).
    

    I wondered what was the mention of the bugs all about?

    BUGS
         If a source directory is specified via the "-s srcdir" option (or if the
         /usr/src directory is used by default), then etcupdate will run "make
         distribution" in the etc subdirectory of the source directory, but it
         will not use the same options or environment variables that would be used
         during a full build of the operating system.  For this reason, use of the
         "-s srcdir" option is not recommended, and use of the "-s tgzdir" or "-s
         tgzfile" options is recommended.
    

    Initially, how did etcupdate get into a state where its default is not recommended? Is there another *nix program or script where the default is not recommended?

    So, which tgz files should I ask etcupdate to use? Did my use of build.sh create those tgz files? Where are they?

    Why can't etcupdate use the same options and environment variables as build.sh?

    What problem would be caused by having build.sh call etcupdate in a similar way to how build.sh calls postinstall? Maybe etcupdate, as called by build.sh, could list the relevant /etc files which were different -- approximately like how postinstall lists specific issues?

    What about the /etc files for programs compiled and installed via pkgsrc?

    Might it make sense to add an example to section 35.1.4 of the NetBSD Guide showing the option flags which should be used by someone upgrading from source on a single architecture? And also, if necessary, using a tgz file because of the bug mentioned in the etcupdate man page?

    Well, I thought I had to review etcupdate and its man page carefully so maybe I could figure out what I should be doing with etcupdate. Hence all these posts here, in case anyone else also wants to review. :)

    Thanks to Linveo for my blazing fast NetBSD VPS! <3 Thanks also to @cmeerw, whose NetBSD image allowed me to get NetBSD going on Linveo! <3 Thanks to the NetBSD developers! <3

    I hope everyone gets the servers they want!

  • Not_OlesNot_Oles Hosting ProviderContent Writer

    I found a nice post from 2001 by Martti Kuparinen, the author of NetBSD's etcupdate. I like the post because it provides examples. Of course, etcupdate has changed since 2001.

    @Not_Oles said, quoting the current etcupdate man page::
    ~~~
    Note that srcdir should refer
    to the top of the source directory tree;
    earlier versions of etcupdate expected
    srcdir to refer to the etc subdirectory
    within the source tree.

    ~~~

    Now I seem to have got through a run of etcupdate -av on our excellent Linveo NetBSD-current VPS. <3 From this test run of etcupdate, we have a 12,207 line transcript. :) It's really easy to grep through and find places I want to review! :)

    Before updating, I made a tar archive etc-revert.tgz, so we easily can go back to where /etc was before the update.

    I still haven't figured out whether the bug mentioned in the etcupdate man page might bite us. I don't remember applying any unusual environment variables during the last new source checkout and rebuild. Maybe we could get more insight into the bug by searching the NetBSD bug reports. I haven't looked for that yet.

    One advantage of the etcupdate process is that etcupdate presents a great opportunity to learn about the contents of /etc in quite a lot of detail . . . every single file!

    To review, as of the present moment, it looks like our NetBSD-current VPS has been updated to -current from 10, and then updated again after some time had passed. Now that etcupdate also has been run, the VPS still reboots and seems to run quite well. Everything I have done might be a bit rough, and there may be significant mistakes. One more thing might remain, which would be to update and rebuild everything which was installed via pkgsrc, since these packaged applications are not part of the main distribution.

    Sorry that there have been so many (too many?) posts from me about NetBSD. Maybe I have ruined the BSD thread for our OpenBSD and FreeBSD fans who no longer seem active.

    One thing I love about NetBSD is that, as complicated as NetBSD is, nevertheless, there's a chance for an ordinary person to look under the hood and tinker around. Lifting the hood also is possible with all other open source OSes, but the BSDs seem relatively more simple, relatively more basic, and relatively faster in some ways, sometimes, compared to some other OSes. It's great that @Linveo includes all the major BSDs in Linveo's VPS installer! <3

    I hope everyone gets the servers they want!

Sign In or Register to comment.