57 lines
1.4 KiB
Bash
57 lines
1.4 KiB
Bash
#!/bin/bash
|
|
|
|
. /etc/profile
|
|
|
|
# export all functions
|
|
set -a
|
|
|
|
|
|
## Include functions
|
|
for bashfunc in $(find /etc/bash/gaboshlib -type f -name "g_*.bashfunc" -o -name "g_*.sh")
|
|
do
|
|
#echo $bashfunc
|
|
. "$bashfunc"
|
|
done
|
|
##
|
|
|
|
# WGET Options
|
|
g_wget_opts="--timeout 10 --tries=2 --user-agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36'"
|
|
|
|
# if runnign directly from shell
|
|
if echo $0 | egrep -q '^-bash$|^-su$'
|
|
then
|
|
g_scriptname=bash
|
|
else
|
|
g_scriptname=$(basename $0)
|
|
fi
|
|
|
|
# TMPDIR
|
|
[ -w /tmp ] && g_tmp=/tmp
|
|
df -h /tmp | grep -q tmpfs && g_tmp=~/.g_tmp
|
|
[ -w /data-crypt/share/tmp ] && g_tmp=/data-crypt/share/tmp
|
|
g_tmp="$g_tmp/g_$g_scriptname-$$"
|
|
[ -d "$g_tmp" ] || mkdir -p "$g_tmp"
|
|
|
|
# START and EXIT Notification
|
|
g_trap_exit="g_logger EXITING $g_scriptname ; rm -r $g_tmp ; g_kill_all_background_jobs >/dev/null 2>&1"
|
|
trap "$g_trap_exit" INT TERM EXIT
|
|
g_syslogtag="g_bash-script:$g_scriptname[$$]"
|
|
[ $g_scriptname = "bash" ] || g_logger STARTING $g_scriptname
|
|
|
|
|
|
# red STDERR output
|
|
exec 9>&2
|
|
exec 8> >(
|
|
while IFS='' read -r line || [ -n "$line" ]; do
|
|
echo -e "\033[31m${line}\033[0m"
|
|
done
|
|
)
|
|
function undirect(){ exec 2>&9; }
|
|
function redirect(){ exec 2>&8; }
|
|
trap "redirect;" DEBUG
|
|
PROMPT_COMMAND='undirect;'
|
|
|
|
# LANG for "." as decimal separator (and not e.g. in German ",")
|
|
export LC_NUMERIC=C
|
|
export LANG=en_US.UTF-8
|