Compare commits
4 Commits
eaeecc926a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| c197b16eb2 | |||
| baacd46248 | |||
| 405d7da754 | |||
| c316104d94 |
@@ -29,8 +29,7 @@ ARG VERSION=0.1.0 \
|
|||||||
USER_NAME=collector \
|
USER_NAME=collector \
|
||||||
USER_GROUP=collector \
|
USER_GROUP=collector \
|
||||||
APP_UID=1000 \
|
APP_UID=1000 \
|
||||||
APP_GID=1000 \
|
APP_GID=1000
|
||||||
HEALTHCHECK_PATH=api/v1/check/health/
|
|
||||||
|
|
||||||
# copy app dependences
|
# copy app dependences
|
||||||
COPY --from=base /usr/local/lib/python3.10/site-packages/ /usr/local/lib/python3.10/site-packages/
|
COPY --from=base /usr/local/lib/python3.10/site-packages/ /usr/local/lib/python3.10/site-packages/
|
||||||
@@ -61,8 +60,5 @@ EXPOSE ${WEB_PORT}
|
|||||||
LABEL maintainer="s.zhukovskii@ispsystem.com"
|
LABEL maintainer="s.zhukovskii@ispsystem.com"
|
||||||
LABEL me.zhukovsky.logs-collector.version=v${VERSION}
|
LABEL me.zhukovsky.logs-collector.version=v${VERSION}
|
||||||
|
|
||||||
# call the health check endpoint of app
|
|
||||||
HEALTHCHECK CMD curl --fail http://localhost:${WEB_PORT}/${HEALTHCHECK_PATH} || exit 1
|
|
||||||
|
|
||||||
# run app
|
# run app
|
||||||
ENTRYPOINT [ "sh", "entrypoint.sh" ]
|
ENTRYPOINT [ "sh", "entrypoint.sh" ]
|
||||||
|
|||||||
12
README-ru.md
12
README-ru.md
@@ -313,12 +313,22 @@ Options:
|
|||||||
|
|
||||||
-f | --file full path to upload file required
|
-f | --file full path to upload file required
|
||||||
-t | --token access token required
|
-t | --token access token required
|
||||||
-u | --url target url required
|
-d | --dst storage domain name required
|
||||||
-v | --version print version
|
-v | --version print version
|
||||||
-h | --help print help
|
-h | --help print help
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
#### Пример:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./uploader.sh \
|
||||||
|
--dst collector.domain.zone \
|
||||||
|
--token e63268f4-5946-42eb-a678-b02182f14e87 \
|
||||||
|
--file /root/logs/all-logs.tar.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Лицензия
|
## Лицензия
|
||||||
|
|
||||||
GNU GPL 3.0
|
GNU GPL 3.0
|
||||||
|
|||||||
@@ -316,13 +316,20 @@ Options:
|
|||||||
|
|
||||||
-f | --file full path to upload file required
|
-f | --file full path to upload file required
|
||||||
-t | --token access token required
|
-t | --token access token required
|
||||||
-u | --url target url required
|
-d | --dst storage domain name required
|
||||||
-v | --version print version
|
-v | --version print version
|
||||||
-h | --help print help
|
-h | --help print help
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
#### Example:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./uploader.sh \
|
||||||
|
--dst collector.domain.zone \
|
||||||
|
--token e63268f4-5946-42eb-a678-b02182f14e87 \
|
||||||
|
--file /root/logs/all-logs.tar.gz
|
||||||
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,12 @@ services:
|
|||||||
target: ${APP_DIR}/data
|
target: ${APP_DIR}/data
|
||||||
env_file:
|
env_file:
|
||||||
- ./.env
|
- ./.env
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://${WEB_HOST}:${WEB_PORT}/${HEALTHCHECK_URL}"]
|
||||||
|
interval: 1m30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 40s
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
logs_collector_data:
|
logs_collector_data:
|
||||||
|
|||||||
@@ -7,4 +7,4 @@ __license__ = "GPL v3.0"
|
|||||||
__version__ = "0.1.0"
|
__version__ = "0.1.0"
|
||||||
__maintainer__ = "Stepan Zhukovsky"
|
__maintainer__ = "Stepan Zhukovsky"
|
||||||
__email__ = "stepan@zhukovsky.me"
|
__email__ = "stepan@zhukovsky.me"
|
||||||
__status__ = "Development"
|
__status__ = "Production"
|
||||||
|
|||||||
@@ -26,4 +26,4 @@ __license__ = "GPL v3.0"
|
|||||||
__version__ = "0.1.0"
|
__version__ = "0.1.0"
|
||||||
__maintainer__ = "Stepan Zhukovsky"
|
__maintainer__ = "Stepan Zhukovsky"
|
||||||
__email__ = "stepan@zhukovsky.me"
|
__email__ = "stepan@zhukovsky.me"
|
||||||
__status__ = "Development"
|
__status__ = "Production"
|
||||||
|
|||||||
@@ -2,13 +2,15 @@
|
|||||||
|
|
||||||
|
|
||||||
# INIT GLOBAL VARIABLES:
|
# INIT GLOBAL VARIABLES:
|
||||||
_VERSION="0.1.0"
|
_VERSION="0.1.1"
|
||||||
_PACKGMGR="apt yum"
|
_PKGMGR="apt yum"
|
||||||
_SCRIPT_NAME="$0"
|
_SCRIPT_NAME="$0"
|
||||||
_CMD="curl"
|
_CMD="curl"
|
||||||
_FILE=""
|
_FILE=""
|
||||||
_TOKEN=""
|
_TOKEN=""
|
||||||
_URL=""
|
_DST=""
|
||||||
|
_PROTO="https://"
|
||||||
|
_API_PATH="/api/v1/archives/"
|
||||||
|
|
||||||
|
|
||||||
# Colorize output
|
# Colorize output
|
||||||
@@ -42,30 +44,32 @@ check_util_exists() {
|
|||||||
|
|
||||||
# Print help message how used it script
|
# Print help message how used it script
|
||||||
help() {
|
help() {
|
||||||
|
# colorize value
|
||||||
local script=$(colorize GREEN "$_SCRIPT_NAME")
|
local script=$(colorize GREEN "$_SCRIPT_NAME")
|
||||||
local required=$(colorize RED "required")
|
local required=$(colorize RED "required")
|
||||||
|
# help message
|
||||||
printf "Usage: $script [options [parameters]]\n"
|
printf "Usage: $script [options [parameters]]\n"
|
||||||
printf "\n"
|
printf "\n"
|
||||||
printf "Options:\n"
|
printf "Options:\n"
|
||||||
printf "\n"
|
printf "\n"
|
||||||
printf " -f | --file full path to upload file $required\n"
|
printf " -f | --file full path to upload file $required\n"
|
||||||
printf " -t | --token access token $required\n"
|
printf " -t | --token access token $required\n"
|
||||||
printf " -u | --url target url $required\n"
|
printf " -d | --dst storage domain name $required\n"
|
||||||
printf " -v | --version print version\n"
|
printf " -v | --version print version\n"
|
||||||
printf " -h | --help print help\n"
|
printf " -h | --help print help\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# parse user arguments
|
# parse user options
|
||||||
argparser() {
|
optparser() {
|
||||||
# count user-passed arguments:
|
# count user-passed options:
|
||||||
local count_arguments=$#
|
local count_options=$#
|
||||||
# run help if empty and exit:
|
# run help if empty and exit:
|
||||||
if [[ count_arguments -eq 0 ]]; then
|
if [[ count_options -eq 0 ]]; then
|
||||||
help
|
help
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
# parse args:
|
# parse opts:
|
||||||
while [ ! -z "$1" ]; do
|
while [ ! -z "$1" ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--file|-f)
|
--file|-f)
|
||||||
@@ -76,9 +80,9 @@ argparser() {
|
|||||||
shift
|
shift
|
||||||
_TOKEN="$1"
|
_TOKEN="$1"
|
||||||
;;
|
;;
|
||||||
--url|-u)
|
--dst|-d)
|
||||||
shift
|
shift
|
||||||
_URL="$1"
|
_DST="$1"
|
||||||
;;
|
;;
|
||||||
--help|-h)
|
--help|-h)
|
||||||
help
|
help
|
||||||
@@ -102,12 +106,13 @@ argparser() {
|
|||||||
curl_is_exists() {
|
curl_is_exists() {
|
||||||
if ! check_util_exists $_CMD; then
|
if ! check_util_exists $_CMD; then
|
||||||
local error_cmd=$(colorize RED "$_CMD")
|
local error_cmd=$(colorize RED "$_CMD")
|
||||||
|
local script=$(colorize GREEN "$_SCRIPT_NAME")
|
||||||
printf "$(colorize RED "ERROR"): upload util doesn't exist, "
|
printf "$(colorize RED "ERROR"): upload util doesn't exist, "
|
||||||
printf "please install $error_cmd before run $_SCRIPT_NAME\n"
|
printf "please install $error_cmd before run $script\n"
|
||||||
# Print how install curl (support only apt/yum):
|
# Print how install curl (support only apt/yum):
|
||||||
for pkgmgr in $_PACKGMGR; do
|
for pkgmgr in $_PKGMGR; do
|
||||||
if check_util_exists $pkgmgr; then
|
if check_util_exists $pkgmgr; then
|
||||||
printf "$(colorize GREEN "RUN"): $pkgmgr install $error_cmd"
|
printf "$(colorize GREEN "RUN"): $pkgmgr install $error_cmd\n"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
exit 1
|
exit 1
|
||||||
@@ -115,17 +120,17 @@ curl_is_exists() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
validate_args() {
|
validate_opts() {
|
||||||
if [[ -z $_URL ]]; then
|
if [[ -z $_DST ]]; then
|
||||||
printf "$(colorize RED "ERROR"): -u | --url argument is required\n"
|
printf "$(colorize RED "ERROR"): -d | --dst option is required\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [[ -z $_FILE ]]; then
|
if [[ -z $_FILE ]]; then
|
||||||
printf "$(colorize RED "ERROR"): -f | --file argument is required\n"
|
printf "$(colorize RED "ERROR"): -f | --file option is required\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [[ -z $_TOKEN ]]; then
|
if [[ -z $_TOKEN ]]; then
|
||||||
printf "$(colorize RED "ERROR"): -t | --token argument is required\n"
|
printf "$(colorize RED "ERROR"): -t | --token option is required\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -134,12 +139,12 @@ validate_args() {
|
|||||||
# Upload file used curl
|
# Upload file used curl
|
||||||
# get $_URL $_FILE $_TOKEN
|
# get $_URL $_FILE $_TOKEN
|
||||||
upload() {
|
upload() {
|
||||||
local url=$1
|
local dst=$1
|
||||||
local file=$2
|
local file=$2
|
||||||
local token=$3
|
local token=$3
|
||||||
# run:
|
# run:
|
||||||
curl --progress-bar -X 'POST' \
|
curl --progress-bar -X 'POST' \
|
||||||
"${url}" \
|
"${_PROTO}${dst}${_API_PATH}" \
|
||||||
-H 'accept: application/json' \
|
-H 'accept: application/json' \
|
||||||
-H "Upload-Token: ${token} " \
|
-H "Upload-Token: ${token} " \
|
||||||
-H 'Content-Type: multipart/form-data' \
|
-H 'Content-Type: multipart/form-data' \
|
||||||
@@ -148,10 +153,10 @@ upload() {
|
|||||||
|
|
||||||
|
|
||||||
main () {
|
main () {
|
||||||
argparser $@
|
optparser $@
|
||||||
curl_is_exists
|
curl_is_exists
|
||||||
validate_args
|
validate_opts
|
||||||
upload $_URL $_FILE $_TOKEN
|
upload $_DST $_FILE $_TOKEN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user