-
Notifications
You must be signed in to change notification settings - Fork 0
/
sandbox.sh
executable file
·65 lines (53 loc) · 1.7 KB
/
sandbox.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Got an easy progress bar function that i wrote the other day:
#!/bin/bash
# 1. Create ProgressBar function
# 1.1 Input is currentState($1) and totalState($2)
function ProgressBar {
# Process data
let _progress=(${1}*100/${2}*100)/100
let _done=(${_progress}*4)/10
let _left=40-$_done
# Build progressbar string lengths
_fill=$(printf "%${_done}s")
_empty=$(printf "%${_left}s")
# 1.2 Build progressbar strings and print the ProgressBar line
# 1.2.1 Output example:
# 1.2.1.1 Progress : [########################################] 100%
printf "\rProgress : [${_fill// /\#}${_empty// /-}] ${_progress}%%"
}
# Variables
_start=1
# This accounts as the "totalState" variable for the ProgressBar function
_end=100
# Proof of concept
for number in $(seq ${_start} ${_end})
do
echo $number
# sleep 0.1
# ProgressBar ${number} 100
done
printf '\nFinished!\n'
# ------------------------------------------------------------------------
source $(find . -name .env-telegram)
echo $TELEGRAM_BOT_TOKEN
telegram_authentication_token () {
# $1 TELEGRAM_BOT_TOKEN
# $2 TELEGRAM_CHAT_ID
if [ -z $1 ] || [ -z $2 ]; then
echo ""
echo "ERR : telegram environment is not valid, please check environment variable bellow :"
echo "----> cat .env-telegram :"
echo ""
cat $(find . -name .env-telegram)
fi
if [ -z $1 ]; then
echo "DETECT_ERR : TELEGRAM_BOT_TOKEN is EMPTY!"
return 1; exit
elif [ -z $2 ]; then
echo "DETECT_ERR : TELEGRAM_CHAT_ID is EMPTY!"
return 1; exit
fi
echo ""
return 0
}
telegram_authentication_token $TELEGRAM_BOT_TOKEN $TELEGRAM_CHAT_ID > /dev/null 2>&1 ;echo $?