-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.0.65 Update build and tool scripts
- Loading branch information
1 parent
a38a131
commit be75fbd
Showing
9 changed files
with
536 additions
and
86 deletions.
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
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 |
---|---|---|
@@ -1,23 +1,62 @@ | ||
#!/bin/bash | ||
# Purpose: Tag a Git commit with version and annotation, commit locally, and push to remote | ||
# Usage: ./git.sh <version> <annotation> | ||
# Description: This script tags a Git commit with the specified version and annotation, | ||
# commits locally, and pushes both the tag and commit to the remote repository. | ||
|
||
if (( $# != 2 )) | ||
then | ||
printf "%b" "Usage: git.sh <version> <annotation>\n" >&2 | ||
exit 1 | ||
# Function to print messages with a timestamp | ||
print_message() { | ||
echo "" | ||
echo "$(date +"%Y-%m-%d %H:%M:%S") - $1" | ||
} | ||
|
||
# Function to display help message | ||
show_help() { | ||
echo "Usage: $0 <version> <annotation>" | ||
echo "" | ||
echo "Options:" | ||
echo " -h, --help Display this help message." | ||
echo "" | ||
echo "Description:" | ||
echo "This script tags a Git commit with the specified version and annotation," | ||
echo "commits locally, and pushes both the tag and commit to the remote repository." | ||
exit 0 | ||
} | ||
|
||
# Function to handle errors | ||
handle_error() { | ||
print_message "Error: $1" | ||
} | ||
|
||
# Parse options | ||
while [[ "$#" -gt 0 ]]; do | ||
case $1 in | ||
-h|--help) show_help ;; | ||
*) break ;; | ||
esac | ||
shift | ||
done | ||
|
||
# Check if exactly two arguments are passed | ||
if (( $# != 2 )); then | ||
handle_error "Incorrect number of arguments. Usage: $0 <version> <annotation>" | ||
fi | ||
|
||
# Assign arguments to variables | ||
VERSION=$1 | ||
ANNOTATION=$2 | ||
|
||
echo "Creating tag $VERSION with annotation \"$ANNOTATION\"" | ||
git tag -a $VERSION -m "$ANNOTATION" | ||
# Tagging, committing, and pushing operations | ||
print_message "Creating tag $VERSION with annotation \"$ANNOTATION\"" | ||
git tag -a "$VERSION" -m "$ANNOTATION" || handle_error "Failed to create tag" | ||
|
||
echo "Commiting version $VERSION to local branch" | ||
git commit -a -m "$VERSION $ANNOTATION" | ||
print_message "Committing version $VERSION to local branch" | ||
git commit -a -m "$VERSION $ANNOTATION" || handle_error "Failed to commit changes" | ||
|
||
echo "Pushing tag $VERSION" | ||
git push --tag | ||
print_message "Pushing tag $VERSION to upstream" | ||
git push --tag || handle_error "Failed to push tag to upstream" | ||
|
||
echo "Pushing version $VERSION to upstream" | ||
git push | ||
print_message "Pushing version $VERSION to upstream" | ||
git push || handle_error "Failed to push changes to upstream" | ||
|
||
print_message "Script completed successfully" |
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 |
---|---|---|
@@ -1,10 +1,77 @@ | ||
#!/bin/bash | ||
|
||
for i in $(docker ps --quiet); do | ||
echo ""; | ||
echo "--------------"; | ||
echo $i; | ||
echo "--------------"; | ||
echo ""; | ||
docker exec $i dpkg -l; | ||
done; | ||
# Function to log messages with timestamps | ||
log() { | ||
echo "$(date +'%Y-%m-%d %H:%M:%S') - $1" | ||
} | ||
|
||
# Function to list packages in a container | ||
list_packages() { | ||
local container_id=$1 | ||
local package_filter_cmd=$2 | ||
|
||
echo "" | ||
echo "------------------------------" | ||
echo "Container ID: $container_id" | ||
echo "------------------------------" | ||
echo "" | ||
|
||
docker exec "$container_id" bash -c "$package_filter_cmd" | ||
} | ||
|
||
# Display usage instructions | ||
display_help() { | ||
echo "Usage: $0 [options]" | ||
echo "Options:" | ||
echo " -a, --all List all installed packages (default)" | ||
echo " -u, --user List only user-installed packages" | ||
echo " -h, --help Display this help message" | ||
exit 0 | ||
} | ||
|
||
# Default behavior | ||
list_user_packages=false | ||
|
||
# Parse command-line arguments | ||
while [[ "$#" -gt 0 ]]; do | ||
case $1 in | ||
-a|--all) list_user_packages=false;; | ||
-u|--user) list_user_packages=true;; | ||
-h|--help) display_help;; | ||
*) log "Unknown parameter passed: $1"; display_help;; | ||
esac | ||
shift | ||
done | ||
|
||
# Check if Docker is running | ||
if ! command -v docker &> /dev/null; then | ||
log "Docker is not installed or not running." | ||
exit 1 | ||
fi | ||
|
||
# Get the list of running containers | ||
containers=$(docker ps --quiet) | ||
|
||
if [ -z "$containers" ]; then | ||
log "No running Docker containers found." | ||
exit 0 | ||
fi | ||
|
||
# Determine the package filter command based on the option selected | ||
if [ "$list_user_packages" = true ]; then | ||
package_filter_cmd='comm -23 <(apt-mark showmanual | sort) <(apt list --installed 2>/dev/null | awk -F/ '\''{print $1}'\'' | sort)' | ||
else | ||
package_filter_cmd='dpkg -l' | ||
fi | ||
|
||
# Loop through each container and list packages based on the option selected | ||
for container_id in $containers; do | ||
if ! docker exec "$container_id" bash -c "$package_filter_cmd" &> /dev/null; then | ||
log "Failed to execute command in container $container_id. Skipping." | ||
continue | ||
fi | ||
|
||
list_packages "$container_id" "$package_filter_cmd" | ||
done | ||
|
||
log "Package listing completed." |
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 |
---|---|---|
@@ -1,27 +1,78 @@ | ||
#!/bin/bash | ||
# Purpose: Merge development branch into main branch and tag with version | ||
# Usage: ./push-development-branch.sh <version> <annotation> | ||
# Description: This script merges the development branch into the main branch, | ||
# tags the main branch with the specified version, and | ||
# calls another script 'git.sh' with the version and annotation. | ||
|
||
if (( $# != 2 )) | ||
then | ||
printf "%b" "Usage: git.sh <version> <annotation>\n" >&2; | ||
exit 1; | ||
fi; | ||
# Function to print messages with a timestamp | ||
print_message() { | ||
echo "" | ||
echo "$(date +"%Y-%m-%d %H:%M:%S") - $1" | ||
} | ||
|
||
VERSION=$1; | ||
ANNOTATION=$2; | ||
# Function to display help message | ||
show_help() { | ||
echo "Usage: $0 <version> <annotation>" | ||
echo "" | ||
echo "Options:" | ||
echo " -h, --help Display this help message." | ||
echo "" | ||
echo "Description:" | ||
echo "This script merges the development branch into the main branch," | ||
echo "tags the main branch with the specified version, and" | ||
echo "calls another script 'git.sh' with the version and annotation." | ||
exit 0 | ||
} | ||
|
||
echo "Calling git.sh with tag $VERSION with annotation \"$ANNOTATION\""; | ||
./git.sh "$VERSION" "$ANNOTATION"; | ||
# Function to handle errors | ||
handle_error() { | ||
print_message "Error: $1" | ||
exit 1 | ||
} | ||
|
||
echo "Checking out main branch"; | ||
git checkout main; | ||
# Parse options | ||
while [[ "$#" -gt 0 ]]; do | ||
case $1 in | ||
-h|--help) show_help ;; | ||
*) break ;; | ||
esac | ||
shift | ||
done | ||
|
||
echo "Merging development branch"; | ||
git merge development; | ||
# Check if exactly two arguments are passed | ||
if (( $# != 2 )); then | ||
handle_error "Incorrect number of arguments. Usage: $0 <version> <annotation>" | ||
fi | ||
|
||
echo "Calling git.sh with tag $VERSION with annotation \"$ANNOTATION\""; | ||
./git.sh "$VERSION" "$ANNOTATION"; | ||
# Assign arguments to variables | ||
VERSION=$1 | ||
ANNOTATION=$2 | ||
|
||
echo "Checking out development branch"; | ||
git checkout development; | ||
# Verify 'git.sh' script exists and is executable | ||
GIT_SCRIPT="./git.sh" | ||
if [[ ! -x "$GIT_SCRIPT" ]]; then | ||
handle_error "'git.sh' script not found or not executable" | ||
fi | ||
|
||
git status; | ||
# Tag and merge operations | ||
print_message "Calling git.sh with tag $VERSION with annotation \"$ANNOTATION\"" | ||
"$GIT_SCRIPT" "$VERSION" "$ANNOTATION" || handle_error "Failed to call git.sh" | ||
|
||
print_message "Checking out main branch" | ||
git checkout main || handle_error "Failed to checkout main branch" | ||
|
||
print_message "Merging development branch" | ||
git merge development || handle_error "Failed to merge development branch" | ||
|
||
print_message "Calling git.sh with tag $VERSION with annotation \"$ANNOTATION\"" | ||
"$GIT_SCRIPT" "$VERSION" "$ANNOTATION" || handle_error "Failed to call git.sh" | ||
|
||
print_message "Checking out development branch" | ||
git checkout development || handle_error "Failed to checkout development branch" | ||
|
||
# Show git status | ||
print_message "Git status" | ||
git status || handle_error "Failed to show git status" | ||
|
||
print_message "Script completed successfully" |
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 |
---|---|---|
@@ -1,9 +1,67 @@ | ||
#!/bin/bash | ||
# Purpose: Clean up Docker resources for Mutillidae application | ||
# Usage: ./remove-all-images.sh [options] | ||
|
||
docker stop $(docker ps -a -q); | ||
docker rm $(docker ps -a -q); | ||
docker rmi $(docker images -a -q); | ||
docker container prune -f; | ||
docker image prune --all -f; | ||
docker volume prune -f; | ||
docker system prune --all --volumes -f; | ||
# Function to print messages with a timestamp | ||
print_message() { | ||
echo "" | ||
echo "$(date +"%Y-%m-%d %H:%M:%S") - $1" | ||
} | ||
|
||
# Function to display help message | ||
show_help() { | ||
echo "Usage: $0 [options]" | ||
echo "" | ||
echo "Options:" | ||
echo " -h, --help Display this help message." | ||
echo "" | ||
echo "Description:" | ||
echo "This script is used to clean up Docker resources for the Mutillidae application." | ||
echo "It stops and removes all containers, removes all images, and prunes all volumes and networks." | ||
exit 0 | ||
} | ||
|
||
# Function to handle errors | ||
handle_error() { | ||
print_message "Error: $1" | ||
} | ||
|
||
# Parse options | ||
while [[ "$#" -gt 0 ]]; do | ||
case $1 in | ||
-h|--help) show_help ;; | ||
*) handle_error "Unknown parameter passed: $1" ;; | ||
esac | ||
shift | ||
done | ||
|
||
# Check if Docker is installed and running | ||
if ! command -v docker &> /dev/null; then | ||
handle_error "Docker is not installed or not in PATH. Please install Docker." | ||
fi | ||
|
||
# Clean up Docker resources | ||
print_message "Cleaning up Docker resources for Mutillidae" | ||
|
||
# Stop and remove all containers | ||
print_message "Stopping and removing all containers" | ||
docker stop $(docker ps -a -q) || handle_error "Failed to stop containers" | ||
docker rm $(docker ps -a -q) || handle_error "Failed to remove containers" | ||
|
||
# Remove all images | ||
print_message "Removing all images" | ||
docker rmi $(docker images -a -q) || handle_error "Failed to remove images" | ||
|
||
# Prune containers, images, volumes, networks | ||
print_message "Pruning containers, images, volumes, networks" | ||
docker container prune -f || handle_error "Failed to prune containers" | ||
docker image prune --all -f || handle_error "Failed to prune images" | ||
docker volume prune -f || handle_error "Failed to prune volumes" | ||
docker network prune -f || handle_error "Failed to prune networks" | ||
|
||
# System-wide prune | ||
print_message "Pruning system" | ||
docker system prune --all --volumes -f || handle_error "Failed to prune system" | ||
|
||
# Success message | ||
print_message "Docker resources for Mutillidae cleaned up successfully" |
Oops, something went wrong.