Skip to content

Commit

Permalink
Merge pull request #6 from opennms-forge/issue/4
Browse files Browse the repository at this point in the history
Issue#4: Add test if sudo is available. Tested the script against Ubunutu 18.04, Debian 9 and CentOS 7.5.1804.
  • Loading branch information
indigo423 authored May 12, 2018
2 parents 2a6f488 + c329e0f commit 094a80c
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 57 deletions.
6 changes: 3 additions & 3 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ The script executes the steps documented in link:http://docs.opennms.org/opennms

The script is tested with:

* Ubuntu 16.04 (Xenial Xerus) LTS 64bit
* Debian 8 (Jessie) 64bit
* CentOS 7.1 64bit
* Ubuntu 18.04 (Bionic Beaver) 64bit
* Debian 9 (Stretch) 64bit
* CentOS 7.5.1804 64bit
== Usage

Expand Down
51 changes: 33 additions & 18 deletions bootstrap-debian-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,37 @@ usage() {
echo "-h: Show this help"
}

checkRequirements() {
# Test if system is supported
uname -a | grep -E "${REQUIRED_SYSTEMS}" 1>/dev/null 2>>"${ERROR_LOG}"
if [ ! "${?}" -eq 0 ]; then
echo ""
echo "This is system is not a supported Ubuntu or Debian system."
echo ""
exit ${E_UNSUPPORTED}
fi

# Setting Postgres User and changing configuration files require
# root permissions.
if [ "${USER}" != "${REQUIRED_USER}" ]; then
echo ""
echo "This script requires root permissions to be executed."
echo ""
exit ${E_BASH}
fi

# The sudo command is required to switch to postgres user for DB setup
echo -n "Path to sudo: ">>${ERROR_LOG}
which sudo 1>>${ERROR_LOG} 2>>${ERROR_LOG}
if [ ! "${?}" -eq "0" ]; then
echo ""
echo "This script requires sudo which could not be found."
echo "Please install the sudo package."
echo ""
exit ${E_BASH}
fi
}

showDisclaimer() {
echo ""
echo "This script installs OpenNMS on your system. It will"
Expand Down Expand Up @@ -66,24 +97,6 @@ showDisclaimer() {
shopt -u nocasematch
}

# Test if system is supported
uname -a | grep -E ${REQUIRED_SYSTEMS} 1>/dev/null 2>>${ERROR_LOG}
if [ ! ${?} -eq 0 ]; then
echo ""
echo "This is system is not a supported Ubuntu or Debian system."
echo ""
exit ${E_UNSUPPORTED}
fi

# Setting Postgres User and changing configuration files require
# root permissions.
if [ "${USER}" != "${REQUIRED_USER}" ]; then
echo ""
echo "This script requires root permissions to be executed."
echo ""
exit ${E_BASH}
fi

####
# The -r option is optional and allows to set the release of OpenNMS.
# The -m option allows to overwrite the package repository server.
Expand Down Expand Up @@ -206,6 +219,8 @@ cloneCode() {

# Execute setup procedure
clear
showDisclaimer
checkRequirements
installOnmsRepo
installOracleJdk
installPostgres
Expand Down
50 changes: 32 additions & 18 deletions bootstrap-debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,37 @@ usage() {
echo "-h: Show this help"
}

checkRequirements() {
# Test if system is supported
uname -a | grep -E "${REQUIRED_SYSTEMS}" 1>/dev/null 2>>"${ERROR_LOG}"
if [ ! "${?}" -eq 0 ]; then
echo ""
echo "This is system is not a supported Ubuntu or Debian system."
echo ""
exit ${E_UNSUPPORTED}
fi

# Setting Postgres User and changing configuration files require
# root permissions.
if [ "${USER}" != "${REQUIRED_USER}" ]; then
echo ""
echo "This script requires root permissions to be executed."
echo ""
exit ${E_BASH}
fi

# The sudo command is required to switch to postgres user for DB setup
echo -n "Path to sudo: ">>${ERROR_LOG}
which sudo 1>>${ERROR_LOG} 2>>${ERROR_LOG}
if [ ! "${?}" -eq "0" ]; then
echo ""
echo "This script requires sudo which could not be found."
echo "Please install the sudo package."
echo ""
exit ${E_BASH}
fi
}

showDisclaimer() {
echo ""
echo "This script installs OpenNMS on your system. It will"
Expand Down Expand Up @@ -77,24 +108,6 @@ showDisclaimer() {
shopt -u nocasematch
}

# Test if system is supported
uname -a | grep -E "${REQUIRED_SYSTEMS}" 1>/dev/null 2>>"${ERROR_LOG}"
if [ ! "${?}" -eq 0 ]; then
echo ""
echo "This is system is not a supported Ubuntu or Debian system."
echo ""
exit ${E_UNSUPPORTED}
fi

# Setting Postgres User and changing configuration files require
# root permissions.
if [ "${USER}" != "${REQUIRED_USER}" ]; then
echo ""
echo "This script requires root permissions to be executed."
echo ""
exit ${E_BASH}
fi

####
# The -r option is optional and allows to set the release of OpenNMS.
# The -m option allows to overwrite the package repository server.
Expand Down Expand Up @@ -258,6 +271,7 @@ lockdownDbUser() {

# Execute setup procedure
clear
checkRequirements
showDisclaimer
installOnmsRepo
installPostgres
Expand Down
50 changes: 32 additions & 18 deletions bootstrap-yum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,37 @@ usage() {
echo "-h: Show this help"
}

checkRequirements() {
# Test if system is supported
cat ${RELEASE_FILE} | grep -E ${REQUIRED_SYSTEMS} 1>/dev/null 2>>${ERROR_LOG}
if [ ! ${?} -eq 0 ]; then
echo ""
echo "This is system is not a supported CentOS or Red Hat."
echo ""
exit ${E_UNSUPPORTED}
fi

# Setting Postgres User and changing configuration files require
# root permissions.
if [ "${USER}" != "${REQUIRED_USER}" ]; then
echo ""
echo "This script requires root permissions to be executed."
echo ""
exit ${E_BASH}
fi

# The sudo command is required to switch to postgres user for DB setup
echo -n "Path to sudo: ">>${ERROR_LOG}
which sudo 1>>${ERROR_LOG} 2>>${ERROR_LOG}
if [ ! "${?}" -eq "0" ]; then
echo ""
echo "This script requires sudo which could not be found."
echo "Please install the sudo package."
echo ""
exit ${E_BASH}
fi
}

showDisclaimer() {
echo ""
echo "This script installs OpenNMS on your system. It will"
Expand Down Expand Up @@ -78,24 +109,6 @@ showDisclaimer() {
shopt -u nocasematch
}

# Test if system is supported
cat ${RELEASE_FILE} | grep -E ${REQUIRED_SYSTEMS} 1>/dev/null 2>>${ERROR_LOG}
if [ ! ${?} -eq 0 ]; then
echo ""
echo "This is system is not a supported CentOS or Red Hat."
echo ""
exit ${E_UNSUPPORTED}
fi

# Setting Postgres User and changing configuration files require
# root permissions.
if [ "${USER}" != "${REQUIRED_USER}" ]; then
echo ""
echo "This script requires root permissions to be executed."
echo ""
exit ${E_BASH}
fi

####
# The -r option is optional and allows to set the release of OpenNMS.
# The -m option allows to overwrite the package repository server.
Expand Down Expand Up @@ -247,6 +260,7 @@ restartOnms() {

# Execute setup procedure
clear
checkRequirements
showDisclaimer
installOnmsRepo
installOnmsApp
Expand Down

0 comments on commit 094a80c

Please sign in to comment.