From f2765bd773b21b86797e70f8b81a75531cfd4826 Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Mon, 2 Dec 2019 10:48:41 -0800 Subject: [PATCH] format code --- cookbooks/mount-hd/recipes/install.bash | 7 ++++++- cookbooks/ps1/recipes/install.bash | 16 ++++++++++++++-- cookbooks/redis/recipes/install.bash | 9 ++++++++- cookbooks/ssh/recipes/install.bash | 8 +++++++- .../tweaks/recipes/disable-icmp-timestamp.bash | 9 ++++++++- .../tweaks/recipes/disable-tcp-timestamp.bash | 9 ++++++++- cookbooks/vim/recipes/install.bash | 17 +++++++++++++++-- roles/nam/libraries/app.bash | 16 ++++++++++++++-- 8 files changed, 80 insertions(+), 11 deletions(-) diff --git a/cookbooks/mount-hd/recipes/install.bash b/cookbooks/mount-hd/recipes/install.bash index e29e2ccd..5c46aeab 100755 --- a/cookbooks/mount-hd/recipes/install.bash +++ b/cookbooks/mount-hd/recipes/install.bash @@ -40,7 +40,12 @@ function install() local -r fstabConfig="${newDisk} ${mountOn} ${MOUNT_HD_FS_TYPE} ${MOUNT_HD_MOUNT_OPTIONS} ${MOUNT_HD_DUMP} ${MOUNT_HD_FSCK_OPTION}" - appendToFileIfNotFound '/etc/fstab' "$(stringToSearchPattern "${fstabConfig}")" "${fstabConfig}" 'true' 'false' 'true' + appendToFileIfNotFound \ + '/etc/fstab' \ + "$(stringToSearchPattern "${fstabConfig}")" "${fstabConfig}" \ + 'true' \ + 'false' \ + 'true' # Display File System diff --git a/cookbooks/ps1/recipes/install.bash b/cookbooks/ps1/recipes/install.bash index fb106d5d..8c47892f 100755 --- a/cookbooks/ps1/recipes/install.bash +++ b/cookbooks/ps1/recipes/install.bash @@ -94,7 +94,13 @@ function install() fi fi - appendToFileIfNotFound "${profileFilePath}" "${prompt}" "${prompt}" 'false' 'false' 'true' + appendToFileIfNotFound \ + "${profileFilePath}" \ + "${prompt}" \ + "${prompt}" \ + 'false' \ + 'false' \ + 'true' else warn "WARN : profile '${user}' not found" fi @@ -113,7 +119,13 @@ function install() echo -e "Updating '\033[1;32m${defaultProfileFilePath}\033[0m'" - appendToFileIfNotFound "${defaultProfileFilePath}" "${defaultPrompt}" "${defaultPrompt}" 'false' 'false' 'true' + appendToFileIfNotFound \ + "${defaultProfileFilePath}" \ + "${defaultPrompt}" \ + "${defaultPrompt}" \ + 'false' \ + 'false' \ + 'true' umask '0077' } diff --git a/cookbooks/redis/recipes/install.bash b/cookbooks/redis/recipes/install.bash index 70898972..9a6c1a3a 100755 --- a/cookbooks/redis/recipes/install.bash +++ b/cookbooks/redis/recipes/install.bash @@ -57,7 +57,14 @@ function install() local -r overCommitMemoryConfig="vm.overcommit_memory = ${REDIS_VM_OVER_COMMIT_MEMORY}" - appendToFileIfNotFound '/etc/sysctl.conf' "$(stringToSearchPattern "${overCommitMemoryConfig}")" "\n${overCommitMemoryConfig}" 'true' 'true' 'true' + appendToFileIfNotFound \ + '/etc/sysctl.conf' \ + "$(stringToSearchPattern "${overCommitMemoryConfig}")" \ + "\n${overCommitMemoryConfig}" \ + 'true' \ + 'true' \ + 'true' + sysctl "$(deleteSpaces "${overCommitMemoryConfig}")" # Start diff --git a/cookbooks/ssh/recipes/install.bash b/cookbooks/ssh/recipes/install.bash index e196c65c..bb378de6 100755 --- a/cookbooks/ssh/recipes/install.bash +++ b/cookbooks/ssh/recipes/install.bash @@ -22,7 +22,13 @@ function install() <<< "$(cat '/etc/ssh/sshd_config')" \ > '/etc/ssh/sshd_config' || true - appendToFileIfNotFound '/etc/ssh/sshd_config' "$(stringToSearchPattern "${config}")" "${config}" 'true' 'false' 'true' + appendToFileIfNotFound \ + '/etc/ssh/sshd_config' \ + "$(stringToSearchPattern "${config}")" \ + "${config}" \ + 'true' \ + 'false' \ + 'true' grep -F "${config}" '/etc/ssh/sshd_config' | grep -v '^\s*#' done diff --git a/cookbooks/tweaks/recipes/disable-icmp-timestamp.bash b/cookbooks/tweaks/recipes/disable-icmp-timestamp.bash index 83474d3e..65c46e0a 100755 --- a/cookbooks/tweaks/recipes/disable-icmp-timestamp.bash +++ b/cookbooks/tweaks/recipes/disable-icmp-timestamp.bash @@ -4,7 +4,14 @@ function install() { umask '0022' - appendToFileIfNotFound '/etc/sysctl.conf' 'net.ipv4.icmp_echo_ignore_all = 1' 'net.ipv4.icmp_echo_ignore_all = 1' 'false' 'false' 'true' + appendToFileIfNotFound \ + '/etc/sysctl.conf' \ + 'net.ipv4.icmp_echo_ignore_all = 1' \ + 'net.ipv4.icmp_echo_ignore_all = 1' \ + 'false' \ + 'false' \ + 'true' + cat '/etc/sysctl.conf' umask '0077' diff --git a/cookbooks/tweaks/recipes/disable-tcp-timestamp.bash b/cookbooks/tweaks/recipes/disable-tcp-timestamp.bash index 9b790eb4..275388eb 100755 --- a/cookbooks/tweaks/recipes/disable-tcp-timestamp.bash +++ b/cookbooks/tweaks/recipes/disable-tcp-timestamp.bash @@ -4,7 +4,14 @@ function install() { umask '0022' - appendToFileIfNotFound '/etc/sysctl.conf' 'net.ipv4.tcp_timestamps = 0' 'net.ipv4.tcp_timestamps = 0' 'false' 'false' 'true' + appendToFileIfNotFound \ + '/etc/sysctl.conf' \ + 'net.ipv4.tcp_timestamps = 0' \ + 'net.ipv4.tcp_timestamps = 0' \ + 'false' \ + 'false' \ + 'true' + cat '/etc/sysctl.conf' umask '0077' diff --git a/cookbooks/vim/recipes/install.bash b/cookbooks/vim/recipes/install.bash index a011c91b..4b1b5647 100755 --- a/cookbooks/vim/recipes/install.bash +++ b/cookbooks/vim/recipes/install.bash @@ -12,8 +12,21 @@ function install() if [[ "$(isAmazonLinuxDistributor)" = 'true' || "$(isCentOSDistributor)" = 'true' || "$(isRedHatDistributor)" = 'true' ]] then - appendToFileIfNotFound '/etc/profile' 'alias vi=vim' 'alias vi=vim' 'false' 'false' 'true' - appendToFileIfNotFound '/etc/vimrc' 'source /etc/vim/vimrc.local' 'source /etc/vim/vimrc.local' 'false' 'false' 'true' + appendToFileIfNotFound \ + '/etc/profile' \ + 'alias vi=vim' \ + 'alias vi=vim' \ + 'false' \ + 'false' \ + 'true' + + appendToFileIfNotFound \ + '/etc/vimrc' \ + 'source /etc/vim/vimrc.local' \ + 'source /etc/vim/vimrc.local' \ + 'false' \ + 'false' \ + 'true' fi umask '0077' diff --git a/roles/nam/libraries/app.bash b/roles/nam/libraries/app.bash index 60c253e1..b40c6bf3 100755 --- a/roles/nam/libraries/app.bash +++ b/roles/nam/libraries/app.bash @@ -11,7 +11,13 @@ function autoSudo() local -r command='sudo su -l' - appendToFileIfNotFound "$(getUserHomeFolder "${userLogin}")/${profileFileName}" "${command}" "${command}" 'false' 'false' 'true' + appendToFileIfNotFound \ + "$(getUserHomeFolder "${userLogin}")/${profileFileName}" \ + "${command}" \ + "${command}" \ + 'false' \ + 'false' \ + 'true' } function setupRepository() @@ -40,5 +46,11 @@ function updateRepositoryOnLogin() local -r command='cd /opt/linux-cookbooks/cookbooks && git pull' - appendToFileIfNotFound "$(getProfileFilePath "${userLogin}")" "${command}" "${command}" 'false' 'false' 'true' + appendToFileIfNotFound \ + "$(getProfileFilePath "${userLogin}")" \ + "${command}" \ + "${command}" \ + 'false' \ + 'false' \ + 'true' } \ No newline at end of file