-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add p-helper commands to make restarting Pulp easier #161
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# The p-helper commands, back and better than ever! | ||
# This file should be sourced to get the classic commands inside your oci-env | ||
|
||
|
||
_paction() { | ||
SERVICES=$(s6-rc -d list | grep -E 'pulpcore|nginx' | paste -sd ' ') | ||
if [ $# -gt 1 ] ; then | ||
SERVICES="${@:2}" | ||
fi | ||
echo "`setterm -foreground blue` s6-rc $1 ${SERVICES}" | ||
setterm -default | ||
s6-rc $1 ${SERVICES} | ||
} | ||
|
||
pstart() { | ||
_paction start $@ | ||
} | ||
_pstart_help="Start all pulp-related services" | ||
|
||
pstop() { | ||
_paction stop $@ | ||
} | ||
_pstop_help="Stop all pulp-related services" | ||
|
||
prestart() { | ||
_paction stop $@ | ||
_paction start $@ | ||
} | ||
_prestart_help="Restart all pulp-related services" | ||
|
||
pstatus() { | ||
echo "`setterm -foreground green`Services that are live/ran successfully" | ||
_paction -a list | ||
echo "`setterm -foreground red`Services that are down" | ||
_paction -da list | ||
} | ||
_pstatus_help="Report the status of all pulp-related services" | ||
|
||
|
||
pdbreset() { | ||
echo "Resetting the Pulp database" | ||
bash /opt/oci_env/base/container_scripts/database_reset.sh | ||
} | ||
_pdbreset_help="Reset the Pulp database" | ||
# can get away with not resetting terminal settings here since it gets reset in phelp | ||
_pdbreset_help="$_dbreset_help - `setterm -foreground red -bold on`THIS DESTROYS YOUR PULP DATA" | ||
|
||
pclean() { | ||
pdbreset | ||
sudo rm -rf /var/pulp/media/* | ||
redis-cli FLUSHALL | ||
pulpcore-manager collectstatic --clear --noinput --link | ||
if which mc ; then | ||
mc rb --force s3/${PULP_AWS_STORAGE_BUCKET_NAME} | ||
mc mb s3/${PULP_AWS_STORAGE_BUCKET_NAME} | ||
fi | ||
} | ||
_pclean_help="Restore pulp to a clean-installed state" | ||
# can get away with not resetting terminal settings here since it gets reset in phelp | ||
_pclean_help="$_pclean_help - `setterm -foreground red -bold on`THIS DESTROYS YOUR PULP DATA" | ||
|
||
phelp() { | ||
# get a list of declared functions, filter out ones with leading underscores as "private" | ||
funcs=$(declare -F | awk '{ print $3 }'| grep -v ^_ | grep -v fzf) | ||
|
||
# for each func, if a help string is defined, assume it's a pulp function and print its help | ||
# (this is bash introspection via variable variables) | ||
for func in $funcs; do | ||
# get the "help" variable name for this function | ||
help_var="_${func}_help" | ||
# use ${!<varname>} syntax to eval the help_var | ||
help=${!help_var} | ||
# If the help var had a value, echo its value here (the value is function help text) | ||
if [ ! -z "$help" ]; then | ||
# make the function name easy to spot | ||
setterm -foreground yellow -bold on | ||
echo -n "$func" | ||
# reset terminal formatting before printing the help text | ||
# (implicitly format it as normal text) | ||
setterm -default | ||
echo ": $help" | ||
fi | ||
done | ||
|
||
# explicitly restore terminal formatting is reset before exiting function | ||
setterm -default | ||
} | ||
_phelp_help="Print this help" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to register the rest of the commands:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I really need to? clean and dbreset are already covered in other commands, status doesn't do anything extra than what pulp status does, and help is redundant. Those extra commands are helpful inside the container, but outside I don't think so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well,
phelp
can be useful for showing what commends are available for the user. If we wanted to completely mirror the old behaviour, it would be nice to have this change included.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I just added the rest of the phelper commands to the list. I guess it isn't much of a big deal.