mirror of
https://github.com/DictXiong/dotfiles.git
synced 2026-11-23 20:38:16 +08:00
[dev] refactor log.py -> logger.sh (#32)
* update.sh: fetch will prune * log: use hostname directly * refactor log.py to logger.sh (#31) * logger.sh: refactor log.py to bash script * update.sh use beacon; ci test beacon * install.sh: install dep first * install.sh: DFS_UPDATED_RET=85 * more beacon; use stderr * remove py3 dep * install.sh: remove py3 * install.sh: -s|--secure * async log; beacon add sys.login * update use sync beacon * fix ci minor bug; macos: uuidgen/e2fsprogs * logger.sh: not need to use uuid5 * bug fix * dfs err_return * common.sh: post_log and post_beacon will check #args * bug fix * zshrc: fix locale when C.UTF-8 not exists * WIP: combine install -a and tools/ scripts * finish combination; get_os_name; macos.sh * test.ci: now all use -a to install deps * bug fix * bug fix; ci: install.sh run with -x * install.sh: bug fix that re-run install.sh after updated needs orgin args * format Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
This commit is contained in:
@@ -109,7 +109,7 @@ parse_arg()
|
||||
while [[ $# > 0 || -n "$ARG" ]]; do
|
||||
if [[ -z "$ARG" ]]; then ARG=$1; shift; fi
|
||||
case $ARG in
|
||||
-q*|--quite ) DFS_QUIET=1 ;;
|
||||
-q*|--quite ) export DFS_QUIET=1 ;;
|
||||
--* ) PARSE_ARG_RET+=("$ARG") ;;
|
||||
-* ) PARSE_ARG_RET+=("${ARG:0:2}") ;;
|
||||
* ) PARSE_ARG_RET+=("$ARG") ;;
|
||||
@@ -148,10 +148,32 @@ ask_for_Yn()
|
||||
|
||||
post_log()
|
||||
{
|
||||
python3 "${DOTFILES}/tools/log.py" "[$1] $2: $3"
|
||||
if [[ $# != 3 || -z "$1" || -z "$2" || -z "$3" ]]; then
|
||||
fmt_fatal "usage: post_log <level> <section> <content>"
|
||||
fi
|
||||
"${DOTFILES}/tools/logger.sh" "log" "[$1][$2] $3"
|
||||
}
|
||||
|
||||
get_os_type() {
|
||||
apost_log()
|
||||
{
|
||||
post_log "$@" 1>/dev/null &
|
||||
}
|
||||
|
||||
post_beacon()
|
||||
{
|
||||
if [[ $# != 1 || -z "$1" ]]; then
|
||||
fmt_fatal "usage: post_beacon <beacon>"
|
||||
fi
|
||||
"${DOTFILES}/tools/logger.sh" "beacon" "$1"
|
||||
}
|
||||
|
||||
apost_beacon()
|
||||
{
|
||||
post_beacon "$@" 1>/dev/null &
|
||||
}
|
||||
|
||||
get_os_type()
|
||||
{
|
||||
local ans="unknown"
|
||||
case "$(uname -s)" in
|
||||
Darwin*) ans="MacOS";;
|
||||
@@ -163,7 +185,8 @@ get_os_type() {
|
||||
echo $ans | tr '[:upper:]' '[:lower:]'
|
||||
}
|
||||
|
||||
get_linux_dist() {
|
||||
get_linux_dist()
|
||||
{
|
||||
local ans="unknown"
|
||||
if [ -f /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
@@ -185,6 +208,15 @@ get_linux_dist() {
|
||||
echo $ans | tr '[:upper:]' '[:lower:]'
|
||||
}
|
||||
|
||||
get_os_name()
|
||||
{
|
||||
local ans=$(get_os_type)
|
||||
if [[ "$ans" == "linux" ]]; then
|
||||
ans=$(get_linux_dist)
|
||||
fi
|
||||
echo $ans
|
||||
}
|
||||
|
||||
# if bash-ed, else source-d
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
$1 "${@:2}"
|
||||
|
||||
Reference in New Issue
Block a user