Skip to content

Commit

Permalink
v3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ojullien committed Jul 5, 2019
1 parent cd14f39 commit 291afc3
Show file tree
Hide file tree
Showing 37 changed files with 92 additions and 3,486 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.vscode/
desktop.ini
local.*
*.fr.conf
*.com.conf
*.org.conf
/src/bin/ca/
4 changes: 0 additions & 4 deletions src/app/.gitignore

This file was deleted.

14 changes: 14 additions & 0 deletions src/app/manageservices/app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## -----------------------------------------------------------------------------
## Linux Scripts.
## Services manager App functions
##
## @package ojullien\bash\app\manageservices
## @license MIT <https://github.com/ojullien/bash-manageservices/blob/master/LICENSE>
## -----------------------------------------------------------------------------

ManageServices::showHelp() {
String::notice "Usage: $(basename "$0") <disable | start | stop>"
String::notice "\tDisable, start or stop a list of services defined in the config.sh file"
Option::showHelp
return 0
}
26 changes: 26 additions & 0 deletions src/app/manageservices/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## -----------------------------------------------------------------------------
## Linux Scripts.
## Services manager app configuration file.
##
## @package ojullien\bash\app\manageservices
## @license MIT <https://github.com/ojullien/bash-manageservices/blob/master/LICENSE>
## -----------------------------------------------------------------------------

readonly m_SERVICES_DISABLE="bind9 exim4 postfix smbd nmbd telnet rlogin rexec ftp automount named lpd inetd"
readonly m_SERVICES_STOP="apache2 fail2ban php7.3-fpm php7.2-fpm mysql"
readonly m_SERVICES_START="mysql php7.3-fpm php7.2-fpm apache2 fail2ban"

## -----------------------------------------------------------------------------
## Trace
## -----------------------------------------------------------------------------
ManageServices::trace() {
String::separateLine
String::notice "App configuration: ManageServices"
String::notice "\tServices to disable:"
String::notice "\t\t${m_SERVICES_DISABLE}"
String::notice "\tServices to stop:"
String::notice "\t\t${m_SERVICES_STOP}"
String::notice "\tServices to start:"
String::notice "\t\t${m_SERVICES_START}"
return 0
}
4 changes: 0 additions & 4 deletions src/bin/.gitignore

This file was deleted.

72 changes: 52 additions & 20 deletions tests/sys-serviced_test.sh → src/bin/manageservices.sh
Original file line number Diff line number Diff line change
@@ -1,66 +1,98 @@
#!/bin/bash
## -----------------------------------------------------------------------------
## Linux Scripts.
## Run sys\serviceD tests
## Stop services.
##
## @package ojullien\bash\tests
## @license MIT <https://github.com/ojullien/bash-sys/blob/master/LICENSE>
## @package ojullien\bash\bin\manageservices
## @license MIT <https://github.com/ojullien/bash-manageservices/blob/master/LICENSE>
## -----------------------------------------------------------------------------

#set -o errexit
set -o nounset
set -o pipefail

if [[ ${BASH_VERSINFO[0]} -lt 4 ]]; then
echo "At least Bash version 4 is needed!" >&2
exit 4
fi

## -----------------------------------------------------------------------------
## Shell scripts directory, eg: /root/work/Shell/tests
## Shell scripts directory, eg: /root/work/Shell/src/bin
## -----------------------------------------------------------------------------
readonly m_DIR_REALPATH="$(realpath "$(dirname "$0")")"

## -----------------------------------------------------------------------------
## Load constants
## -----------------------------------------------------------------------------
# shellcheck source=/dev/null
. "${m_DIR_REALPATH}/framework/constant.sh"
. "${m_DIR_REALPATH}/../sys/constant.sh"

## -----------------------------------------------------------------------------
## Includes sources
## Includes sources & configuration
## -----------------------------------------------------------------------------
# shellcheck source=/dev/null
. "${m_DIR_SYS}/runasroot.sh"
# shellcheck source=/dev/null
. "${m_DIR_SYS}/string.sh"
# shellcheck source=/dev/null
. "${m_DIR_SYS}/filesystem.sh"
# shellcheck source=/dev/null
. "${m_DIR_SYS}/option.sh"
# shellcheck source=/dev/null
. "${m_DIR_REALPATH}/framework/library.sh"
. "${m_DIR_SYS}/config.sh"
# shellcheck source=/dev/null
. "${m_DIR_SYS}/system/d.sh"
. "${m_DIR_SYS}/service.sh"
Config::load "manageservices"
# shellcheck source=/dev/null
. "${m_DIR_APP}/manageservices/app.sh"

## -----------------------------------------------------------------------------
## Help
## -----------------------------------------------------------------------------
((m_OPTION_SHOWHELP)) && ManageServices::showHelp && exit 0

## -----------------------------------------------------------------------------
## Trace
## -----------------------------------------------------------------------------
Test::Constant::trace
Constant::trace
ManageServices::trace

## -----------------------------------------------------------------------------
## Start
## -----------------------------------------------------------------------------

String::separateLine
String::notice "Today is: $(date -R)"
String::notice "The PID for $(basename "$0") process is: $$"
Console::waitUser

# shellcheck source=/dev/null
. "${m_TEST_DIR_SYS}/system/d_test.sh"
Test::serviced::main
Console::waitUser
## -----------------------------------------------------------------------------
## Parse the app options and arguments
## -----------------------------------------------------------------------------
declare -i iReturn=1

if (( "$#" )); then
case "$1" in
stop)
String::separateLine
Service::stopServices ${m_SERVICES_STOP}
iReturn=$?
;;
start)
String::separateLine
Service::startServices ${m_SERVICES_START}
iReturn=$?
;;
disable)
String::separateLine
Service::disableServices ${m_SERVICES_DISABLE}
iReturn=$?
;;
*) # unknown option
String::separateLine
ManageServices::showHelp
;;
esac
else
String::separateLine
ManageServices::showHelp
fi

## -----------------------------------------------------------------------------
## END
## -----------------------------------------------------------------------------
String::notice "Now is: $(date -R)"
exit ${iReturn}
12 changes: 0 additions & 12 deletions src/sys/bashversion.sh

This file was deleted.

45 changes: 0 additions & 45 deletions src/sys/config.sh

This file was deleted.

50 changes: 0 additions & 50 deletions src/sys/constant.sh

This file was deleted.

Loading

0 comments on commit 291afc3

Please sign in to comment.