-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
64 additions
and
15 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,29 +1,41 @@ | ||
#!/bin/bash | ||
|
||
echo "*************************" | ||
echo "* AWS EC2 AMI Generator *" | ||
echo "*************************" | ||
export dateformat='%Y-%m-%d %H:%M:%S.%N UTC%z' | ||
|
||
scriptroot=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | ||
distro=$(lsb_release -i | sed -r 's/^Distributor ID:\W*(.*)$/\L\1/') | ||
release=$(lsb_release -c | sed -r 's/^Codename:\W*(.*)$/\L\1/') | ||
|
||
# Add global scripts directory | ||
globalscripts="${scriptroot}/global" | ||
if [ -d "${globalscripts}" ]; then | ||
echo "Found global scripts: ${globalscripts}" | ||
PATH="${globalscripts}:${PATH}" | ||
fi | ||
|
||
# Add distro-specific scripts directory | ||
distroscripts="${scriptroot}/${distro}/all" | ||
if [ -d "${distroscripts}" ]; then | ||
echo "Found distro-specific scripts: ${distroscripts}" | ||
PATH="${distroscripts}:${PATH}" | ||
fi | ||
|
||
# Add release-specific scripts directory | ||
releasescripts="${scriptroot}/${distro}/${release}" | ||
if [ -d "${releasescripts}" ]; then | ||
echo "Found release-specific scripts: ${releasescripts}" | ||
PATH="${releasescripts}:${PATH}" | ||
fi | ||
|
||
export PATH | ||
|
||
echo -e "\nStarting at $(date +"${dateformat}")" | ||
|
||
upgradeSystemPackages | ||
installSystemPackages python3 python3-pip puppet cloud-utils | ||
installPythonPackages awscli | ||
|
||
echo -e "\nFinished at $(date +"${dateformat}")" |
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,17 +1,30 @@ | ||
#!/bin/bash | ||
echo "==System Package Installer==" | ||
if [[ "x${dateformat}" != "x" ]]; then | ||
echo -e "Begin at $(date +"${dateformat}")" | ||
fi | ||
|
||
if [ $# -lt 1 ]; then | ||
echo "Please specify at least one package to install" >&2 | ||
echo -e "\t[FAIL] Please specify at least one package to install" >&2 | ||
exit 1 | ||
fi | ||
|
||
if apt-get --version &>/dev/null; then | ||
echo -e "\tRunning apt-get install..." | ||
apt-get install --assume-yes "$@" &>/dev/null | ||
exit $? | ||
exval=$? | ||
elif yum --version &>/dev/null; then | ||
echo -e "\tRunning yum install..." | ||
yum --assumeyes install "$@" &>/dev/null | ||
exit $? | ||
exval=$? | ||
else | ||
echo "No package mangers found" >&2 | ||
echo -e "\t[FAIL] No package mangers found" >&2 | ||
exit 2 | ||
fi | ||
|
||
if [ $exval -eq 0 ]; then | ||
echo -e "\t[DONE]" | ||
else | ||
echo -e "\t[FAIL] Code: ${exval}" | ||
exit $exval | ||
fi |
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,16 +1,29 @@ | ||
#!/bin/bash | ||
echo "==System Package Updater==" | ||
if [[ "x${dateformat}" != "x" ]]; then | ||
echo -e "Begin at $(date +"${dateformat}")" | ||
fi | ||
|
||
if apt-get --version &>/dev/null; then | ||
echo -e "Running apt-get update..." | ||
apt-get update &>/dev/null | ||
exval=$? | ||
if [ $exval -ne 0 ]; then | ||
exit $exval | ||
if [ $exval -eq 0 ]; then | ||
echo -e "Running apt-get upgrade..." | ||
apt-get upgrade --assume-yes &>/dev/null | ||
exval=$? | ||
fi | ||
apt-get upgrade --assume-yes &>/dev/null | ||
exit $? | ||
fi | ||
|
||
if yum --version &>/dev/null; then | ||
echo -e "Running yum upgrade..." | ||
yum --assumeyes upgrade &>/dev/null | ||
exit $? | ||
exval=$? | ||
fi | ||
|
||
if [ $exval -eq 0 ]; then | ||
echo -e "\t[DONE]" | ||
else | ||
echo -e "\t[FAIL] Code: ${exval}" | ||
exit $exval | ||
fi |