Step help as own function within step definition script

fixes #1
This commit is contained in:
2019-04-05 12:06:47 +01:00
parent bfccac6b28
commit 17eaeee234
4 changed files with 107 additions and 120 deletions

View File

@@ -4,31 +4,32 @@
## Installation and maintenance for LibreNMS
## Using buster repositories for php 7.3 installation
toolName="LibreNMS"
librePhpDeps="composer php-cli-prompt php-composer-ca-bundle php-composer-semver php-composer-spdx-licenses php-json-schema php-psr-log php-symfony-console php-symfony-filesystem php-symfony-finder php-symfony-polyfill-mbstring php-symfony-process"
librePackages="fping git graphviz imagemagick mtr-tiny nmap python-memcache python-mysqldb rrdtool snmp snmpd whoisi nagios-plugins"
function step_1 {
echo -e "Updating apt\n"
#apt update
step_1_info() { echo "Updating apt"; }
step_1() {
apt update
}
function step_2 {
echo -e "Installing: $librePackages\n"
step_2_info() { echo -e "Installing $toolname dependencies: $librePackages\n"; }
step_2() {
apt install $librePackages
saveReturn $?
endReturn
}
function step_3 {
echo -e "Installing -t buster PHP related packages\n$librePhpDeps\n"
step_3_info() { echo -e "Installing -t buster PHP related packages\n$librePhpDeps\n"; }
step_3() {
apt -t buster install $librePhpDeps
saveReturn $?
endReturn
}
function step_4 {
echo -e "Adding librenms user"
step_4_info() { echo "Adding $toolName user (librenms:librenms)"; }
step_4() {
useradd librenms -d /opt/librenms -M -r
saveReturn $?
usermod -a -G librenms www-data
@@ -36,20 +37,20 @@ function step_4 {
endReturn
}
function step_5 {
echo -e "Installing librenms using composer"
step_5_info() { echo "Installing $toolName using composer"; }
step_5() {
cd /opt
composer create-project --no-dev --keep-vcs librenms/librenms librenms dev-master
saveReturn $?
endReturn
}
function step_10 {
step_10_info() { echo "Create mysql database for $toolName"; }
step_10() {
local mysqlDatabase
local mysqlUser
local mysqlPass
echo "Setup mysql database"
echo "Existing mysql databases:"
mysql -u root -e 'SHOW DATABASES;'
@@ -80,8 +81,9 @@ function step_10 {
mysql -u root -e 'FLUSH PRIVILEGES;'
}
function step_11 {
echo "MariaDB configuration"
step_11_info() { echo "MariaDB configuration"; }
step_11() {
echo
echo "Edit or create /etc/mysql/mariadb.conf.d/90-myconfig.cnf and add:"
echo
echo "------------------------"
@@ -94,8 +96,9 @@ function step_11 {
echo "service mysql restart"
}
function step_12 {
echo "PHP fpm/cli configuration"
step_12_info() { echo "PHP fpm/cli configuration"; }
step_12() {
echo
echo "Ensure date.timezone is set in php.ini to your preferred time zone. See http://php.net/manual/en/timezones.php for a list of supported timezones. Valid examples are: \"America/New_York\", \"Europe/Berlin\", \"Etc/UTC\"."
echo
echo "vi /etc/php/7.3/fpm/conf.d/90-custom_pi.ini"
@@ -109,8 +112,8 @@ function step_12 {
echo "service php7.3-fpm restart"
}
function step_40 {
echo "Switch Librenms installation to monthly stable"
step_40_info() { echo "Switch $toolName installation to monthly stable"; }
step_40() {
echo
echo "Add following to /opt/librenms/config.php"
echo
@@ -122,31 +125,12 @@ function step_40 {
echo "cd /opt/librenms && git fetch --tags && git checkout \$(git describe --tags \$(git rev-list --tags --max-count=1))"
}
function step_42 {
echo "Fix librenms permission"
step_42_info() { echo "Fix librenms permission"; }
step_42() {
chown -R librenms:librenms /opt/librenms
setfacl -d -m g::rwx /opt/librenms/bootstrap/cache /opt/librenms/storage /opt/librenms/logs /opt/librenms/rrd
chmod -R ug=rwX /opt/librenms/bootstrap/cache /opt/librenms/storage /opt/librenms/logs /opt/librenms/rrd
}
help() {
echo " Step Documentation"
echo " 1: Updating apt"
echo -e " 2: Install packages:\n\t$librePackages"
echo -e " 3: Installing -t buster PHP related packages:\n\t$librePhpDeps"
echo " 4: Adding librenms user"
echo " 5: Installing librenms using composer"
echo
echo " 10: Setup mysql database"
echo " 11: MariaDB configuration"
echo " 12: PHP fpm/cli configuration"
echo
echo " 40: Switch Librenms installation to monthly stable"
echo " 42: Fix librenms permission"
}
#
## Path to sequencer
# Path to sequencer
. ../sequencer/sequencer.sh