Compare commits
No commits in common. "515c77bed429225dc45402202af0ac45e6a64067" and "33511a5bcb37d084a826e5c5f6284445d4cae26a" have entirely different histories.
515c77bed4
...
33511a5bcb
28
git_helpers
28
git_helpers
@ -90,10 +90,12 @@ clone_customer_repository () {
|
|||||||
log_debug "$func:${LINENO} cloning ${1} ..."
|
log_debug "$func:${LINENO} cloning ${1} ..."
|
||||||
if cd "./$WORKSPACE_DIR"
|
if cd "./$WORKSPACE_DIR"
|
||||||
then
|
then
|
||||||
exec_git_command git clone "$1"
|
$(exec_git_command git clone "$1")
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
log_debug "$func:${LINENO} cloning ${1} done"
|
log_debug "$func:${LINENO} cloning ${1} done"
|
||||||
GIT_CLONE_EXECUTED=1
|
GIT_CLONE_EXECUTED=1
|
||||||
|
rm -f $GIT_PULL_TMP
|
||||||
|
rm -f $OPKG_CMDS_TMP
|
||||||
# after cloning, cd into repository, and re-initialize,
|
# after cloning, cd into repository, and re-initialize,
|
||||||
# setting the work-tree as "/". This has the effect that
|
# setting the work-tree as "/". This has the effect that
|
||||||
# a "git pull" will automatically fetched files in the
|
# a "git pull" will automatically fetched files in the
|
||||||
@ -180,20 +182,26 @@ pull_customer_repository () {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_crit "$func:${LINENO}: executing 'git pull'..."
|
#local commit_before_pull=$(latest_commit)
|
||||||
|
#if [ -z $commit_before_pull ]; then
|
||||||
|
# log_warn "$func:${LINENO}: commit_before_pull empty"
|
||||||
|
# cd_home ; return 1
|
||||||
|
#fi
|
||||||
|
#log_debug "$func:${LINENO}: commit_before_pull=$commit_before_pull"
|
||||||
|
|
||||||
|
rm -f "$OPKG_CMDS_TMP"
|
||||||
|
rm -f "$GIT_PULL_TMP"
|
||||||
|
|
||||||
|
log_debug "$func:${LINENO}: executing 'git pull'..."
|
||||||
exec_git_command 'git pull'
|
exec_git_command 'git pull'
|
||||||
|
|
||||||
# GIT_UPDATE_LOG updated by hook post-merge. it contains the names of the
|
# GIT_PULL_TMP created by hook post-merge. it contains the names of the
|
||||||
# changed files or opkg-commands to execute.
|
# changed files.
|
||||||
# If 'git pull' has fetched new data, then there are lines starting with
|
if [[ -f $GIT_PULL_TMP ]]; then
|
||||||
# DOWNLOAD or EXECUTE.
|
|
||||||
grep -E -q "^[[:space:]]*(DOWNLOAD|EXECUTE)" "$GIT_UPDATE_LOG"
|
|
||||||
if [ $? -eq 0]; then
|
|
||||||
log_info "$func:${LINENO}: new data fetched from repository"
|
|
||||||
cd_home; return 0
|
cd_home; return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_warn "$func:${LINENO}: no data fetched from repository"
|
log_warn "$func:${LINENO}: no data fetched form repository"
|
||||||
cd_home; return 1
|
cd_home; return 1
|
||||||
}
|
}
|
||||||
# pull_customer_repository customer_281
|
# pull_customer_repository customer_281
|
||||||
|
31
log_helpers
31
log_helpers
@ -1,6 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# set -x
|
# set -x
|
||||||
|
|
||||||
|
RED='\e[0;31m'
|
||||||
|
GREEN='\e[0;32m'
|
||||||
|
NC='\e[0m' # No Color
|
||||||
|
|
||||||
if [ "${log_helpers_sourced:-1}" = "1" ]; then # include only once
|
if [ "${log_helpers_sourced:-1}" = "1" ]; then # include only once
|
||||||
readonly log_helpers_sourced=${BASH_SOURCE[0]}
|
readonly log_helpers_sourced=${BASH_SOURCE[0]}
|
||||||
|
|
||||||
@ -29,60 +33,51 @@ if [ "${log_helpers_sourced:-1}" = "1" ]; then # include only once
|
|||||||
return $log_level
|
return $log_level
|
||||||
}
|
}
|
||||||
|
|
||||||
log_to_file() {
|
log() {
|
||||||
|
# TODO: kann man wohl entfernen
|
||||||
if [[ $(("$(wc -l < $log_file)")) -ge $((100000)) ]]; then
|
if [[ $(("$(wc -l < $log_file)")) -ge $((100000)) ]]; then
|
||||||
# remove first line
|
# remove first line
|
||||||
sed -e 1d -i $log_file
|
sed -e 1d -i $log_file
|
||||||
fi
|
fi
|
||||||
local msg="$(date +'%Y-%m-%d_%T'): $*"
|
local msg="$(date +'%Y-%m-%d_%T'): $*"
|
||||||
|
echo "log:$msg" >&2
|
||||||
echo "$msg" >> $log_file
|
echo "$msg" >> $log_file
|
||||||
}
|
}
|
||||||
|
|
||||||
log() {
|
|
||||||
local msg="$(date +'%Y-%m-%d_%T'): $*"
|
|
||||||
echo "log:$msg" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
log_debug() {
|
log_debug() {
|
||||||
log_to_file "DEBUG $*"
|
|
||||||
if [ $log_level -le $DEBUG ]; then
|
if [ $log_level -le $DEBUG ]; then
|
||||||
log "DEBUG $*"
|
log "DEBUG $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
log_info() {
|
log_info() {
|
||||||
log_to_file "INFO $*"
|
|
||||||
if [ $log_level -le $INFO ]; then
|
if [ $log_level -le $INFO ]; then
|
||||||
log "INFO $*"
|
log "${GREEN}INFO $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
log_warn() {
|
log_warn() {
|
||||||
log_to_file "WARN $*"
|
|
||||||
if [ $log_level -le $WARN ]; then
|
if [ $log_level -le $WARN ]; then
|
||||||
log "WARN $*"
|
log "${RED}WARN $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
log_crit() {
|
log_crit() {
|
||||||
log_to_file "CRIT $*"
|
|
||||||
if [ $log_level -le $CRIT ]; then
|
if [ $log_level -le $CRIT ]; then
|
||||||
log "CRIT $*"
|
log "${RED}CRIT $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
log_error() {
|
log_error() {
|
||||||
log_to_file "ERROR $*"
|
|
||||||
if [ $log_level -le $ERROR ]; then
|
if [ $log_level -le $ERROR ]; then
|
||||||
log "ERROR $*"
|
log "${RED}ERROR $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
log_fatal() {
|
log_fatal() {
|
||||||
log_to_file "FATAL $*"
|
|
||||||
if [ $log_level -le $FATAL ]; then
|
if [ $log_level -le $FATAL ]; then
|
||||||
log "FATAL $*"
|
log "${RED}FATAL $*"
|
||||||
log "exiting ..."
|
log "${RED}exiting ..."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,8 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
|||||||
readonly UPDATEPSABEGIN=./.updatepsa/begin
|
readonly UPDATEPSABEGIN=./.updatepsa/begin
|
||||||
readonly UPDATEPSAEND=./.updatepsa/end
|
readonly UPDATEPSAEND=./.updatepsa/end
|
||||||
|
|
||||||
# name of file containing the logs following a 'git pull':
|
readonly OPKG_CMDS_TMP=/tmp/opkg_commands
|
||||||
# basically, there are two kinds of entries:
|
readonly GIT_PULL_TMP=/tmp/git_pull
|
||||||
readonly GIT_UPDATE_LOG=/opt/app/tools/atbupdate/update_log.csv
|
|
||||||
|
|
||||||
readonly PROGRAM=`basename $0`
|
readonly PROGRAM=`basename $0`
|
||||||
readonly WORKSPACE_DIR=workspace
|
readonly WORKSPACE_DIR=workspace
|
||||||
|
Loading…
x
Reference in New Issue
Block a user