This repository has been archived on 2022-02-20. You can view files and clone it, but cannot push or open issues/pull-requests.
2020-11-03 12:07:49 -08:00
|
|
|
#!/bin/bash
|
|
|
|
function logit(){
|
|
|
|
local SCRIPT_PATH
|
|
|
|
local LOG_PATH
|
|
|
|
local SCRIPT_DIR
|
|
|
|
local SCRIPT_NAME
|
|
|
|
|
|
|
|
tty -s
|
|
|
|
if [ "0" != "$?" ] || [ $1 == f ]; then
|
|
|
|
SCRIPT_PATH=$(readlink -f "$0")
|
|
|
|
SCRIPT_DIR=$(dirname $SCRIPT_PATH)
|
|
|
|
SCRIPT_NAME=$(basename ${SCRIPT_PATH%.*})
|
|
|
|
mkdir -p $SCRIPT_DIR/logs
|
|
|
|
# log is the /logs subdirectory of original script directory
|
|
|
|
LOG_PATH="$SCRIPT_DIR/logs/$SCRIPT_NAME.log"
|
|
|
|
exec 1> $LOG_PATH 2>&1
|
|
|
|
echo $(date) logging for $SCRIPT_PATH
|
|
|
|
fi
|
|
|
|
}
|
2020-11-10 14:09:08 -08:00
|
|
|
|
|
|
|
#
|
|
|
|
# LOG_DIR=/opt/bash/logs
|
|
|
|
# mkdir -p $LOG_DIR
|
|
|
|
# LOG_FILE=$LOG_DIR/bash_profile
|
|
|
|
#
|
|
|
|
# msg="$(date) \n Login for $USER \n $(env | grep BASH)"
|
|
|
|
# [[ $- == *i* ]] && echo -e $msg || echo -e $msg 1> $LOG_FILE 2>&1
|
|
|
|
#
|
|
|
|
#
|