[2] | 1 | #! /bin/sh |
---|
| 2 | #+ |
---|
| 3 | # |
---|
[82] | 4 | # .. _dlogd.sh: |
---|
| 5 | # |
---|
[72] | 6 | # ======== |
---|
| 7 | # dlogd.sh |
---|
| 8 | # ======== |
---|
[2] | 9 | # |
---|
[85] | 10 | # ---------------------------------------------------------------------------------------------------------- |
---|
| 11 | # prompt for destruction of the most recent release of :file:`${IRCAAM_LOG}/{action}.log.{YYYYMMDDTHHMMSSZ}` |
---|
| 12 | # ---------------------------------------------------------------------------------------------------------- |
---|
[2] | 13 | # |
---|
| 14 | # SYNOPSIS |
---|
| 15 | # ======== |
---|
| 16 | # |
---|
| 17 | # :: |
---|
| 18 | # |
---|
| 19 | # $ dlogd.sh action |
---|
| 20 | # |
---|
| 21 | # DESCRIPTION |
---|
| 22 | # =========== |
---|
| 23 | # |
---|
[85] | 24 | # ``dlogd.sh`` prompt for destruction of the most recent release of :file:`${IRCAAM_LOG}/{action}.log.{YYYYMMDDTHHMMSSZ}`. |
---|
[2] | 25 | # |
---|
[12] | 26 | # |
---|
[2] | 27 | # SEE ALSO |
---|
| 28 | # ======== |
---|
| 29 | # |
---|
[82] | 30 | # :ref:`ircaam_profile.sh` |
---|
[12] | 31 | # |
---|
[82] | 32 | # :ref:`elogd.sh` |
---|
[12] | 33 | # |
---|
[82] | 34 | # :ref:`plogd.sh` |
---|
[12] | 35 | # |
---|
[82] | 36 | # :ref:`tlogd.sh` |
---|
[12] | 37 | # |
---|
[2] | 38 | # EVOLUTIONS |
---|
| 39 | # ========== |
---|
| 40 | # |
---|
| 41 | # $Id$ |
---|
| 42 | # |
---|
[69] | 43 | # - fplod 20100226T151441Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 44 | # |
---|
| 45 | # * replace ????-??-??T??:??:??Z by ????????T??????Z |
---|
| 46 | # |
---|
[2] | 47 | # - fplod 2006-02-20T16:44:33Z aedon.lodyc.jussieu.fr (Darwin) |
---|
| 48 | # |
---|
| 49 | # * posix |
---|
| 50 | # |
---|
| 51 | #- |
---|
| 52 | # |
---|
| 53 | set -u |
---|
| 54 | system=$(uname) |
---|
| 55 | case "${system}" in |
---|
[77] | 56 | AIX|IRIX64) |
---|
| 57 | echo " www : no specific posix checking" |
---|
| 58 | ;; |
---|
| 59 | *) |
---|
| 60 | set -o posix |
---|
| 61 | ;; |
---|
[2] | 62 | esac |
---|
[75] | 63 | unset system |
---|
[60] | 64 | # |
---|
| 65 | LANG=POSIX |
---|
| 66 | # |
---|
[2] | 67 | command=$(basename ${0}) |
---|
| 68 | # |
---|
| 69 | if [ "${1}" = "" ] |
---|
| 70 | then |
---|
| 71 | echo "${command} : eee : 1st parameter missing" >&2 |
---|
| 72 | exit 1 |
---|
| 73 | fi |
---|
| 74 | # |
---|
| 75 | # check for ${IRCAAM_LOG} definition |
---|
| 76 | if [ "${IRCAAM_LOG}" = "" ] |
---|
[12] | 77 | then |
---|
[77] | 78 | echo " eee : \${IRCAAM_LOG} not defined" |
---|
| 79 | exit 1 |
---|
[2] | 80 | fi |
---|
| 81 | # |
---|
| 82 | # check for ${IRCAAM_LOG} existence |
---|
| 83 | if [ ! -d ${IRCAAM_LOG} ] |
---|
| 84 | then |
---|
[77] | 85 | echo " eee : ${IRCAAM_LOG} not found" |
---|
| 86 | exit 1 |
---|
[2] | 87 | fi |
---|
| 88 | # |
---|
| 89 | # check for permission access on IRCAAM_LOG |
---|
| 90 | if [ ! -x ${IRCAAM_LOG} ] |
---|
| 91 | then |
---|
[77] | 92 | echo " eee : ${IRCAAM_LOG} not reachable" |
---|
| 93 | exit 1 |
---|
[2] | 94 | fi |
---|
| 95 | # check for write permission on IRCAAM_LOG |
---|
| 96 | if [ ! -w ${IRCAAM_LOG} ] |
---|
| 97 | then |
---|
[77] | 98 | echo " eee : ${IRCAAM_LOG} not writable" |
---|
| 99 | exit 1 |
---|
[2] | 100 | fi |
---|
| 101 | # |
---|
[69] | 102 | log=$(find ${IRCAAM_LOG} -name "${1}.log.????????T??????Z" | sort | \ |
---|
[2] | 103 | tail -n 1) |
---|
| 104 | tmp=${?} |
---|
| 105 | if [ ${tmp} -eq 0 ] |
---|
| 106 | then |
---|
[77] | 107 | if [ "${log}" = "" ] |
---|
| 108 | then |
---|
| 109 | echo "${command} : eee : no release of ${IRCAAM_LOG}/${1}.log" >&2 |
---|
| 110 | exit 1 |
---|
| 111 | else |
---|
| 112 | # destruction du fichier ${log} |
---|
| 113 | /bin/rm -i ${log} |
---|
| 114 | exit 0 |
---|
| 115 | fi |
---|
[2] | 116 | else |
---|
[77] | 117 | exit 1 |
---|
[2] | 118 | fi |
---|