# File: /u/kscott/www/sysadmin/tools.notes # Author: K. Scott Rowe # Time-stamp: <02/01/2000 00:48:50 kscott@bendenweir.nmt.edu> why not create a script called test? /bin/test why use comments? someone else may have to change your scripts you may not know what you meant 6 months from now how do rc startup scripts work? init is the first process run. It runs the appropriate rc scripts (Single, Multi, 0, 1, 2, 3, ...) BSD usually only has two runlevels, Single and Multi user Slackware-Linux init calls inittab (Slackware-Linux) inittab calls rc.S (Slackware-Linux) This first rc file, does things like fsck, mount, swapon Then rc.M is run for all multi-user runlevels (2345) SunOS 4.x init calls rc.boot (SunOS) This first rc file, does things like fsck, mount, swapon Then either rc.single or rc.local is called SYSV usually has 8 0-6 and S init calls inittab inittab calls rc.sysinit (RedHat-Linux) or rcS (Solaris) This first rc file, does things like fsck, mount, swapon Then the run levels are run sequentially (rc0, rc1, rc2, rc3 (solaris)) (rc 0, rc 1, ... (redhat)) if [ -d /etc/rc0.d ]; then for f in /etc/rc0.d/K*; do if [ -s $f ]; then case $f in *.sh) . $f ;; *) /sbin/sh $f stop ;; esac fi done # System cleanup functions ONLY (things that end fast!) for f in /etc/rc0.d/S*; do if [ -s $f ]; then case $f in *.sh) . $f ;; *) /sbin/sh $f start ;; esac fi done fi #!/bin/sh # #Select a unique UID to assign a new user. UID's selected are always >= 100 # sort -t: +2n -3 "$1" | awk -F: 'BEGIN { u = 100; } $3 == u { u++; next; } $3 > u { print u; exit; } { next; }'; # # or ... # x=100 while [ $x -lt 65535 ] ; do grep "^[^:]*:[^:]*:$x:.*$" /etc/passwd > /dev/null 2>&1 if [ "$?" = "1" ] ; then echo "$x" exit fi x=`expr ${x} + 1` done echo "drat, ran out of numbers"