Update of /cvsroot/leaf/src/The_UnNamed_One/apps/root/skel
In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv15949/apps/root/skel

Added Files:
        edit getservbyname mail profile root.dev.mod root.dev.own 
        savelog svi ticker update-rc.d 
Log Message:
initial import


--- NEW FILE: profile ---
# ~/.profile: executed for shells.

export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
#Set the prompt
export PS1="$HOSTNAME# " 

umask 022

RPW=`grep root /etc/shadow | sed 's/root://' | sed 's/:.*//'`
if test -z $RPW; then passwd; fi

#Uncomment to run at login
/usr/sbin/lrcfg

--- NEW FILE: svi ---
#!/bin/sh

prog=${0##*/}

[ "$1" = "" ] && echo "Usage: $prog file" && exit 1
[ ! -f "/etc/init.d/$1" ] && echo "$1: No such file or directory" && exit 1

/etc/init.d/$@

--- NEW FILE: update-rc.d ---
#!/bin/sh
#
#GPL2 -- Dave Cinege <[EMAIL PROTECTED]>
#

qt () { "$@" >/dev/null 2>&1 ; }

OIFS=$IFS


usage () {
        echo "Usage: $(basename $0) [-f] [-a[-w]] <basename>"
        echo "  -f: force       Force. ALL current links of <basename> are 
deleted."
        echo "  -a: all         Process all files in /etc/init.d/. <basename> 
ignored."
        echo "  -w: wipe        Wipe /etc/rc?.d/ directories (implies -f)"
        echo "  -v: verbose     Be extra verbose."
        echo ""
        echo "This program uses 'RCDLINKS=' found in the /etc/init.d/ files."
        echo "Comment out 'RCDLINKS=' if you want a file to be ignored."
}

while getopts fawv opt ; do
        case "$opt" in
                f) rcdforce="yes" ;;
                a) rcdall="yes" ;;
                w) rcdwipe="yes"  ;;
                v) rcdvb="yes"  ;;
        esac
done

shift $(($OPTIND - 1))
        
if [ "$rcdall" = "yes" ]; then
        if [ "$rcdwipe" = "yes" ]; then
                for d in /etc/rc?.d; do
                        [ ! -d "$d" ] && continue
                        qt rm $d/[KS][0-9][0-9]*
                done
        fi
        F=/etc/init.d/*
else
        [ "$1" = "" ] && usage && exit 1        
        F=/etc/init.d/$1
                
        if [ ! -x "$F" ]; then
                echo "$F does not exist or is not executable."
                exit 1
        fi
fi

for f in $F; do
                
        [ ! -x "$f" ] && continue
                                
        eval RCDLINKS=$(sed -n '1,/^RCDLINKS=/s/^RCDLINKS=\(.*\)/\1/p' $f 
2>/dev/null)
        
        if [ "$RCDLINKS" != "" ]; then
                bf="$(basename $f)"
                                
                qt ls /etc/rc?.d/[KS][0-9][0-9]$bf
                if [ $? -eq 0 ]; then
                        if [ "$rcdforce" = "yes" ]; then
                                qt rm /etc/rc?.d/[KS][0-9][0-9]$bf
                        else
                                echo "System startup links for $f already 
exist."
                                continue
                        fi
                fi
                                
                for l in $RCDLINKS; do
                        IFS=','; set -- $l; IFS=$OIFS
                        [ ! -d "/etc/rc$1.d" ] && continue      # Ignore bad 
dirs.
                        [ "$rcdvb" ] && echo "RCDLINKS=$RCDLINKS - $f"
                        ln -sf "../init.d/$bf" "/etc/rc$1.d/$2$bf" 2>/dev/null
                done
        else
                [ "$rcdvb" ] && echo "'^RCDLINKS=' not found in $f. File 
ignored."
        fi
done

--- NEW FILE: root.dev.own ---

cd /dev/

#Default
chown -R root.root * >null 2>&1

chown root.tty tty* >null 2>&1
chown root.tty console >null 2>&1
chown root.root tty >null 2>&1
chown root.dialout ttyS* >null 2>&1

chown root.disk hd* >null 2>&1
chown root.disk sd* >null 2>&1
chown root.disk scd* >null 2>&1
chown root.disk ram* >null 2>&1
chown root.disk loop* >null 2>&1
chown root.disk initrd >null 2>&1

chown root.floppy fd* >null 2>&1

chown root.kmem mem >null 2>&1
chown root.kmem kmem >null 2>&1
chown root.kmem port >null 2>&1

cd /

--- NEW FILE: edit ---
#!/bin/sh

# Launch the desired editor:
eval ${EDITOR:-/bin/e3ne} "$@"

--- NEW FILE: savelog ---
#! /bin/sh
# savelog - save a log file
#    Copyright (C) 1987, 1988 Ronald S. Karr and Landon Curt Noll
#    Copyright (C) 1992  Ronald S. Karr
# Slight modifications by Ian A. Murdock <[EMAIL PROTECTED]>:
#       * uses `gzip' rather than `compress'
#       * doesn't use $savedir; keeps saved log files in the same directory
#       * reports successful rotation of log files
#       * for the sake of consistency, files are rotated even if they are
#         empty
# More modifications by Guy Maor <[EMAIL PROTECTED]>:
#       * cleanup.
#       * -p (preserve) option
# 
# usage: savelog [-m mode] [-u user] [-g group] [-t] [-p] [-c cycle] [-l]
#                file...
#       -m mode   - chmod log files to mode
#       -u user   - chown log files to user
#       -g group  - chgrp log files to group
#       -c cycle  - save cycle versions of the logfile  (default: 7)
#       -t        - touch file
#       -l        - don't compress any log files        (default: compress)
#       -p        - preserve mode/user/group of original file
#       file      - log file names
#
# The savelog command saves and optionally compresses old copies of files.
# Older version of 'file' are named:
#
#               'file'.<number><compress_suffix>
#
# where <number> is the version number, 0 being the newest.  By default,
# version numbers > 0 are compressed (unless -l prevents it). The
# version number 0 is never compressed on the off chance that a process
# still has 'file' opened for I/O.
#
# If the 'file' does not exist and -t was given, it will be created.
#
# For files that do exist and have lengths greater than zero, the following 
# actions are performed.
#
#       1) Version numered files are cycled.  That is version 6 is moved to
#          version 7, version is moved to becomes version 6, ... and finally
#          version 0 is moved to version 1.  Both compressed names and
#          uncompressed names are cycled, regardless of -t.  Missing version 
#          files are ignored.
#
#       2) The new file.1 is compressed and is changed subject to 
#          the -m, -u and -g flags.  This step is skipped if the -t flag 
#          was given.
#
#       3) The main file is moved to file.0.
#
#       4) If the -m, -u, -g, -t, or -p flags are given, then the file is
#          touched into existence subject to the given flags.  The -p flag
#          will preserve the original owner, group, and permissions.
#
#       5) The new file.0 is changed subject to the -m, -u and -g flags.
#
# Note: If no -m, -u, -g, -t, or -p is given, then the primary log file is 
#       not created.
#
# Note: Since the version numbers start with 0, version number <cycle>
#       is never formed.  The <cycle> count must be at least 2.
#
# Bugs: If a process is still writing to the file.0 and savelog
#       moved it to file.1 and compresses it, data could be lost.
#       Smail does not have this problem in general because it
#       restats files often.

# common location
export PATH=$PATH:/sbin:/bin:/usr/sbin:/usr/bin
COMPRESS="gzip"
DOT_Z=".gz"

# parse args
exitcode=0      # no problems to far
prog=`basename $0`
mode=
user=
group=
touch=
preserve=
count=7

usage()
{
    echo "Usage: $prog [-m mode][-u user][-g group][-t][-c cycle][-l][-p] file 
..."
}


fixfile()
{
    if [ -n "$user" ]; then
        chown "$user" "$1"
    fi
    if [ -n "$group" ]; then 
        chgrp "$group" "$1"
    fi
    if [ -n "$mode" ]; then 
        chmod "$mode" "$1"
    fi
}


while getopts m:u:g:c:ltph opt ; do
        case "$opt" in
        m) mode="$OPTARG" ;;
        u) user="$OPTARG" ;;
        g) group="$OPTARG" ;;
        c) count="$OPTARG" ;;
        t) touch=1 ;;
        l) COMPRESS="" ;;
        p) preserve=1 ;;
        h) usage; exit 0 ;;
        *) usage; exit 1 ;;
        esac
done

shift $(($OPTIND - 1))

if [ "$count" -lt 2 ]; then
        echo "$prog: count must be at least 2" 1>&2
        exit 2
fi

# cycle thru filenames
while [ $# -gt 0 ]; do

        # get the filename
        filename="$1"
        shift

        # catch bogus files
        if [ -e "$filename" -a ! -f "$filename" ]; then
                echo "$prog: $filename is not a regular file" 1>&2
                exitcode=3
                continue
        fi

        # if not a file or empty, do nothing major
        # (in the Debian version, we rotate even if empty)
        #if [ ! -s $filename ]; then
                # if -t was given and it does not exist, create it
                if [ -n "$touch" -a ! -f "$filename" ]; then 
                        touch "$filename"
                        if [ "$?" -ne 0 ]; then
                                echo "$prog: could not touch $filename" 1>&2
                                exitcode=4
                                continue
                        fi
                        fixfile "$filename"
                fi
        #       continue
        #fi

        # be sure that the savedir exists and is writable
        # (in the Debian version, $savedir is . and not ./OLD)
        savedir=`dirname "$filename"`
        if [ -z "$savedir" ]; then
                savedir=.
        fi
        if [ ! -d "$savedir" ]; then
                mkdir "$savedir"
                if [ "$?" -ne 0 ]; then
                        echo "$prog: could not mkdir $savedir" 1>&2
                        exitcode=5
                        continue
                fi
                chmod 0755 "$savedir"
        fi
        if [ ! -w "$savedir" ]; then
                echo "$prog: directory $savedir is not writable" 1>&2
                exitcode=7
                continue
        fi
 
        # determine our uncompressed file names
        newname=`basename "$filename"`
        newname="$savedir/$newname"

        # cycle the old compressed log files
        cycle=$(( $count - 1))
        rm -f "$newname.$cycle" "$newname.$cycle$DOT_Z"
        while [ $cycle -gt 1 ]; do
                # --cycle
                oldcycle=$cycle
                cycle=$(( $cycle - 1 ))
                # cycle log
                if [ -f "$newname.$cycle$DOT_Z" ]; then
                        mv -f "$newname.$cycle$DOT_Z" \
                            "$newname.$oldcycle$DOT_Z"
                fi
                if [ -f "$newname.$cycle" ]; then
                        # file was not compressed. move it anyway
                        mv -f "$newname.$cycle" "$newname.$oldcycle"
                fi
        done

        # compress the old uncompressed log if needed
        if [ -f "$newname.0" ]; then
                if [ -z "$COMPRESS" ]; then
                        newfile="$newname.1"
                        mv "$newname.0" "$newfile"
                else
                        newfile="$newname.1$DOT_Z"
                        $COMPRESS < $newname.0 - > $newfile
                        rm -f $newname.0
#                       $COMPRESS "$newname.0"
#                       mv "$newname.0$DOT_Z" "$newfile"
                fi
                fixfile "$newfile"
        fi

        # create new file if needed
        if [ -n "$preserve" ]; then
                cp -p "$filename" "$filename.new"
                echo -n > "$filename.new"
                filenew=1
        elif [ -n "$touch$user$group$mode" ]; then
                touch "$filename.new"
                fixfile "$filename.new"
                filenew=1
        fi

        # link the file into the file.0 holding place
        if [ -f "$filename" ]; then
                if [ -n "$filenew" ]; then
                        ln -f "$filename" "$newname.0"
                        mv "$filename.new" "$filename"
                else
                        mv "$filename" "$newname.0"
                fi
        fi
        [ ! -f "$newname.0" ] && touch "$newname.0"
        fixfile "$newname.0"

        # report successful rotation
        echo "Rotated \`$filename' at `date`."
done
exit $exitcode

--- NEW FILE: mail ---
#!/bin/sh
#
#GPL2 -- Dave Cinege <[EMAIL PROTECTED]>
#

qt () { "$@" >/dev/null 2>&1 ; }
eecho () { echo "$@" >/dev/null >&2 ; }
prog=${0##*/}

OIFS=$IFS
CR='
'
LF='
'

MASTCONF="/etc/POSIXness.conf"
[ -f "$MASTCONF" ] && . $MASTCONF


  usage () { 
        echo "Usage: $(basename $0) options to[,...]"
        echo "Options: [-s subject] [-c cc[,...]] [-b bcc[,...]]"
        echo "         [-a attachment[,...]] [-d domain] [-h smptserver]"
        echo ""
        echo "Mail settings are in $MASTCONF"
        echo "-a attach text file(s)"
        echo "-d specify from FQDN, overriding local domain"
        echo "-h specify SMTP server, overriding the MAIL_SERVER setting"
        echo "-v verbose"
  }

  echocr () { echo "$@""$CR"; }

  log () {
        logger -p mail.notice -t "$prog[$$]" "$user => [$envelopes]: $subject"
  }

  rfcdate () {
        local IFS=" "
        set -- `date -R`
        case "$#" in
        6)
                echo "$@"
                ;;
        1)
                set -- `date`
                [ "$#" -eq 5 ] && echo "$1, $3 $2 $5 $4 +0000"
                ;;
        *)
                ;;
        esac
  }

  attach () {
        if [ -f "$1" ] ; then
                name=`basename $1`
                
                echocr "--$ContentBoundry"
                echocr "Content-Type: text/plain; charset=us-ascii"
                echocr " name=\"$name\""
                echocr "Content-Transfer-Encoding: 7bit"
                
                if [ -n "$MAIL_ATTINLINE" ] ; then
                        echocr "Content-Disposition: inline;"
                else
                        echocr "Content-Disposition: attachment;"
                fi

                echocr " filename=\"$name\""
                echocr ""
                sed 's/^\./\.\./;s/$/'"$CR"'/' "$1"
        fi
  }

  body () {

        [ -n "$att" ] && {
                echocr "This is a multi-part message in MIME format."
                echocr "--$ContentBoundry"
                echocr "Content-Type: text/plain; charset=us-ascii"
                echocr "Content-Transfer-Encoding: 7bit"
                echocr ""
        }
        
        sed 's/^\./\.\./;s/$/'"$CR"'/' "$fbody"
  }
  
  abort () {
        eecho "Aborting due to $1"
        eecho "  Killing child processes: $pidctrl $pidnc"
        qt kill $pidctrl
        qt kill $pidnc
        exit 1
  }

  ctrl () {

    exit1 () { 
        eecho "Error: Unknown response." 
        eecho "  $lastline"
        eecho "  $state: $nrep $vrep"
        kill -12 $$
        exit 1 
    }

    getresponse () {
        read nrep vrep
        # Skip over multi-line responses
        while : ; do 
                case $nrep in
                ???-*)  read nrep vrep  ;;
                *)      break           ;;
                esac
        done
        x=${nrep%${nrep#?}}
    }

        local wait=yes
        trap "unset wait" 10

        kill -10 $$     # local trap setup...unblock main thread

        # Wait for main thread to setup nc process
        while [ "$wait" = "yes" ] ; do sleep 1; done

        exec 3<$prx

        getresponse <&3

        state=0
        sentbody=no

        IFS=$LF
#       for line in `cat $fdata` ; do
        while read line ; do

                IFS=$OIFS
                # Send heartbeat signal...prevents timout while active
                kill -10 $$     
                lastline=$line

                case $x in
                "2")
                        echo "$line$CR"
                        [ $state -eq 4 ] && [ "$line" != "DATA" ] && 
                                state=$(($state - 1))
                        [ $state -ne 6 ] && state=$(($state + 1))
                        ;;
                "3")
                        [ $state -ne 5 -a $state -ne 6 ] && exit1
                        [ $state -eq 5 ] && state=$(($state + 1))
                        if [ "$line" = "." ] ; then
                                if [ "$sentbody" != "yes" ] ; then
                                        body
                                        kill -10 $$
                                        IFS=","
                                        for file in $att; do
                                                attach $file
                                                kill -10 $$
                                        done
                                        IFS=$OIFS
                                        sentbody=yes
                                else
                                        echo "$line$CR"
                                        state=$(($state + 1))
                                fi
                        else    
                                echo "$line$CR"
                        fi
                        ;;
                *)
                        exit1
                        ;;
                esac

                [ $state -ne 6 ] && getresponse <&3
                [ "$verbose" ] && eecho "$state: $nrep $line"
        done <$fdata
        log
        exit 0
  } 

# mail main ()
        TIMEOUT=60

        ContentBoundry="$$--`date +%s`"

        ptx="/tmp/smtp.tx.$$"
        prx="/tmp/smtp.rx.$$"
        fdata="/tmp/smtp.data.$$"
        fbody="/tmp/smtp.body.$$"

        [ -e $prx ]   && eecho "Bad in file"   && exit 1
        [ -e $ptx ]   && eecho "Bad out file"  && exit 1
        [ -e $fdata ] && eecho "Bad temp file" && exit 1
        [ -e $fbody ] && eecho "Bad temp file" && exit 1

        mknod $ptx p; mknod $prx p; : > $fdata; : > $fbody
        chmod 600 $ptx $prx $fdata $fbody

        fqdn=${MAIL_DOMAIN:-`hostname -f`}
        user=${USER:-$LOGNAME}
        #if mail is started from init set user to root
        user=${user:-root}
        smtpserv=${MAIL_SERVER:-mail}

        while getopts va:b:c:d:h:s: opt ; do
                case "$opt" in
                        a) att="$OPTARG" ;;
                        b) bcc="$OPTARG" ;;
                        c) cc="$OPTARG"  ;;
                        d) fqdn="$OPTARG"  ;;
                        h) smtpserv="$OPTARG"  ;;
                        s) subject="$OPTARG"  ;;
                        v) verbose=1    ;;
                esac
        done

        shift $(($OPTIND - 1))

        [ $# -lt 1 ] && usage && exit 1

        while read line; do
                echo "$line"
        done >$fbody
        
        to="$@"

        IFS=","

        allto="$to,$cc,$bcc"
        envelopes="$(   for str in $allto; do
                echo $str
        done | sed 's/^.*[< ]\(.*\)$/\1/;s/>$//' )"

        IFS=$OIFS

        {       echo "RSET" 
                echo "HELO $fqdn"
                echo "MAIL FROM:<[EMAIL PROTECTED]>"
                        
                for rcpt in $envelopes; do
                        echo "RCPT TO:<$rcpt>"
                done    
        
                echo "DATA"

                date=`rfcdate`
                [ -n "$date" ] && echo "Date: $date"
                echo "From: [EMAIL PROTECTED]"
                echo "Subject: $subject"
                [ -n "$to" ] && echo "To: $to"
                [ -n "$cc" ] && echo "cc: $cc"
                [ -n "$bcc" ] && echo "Bcc: "
                echo "X-Mailer: POSIXness Mail"
                [ -n "$att" ] && {
                        echo "MIME-Version: 1.0"
                        echo "Content-Type: multipart/mixed; 
boundary=\"$ContentBoundry\""
                }

                echo ""         # Blank line between header and body
                
                echo "."        # Tag to insert body
                
                [ -n "$att" ] && echo "--$ContentBoundry--"
                
                echo ""         # CRLF
                echo "."        # End DATA
                echo "QUIT"
  
        } >$fdata

        # Heartbeat signal from ctrl process
        trap "count=0" 10       

        # Abort signal from ctrl process
        trap "abort \"connection error\"" 12

        # Remove files on exit
        trap "qt rm -f $ptx $prx $fdata $fbody" 0

        # Trap software aborts & kill child processes
        trap "abort \"software signal\"" 1 2 6 9 15
        trap "" 18 19 20
        trap ":" 17

        count=1
        ctrl > $ptx &
        pidctrl=$!
        [ "$verbose" ] && eecho "pidctrl: $pidctrl"

        nc $smtpserv $(getservbyname smtp) < $ptx > $prx &
        pidnc=$!
        [ "$verbose" ] && eecho "pidnc: $pidnc"

        while [ "$count" -ne 0 ] ; do sleep 1; done
        kill -10 $pidctrl

        count=0
        while [ -e "/proc/$pidctrl" -o -e "/proc/$pidnc" ] ; do
                sleep 1
                count=$(($count + 1))
                [ $count -gt $TIMEOUT ] && abort "timeout"
        done

        exit 0

--- NEW FILE: ticker ---
#!/bin/sh
trap 'exit' 0 2 5 15
echo -n " "
while : ; do
        for i in \\\\ \| / - ; do
                echo -e -n "\b$i"
                sleep 1
        done
done
            
--- NEW FILE: root.dev.mod ---

cd /dev/

#Default
chmod -R 660 * >null 2>&1

chmod 622 tty* >null 2>&1
chmod 666 ttyp* >null 2>&1
chmod 666 ttyq* >null 2>&1
chmod 666 ttyr* >null 2>&1
chmod 660 ttyS* >null 2>&1
chmod 622 console >null 2>&1
chmod 666 tty >null 2>&1
chmod 600 ppp >null 2>&1

chmod 666 pty* >null 2>&1

chmod 666 null >null 2>&1
chmod 666 zero >null 2>&1

chmod 622 full >null 2>&1

chmod 644 random >null 2>&1
chmod 644 urandom >null 2>&1

chmod 666 socksys >null 2>&1
chmod 666 spx >null 2>&1

chmod 666 inet/* >null 2>&1
chmod 755 inet/ >null 2>&1

cd /

--- NEW FILE: getservbyname ---
#!/bin/sh

TAB='   '
prog=${0##*/}

[ "$1" != "" ] && serv=$1 || \
        { echo "Usage: $prog service [type]"; exit 1; }
proto=${2:-tcp}
port="$(sed -n "s/^$serv[ |$TAB]*\([0-9]*\)\/$proto.*$/\1/p" /etc/services)"
echo "${port:-0}"


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
leaf-cvs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/leaf-cvs-commits

Reply via email to