generated from ojullien/bash-sys
-
Notifications
You must be signed in to change notification settings - Fork 0
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
37 changed files
with
92 additions
and
3,486 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
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/ |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -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 | ||
} |
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 |
---|---|---|
@@ -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 | ||
} |
This file was deleted.
Oops, something went wrong.
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,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} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.