Best commit ever
This commit is contained in:
21
harden
21
harden
@@ -249,6 +249,21 @@ function kernelSecurityModuleInit {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function dockerInit {
|
||||||
|
# Get all arguments passed to the function and store them in the dockerImages array
|
||||||
|
local dockerImages=("$@")
|
||||||
|
# Check if the dockerImages array is empty and return 0 if it is
|
||||||
|
[[ "${#dockerImages[@]}" -eq 0 ]] && return 0
|
||||||
|
# Loop through the dockerImages array
|
||||||
|
# The dockerImages array contains all the docker images to install and run
|
||||||
|
for dockerImage in "${dockerImages[@]}"; do
|
||||||
|
# No need to pull the docker image as the run command will do it automatically
|
||||||
|
# Run the docker image in the background,
|
||||||
|
# with the restar always option and the name of the docker image
|
||||||
|
docker run -d --restart always --name "$dockerImage" "$dockerImage"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# The main function will call the check_dependencies function and exit if it fails.
|
# The main function will call the check_dependencies function and exit if it fails.
|
||||||
# It will also output a message to the user to let them know that the script has finished.
|
# It will also output a message to the user to let them know that the script has finished.
|
||||||
function main {
|
function main {
|
||||||
@@ -256,6 +271,10 @@ function main {
|
|||||||
harden_ssh || exit 1 # Harden ssh and exit if it fails
|
harden_ssh || exit 1 # Harden ssh and exit if it fails
|
||||||
firewallInit || exit 1 # Initialize the firewall and exit if it fails
|
firewallInit || exit 1 # Initialize the firewall and exit if it fails
|
||||||
kernelSecurityModuleInit || exit 1 # Initialize the kernel security module and exit if it fails
|
kernelSecurityModuleInit || exit 1 # Initialize the kernel security module and exit if it fails
|
||||||
|
# If number of arguments is greater than 0
|
||||||
|
# Call the dockerInit function with the arguments passed to the script
|
||||||
|
# Else exit with error code 1
|
||||||
|
[[ $# -gt 0 ]] && dockerInit "$@" || exit 1
|
||||||
printf "%s" "Script finished" # Output message to the user
|
printf "%s" "Script finished" # Output message to the user
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,7 +342,7 @@ function main {
|
|||||||
# }
|
# }
|
||||||
|
|
||||||
# Call the main function
|
# Call the main function
|
||||||
main
|
main "$@"
|
||||||
# am_i_root
|
# am_i_root
|
||||||
|
|
||||||
exit 0 # The right and proper way to exit a script
|
exit 0 # The right and proper way to exit a script
|
||||||
|
|||||||
Reference in New Issue
Block a user