countme: Merge the update scripts code for CentOS/Fedora countme.
Signed-off-by: James Antill <jantill@redhat.com>
This commit is contained in:
parent
abefd06101
commit
d971dca377
2 changed files with 36 additions and 14 deletions
|
@ -1,8 +1,11 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# What are we called (used for message bus so don't just use cmd $0)
|
||||||
|
CMD_NAME=countme-centos-update
|
||||||
|
|
||||||
export MSGTOPIC_PREFIX=logging.stats
|
export MSGTOPIC_PREFIX=logging.stats
|
||||||
export MSGBODY_PRESET="loghost=$(hostname) run_id=$(uuidgen -r)"
|
export MSGBODY_PRESET="loghost=$(hostname) run_id=$(uuidgen -r)"
|
||||||
simple_message_to_bus countme-centos-update.start
|
simple_message_to_bus $CMD_NAME.start
|
||||||
|
|
||||||
# Where do we keep our local/internal data?
|
# Where do we keep our local/internal data?
|
||||||
LOCAL_DATA_DIR=/var/lib/countme
|
LOCAL_DATA_DIR=/var/lib/countme
|
||||||
|
@ -16,10 +19,18 @@ PUBLIC_DATA_DIR=/var/www/html/csv-reports/countme
|
||||||
PUBLIC_TOTALS_DB=$PUBLIC_DATA_DIR/totals-centos.db
|
PUBLIC_TOTALS_DB=$PUBLIC_DATA_DIR/totals-centos.db
|
||||||
PUBLIC_TOTALS_CSV=$PUBLIC_DATA_DIR/totals-centos.csv
|
PUBLIC_TOTALS_CSV=$PUBLIC_DATA_DIR/totals-centos.csv
|
||||||
|
|
||||||
# Names of the update commands. They are from the python3-mirrors-countme rpm
|
# Names of the update commands.
|
||||||
|
# From python3*-mirrors-countme Eg. python3.11-mirrors-countme-0.1.2-1.el8
|
||||||
|
# They should be in PATH somewhere...
|
||||||
UPDATE_RAWDB=countme-update-rawdb.sh
|
UPDATE_RAWDB=countme-update-rawdb.sh
|
||||||
UPDATE_TOTALS=countme-update-totals.sh
|
UPDATE_TOTALS=countme-update-totals.sh
|
||||||
|
|
||||||
|
# ------------------------------ NOTE ------------------------------
|
||||||
|
# Everything below this line should try to be identical between the
|
||||||
|
# fedora/centos scripts, to make any changes easier. Add more options
|
||||||
|
# above and then have the code below be the same.
|
||||||
|
# ------------------------------ NOTE ------------------------------
|
||||||
|
|
||||||
# How we're gonna call git - our local repo dir is LOCAL_DATA_DIR
|
# How we're gonna call git - our local repo dir is LOCAL_DATA_DIR
|
||||||
_GIT="git -C $LOCAL_DATA_DIR"
|
_GIT="git -C $LOCAL_DATA_DIR"
|
||||||
|
|
||||||
|
@ -39,16 +50,16 @@ _run() {
|
||||||
if [ "$DRYRUN" ]; then
|
if [ "$DRYRUN" ]; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
simple_message_to_bus countme-centos-update.command.start command="$@"
|
simple_message_to_bus $CMD_NAME.command.start command="$@"
|
||||||
"$@"
|
"$@"
|
||||||
RESULT=$?
|
RESULT=$?
|
||||||
simple_message_to_bus countme-centos-update.command.finish command="$@" result="$?"
|
simple_message_to_bus $CMD_NAME.command.finish command="$@" result="$?"
|
||||||
return $RESULT
|
return $RESULT
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# CLI help text
|
# CLI help text
|
||||||
HELP_USAGE="usage: countme-centos-updates.sh [OPTION]..."
|
HELP_USAGE="usage: $CMD_NAME.sh [OPTION]..."
|
||||||
HELP_OPTIONS="
|
HELP_OPTIONS="
|
||||||
Options:
|
Options:
|
||||||
-h, --help Show this message and exit
|
-h, --help Show this message and exit
|
||||||
|
@ -62,7 +73,7 @@ if [ -z "$PROGRESS" -a -t 2 ]; then PROGRESS=1; fi
|
||||||
|
|
||||||
# Parse CLI options with getopt(1)
|
# Parse CLI options with getopt(1)
|
||||||
_GETOPT_TMP=$(getopt \
|
_GETOPT_TMP=$(getopt \
|
||||||
--name countme-centos-update \
|
--name $CMD_NAME \
|
||||||
--options hvnp \
|
--options hvnp \
|
||||||
--longoptions help,verbose,dryrun,progress,checkoutdir: \
|
--longoptions help,verbose,dryrun,progress,checkoutdir: \
|
||||||
-- "$@")
|
-- "$@")
|
||||||
|
@ -122,5 +133,5 @@ _run $_GIT diff --quiet || _run $_GIT commit -a -m "$(date -u +%F) update"
|
||||||
_run atomic_copy $TOTALS_DB $PUBLIC_TOTALS_DB
|
_run atomic_copy $TOTALS_DB $PUBLIC_TOTALS_DB
|
||||||
_run atomic_copy $TOTALS_CSV $PUBLIC_TOTALS_CSV
|
_run atomic_copy $TOTALS_CSV $PUBLIC_TOTALS_CSV
|
||||||
|
|
||||||
simple_message_to_bus countme-centos-update.finish
|
simple_message_to_bus $CMD_NAME.finish
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# What are we called (used for message bus so don't just use cmd $0)
|
||||||
|
CMD_NAME=countme-update
|
||||||
|
|
||||||
export MSGTOPIC_PREFIX=logging.stats
|
export MSGTOPIC_PREFIX=logging.stats
|
||||||
export MSGBODY_PRESET="loghost=$(hostname) run_id=$(uuidgen -r)"
|
export MSGBODY_PRESET="loghost=$(hostname) run_id=$(uuidgen -r)"
|
||||||
simple_message_to_bus countme-update.start
|
simple_message_to_bus $CMD_NAME.start
|
||||||
|
|
||||||
# Where do we keep our local/internal data?
|
# Where do we keep our local/internal data?
|
||||||
LOCAL_DATA_DIR=/var/lib/countme
|
LOCAL_DATA_DIR=/var/lib/countme
|
||||||
|
@ -15,10 +18,18 @@ PUBLIC_DATA_DIR=/var/www/html/csv-reports/countme
|
||||||
PUBLIC_TOTALS_DB=$PUBLIC_DATA_DIR/totals.db
|
PUBLIC_TOTALS_DB=$PUBLIC_DATA_DIR/totals.db
|
||||||
PUBLIC_TOTALS_CSV=$PUBLIC_DATA_DIR/totals.csv
|
PUBLIC_TOTALS_CSV=$PUBLIC_DATA_DIR/totals.csv
|
||||||
|
|
||||||
# Names of the update commands. They should be in PATH somewhere..
|
# Names of the update commands.
|
||||||
|
# From python3*-mirrors-countme Eg. python3.11-mirrors-countme-0.1.2-1.el8
|
||||||
|
# They should be in PATH somewhere...
|
||||||
UPDATE_RAWDB=countme-update-rawdb.sh
|
UPDATE_RAWDB=countme-update-rawdb.sh
|
||||||
UPDATE_TOTALS=countme-update-totals.sh
|
UPDATE_TOTALS=countme-update-totals.sh
|
||||||
|
|
||||||
|
# ------------------------------ NOTE ------------------------------
|
||||||
|
# Everything below this line should try to be identical between the
|
||||||
|
# fedora/centos scripts, to make any changes easier. Add more options
|
||||||
|
# above and then have the code below be the same.
|
||||||
|
# ------------------------------ NOTE ------------------------------
|
||||||
|
|
||||||
# How we're gonna call git - our local repo dir is LOCAL_DATA_DIR
|
# How we're gonna call git - our local repo dir is LOCAL_DATA_DIR
|
||||||
_GIT="git -C $LOCAL_DATA_DIR"
|
_GIT="git -C $LOCAL_DATA_DIR"
|
||||||
|
|
||||||
|
@ -38,16 +49,16 @@ _run() {
|
||||||
if [ "$DRYRUN" ]; then
|
if [ "$DRYRUN" ]; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
simple_message_to_bus countme-update.command.start command="$@"
|
simple_message_to_bus $CMD_NAME.command.start command="$@"
|
||||||
"$@"
|
"$@"
|
||||||
RESULT=$?
|
RESULT=$?
|
||||||
simple_message_to_bus countme-update.command.finish command="$@" result="$?"
|
simple_message_to_bus $CMD_NAME.command.finish command="$@" result="$?"
|
||||||
return $RESULT
|
return $RESULT
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# CLI help text
|
# CLI help text
|
||||||
HELP_USAGE="usage: countme-updates.sh [OPTION]..."
|
HELP_USAGE="usage: $CMD_NAME.sh [OPTION]..."
|
||||||
HELP_OPTIONS="
|
HELP_OPTIONS="
|
||||||
Options:
|
Options:
|
||||||
-h, --help Show this message and exit
|
-h, --help Show this message and exit
|
||||||
|
@ -61,7 +72,7 @@ if [ -z "$PROGRESS" -a -t 2 ]; then PROGRESS=1; fi
|
||||||
|
|
||||||
# Parse CLI options with getopt(1)
|
# Parse CLI options with getopt(1)
|
||||||
_GETOPT_TMP=$(getopt \
|
_GETOPT_TMP=$(getopt \
|
||||||
--name countme-update \
|
--name $CMD_NAME \
|
||||||
--options hvnp \
|
--options hvnp \
|
||||||
--longoptions help,verbose,dryrun,progress,checkoutdir: \
|
--longoptions help,verbose,dryrun,progress,checkoutdir: \
|
||||||
-- "$@")
|
-- "$@")
|
||||||
|
@ -121,5 +132,5 @@ _run $_GIT diff --quiet || _run $_GIT commit -a -m "$(date -u +%F) update"
|
||||||
_run atomic_copy $TOTALS_DB $PUBLIC_TOTALS_DB
|
_run atomic_copy $TOTALS_DB $PUBLIC_TOTALS_DB
|
||||||
_run atomic_copy $TOTALS_CSV $PUBLIC_TOTALS_CSV
|
_run atomic_copy $TOTALS_CSV $PUBLIC_TOTALS_CSV
|
||||||
|
|
||||||
simple_message_to_bus countme-update.finish
|
simple_message_to_bus $CMD_NAME.finish
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue