Skip to content

Commit

Permalink
fix : finalize Mac module
Browse files Browse the repository at this point in the history
  • Loading branch information
patternhelloworld committed Oct 18, 2024
1 parent 57abd64 commit 706fbe9
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 61 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Deploying web projects should be [simple, with high availability and security](h
- If you are using WSL2 in WIN10 (not WIN11), which has the CRLF issue, you should run `bash prevent-crlf.sh` twice, and then execute the required `.sh` file.
- The error message you might encounter is `$'\r': command not found`.
- When using WSL2, I recommend cloning the project into the WSL area (`\\wsl$\Ubuntu\home`) instead of `C:\`.
- Available on macOS as long as GNU-based libraries are installed
- Available on MacOS as long as GNU-based libraries are installed. See the 'Dependencies' section for more details.
- **Summary**: Linux is more stable than WSL2, and WSL2 is not recommended for production environments.


Expand Down
4 changes: 2 additions & 2 deletions activate.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -e
sudo sed -i -e "s/\r$//g" $(basename $0)
# This is a private shell script. Do NOT use this directly.
set -eu

source ./util.sh
source ./use-app.sh
Expand Down
14 changes: 6 additions & 8 deletions apply-security.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#!/usr/bin/env bash
sudo sed -i -e "s/\r$//g" $(basename $0)
echo "[NOTICE] To prevent CRLF errors in scripts based on the Windows operating system, currently performing CRLF to LF conversion."
bash prevent-crlf.sh
git config apply.whitespace nowarn
git config core.filemode false
#!/bin/bash
set -eu

source ./util.sh
check_bash_version
check_gnu_grep_installed
check_gnu_sed_installed
check_git_docker_compose_commands_exist

cache_global_vars

set -e

set_safe_filemode_on_app() {
for volume in "${docker_compose_real_selective_volumes[@]}"; do
local local_path="${volume%%:*}"
Expand Down
11 changes: 6 additions & 5 deletions check-current-states.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash
sed -i -e "s/\r$//g" $(basename $0)
set -e

git config apply.whitespace nowarn
git config core.filemode false
set -eu

source ./util.sh
check_bash_version
check_gnu_grep_installed
check_gnu_sed_installed
check_git_docker_compose_commands_exist


cache_global_vars
11 changes: 7 additions & 4 deletions check-source-integrity.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#!/bin/bash
sed -i -e "s/\r$//g" $(basename $0)
set -e
set -eu

source ./util.sh
check_bash_version
check_gnu_grep_installed
check_gnu_sed_installed
check_git_docker_compose_commands_exist

git config apply.whitespace nowarn
git config core.filemode false

source ./util.sh

result=$(check_git_status)

if [ "$result" == "true" ]; then
Expand Down
2 changes: 1 addition & 1 deletion emergency-nginx-down-and-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ bash prevent-crlf.sh
git config apply.whitespace nowarn
git config core.filemode false

sleep 3
sleep 2

source ./use-nginx.sh

Expand Down
12 changes: 8 additions & 4 deletions remove-all-images.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/bash
sudo sed -i -e "s/\r$//g" $(basename $0)
set -e
set -eu

source ./util.sh
check_bash_version
check_gnu_grep_installed
check_gnu_sed_installed
check_git_docker_compose_commands_exist

git config apply.whitespace nowarn
git config core.filemode false
Expand All @@ -10,8 +15,7 @@ bash prevent-crlf.sh
git config apply.whitespace nowarn
git config core.filemode false

sleep 3
source ./util.sh
sleep 2

cache_non_dependent_global_vars

Expand Down
12 changes: 2 additions & 10 deletions reset.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#!/usr/bin/env bash
sudo sed -i -e "s/\r$//g" $(basename $0)
echo "[NOTICE] To prevent CRLF errors in scripts based on the Windows operating system, currently performing CRLF to LF conversion."
bash prevent-crlf.sh

set -e

#!/bin/bash
# This is a private shell script. Do NOT use this directly.
source ./util.sh

app_env=$(get_value_from_env "APP_ENV")
Expand All @@ -22,9 +17,6 @@ docker exec ${project_name}-nginx curl -X PUT -d ${state} ${consul_key_value_sto
docker exec ${project_name}-nginx sh -c 'service nginx reload || service nginx restart || [EMERGENCY] Nginx Contingency Plan failed as well. Correct /etc/nginx/conf.d/nginx.conf directly and Run "service nginx restart".'
}




echo "[NOTICE] Stopping the ${new_state} ${orchestration_type}"
if [[ ${orchestration_type} != 'stack' ]]; then
docker-compose -f docker-${orchestration_type}-${project_name}-${app_env}.yml stop ${project_name}-${new_state}
Expand Down
14 changes: 11 additions & 3 deletions rollback.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#!/usr/bin/env bash
#!/bin/bash
set -eu

source ./util.sh
check_bash_version
check_gnu_grep_installed
check_gnu_sed_installed
check_git_docker_compose_commands_exist

sudo sed -i -e "s/\r$//g" $(basename $0)
set -e

echo "[NOTICE] To prevent CRLF errors in scripts based on the Windows operating system, currently performing CRLF to LF conversion."
sudo bash prevent-crlf.sh
git config apply.whitespace nowarn || echo "[WARN] A supporting command 'git config apply.whitespace nowarn' has NOT been run."
git config core.filemode false || echo "[WARN] A supporting command 'git config core.filemode false' has NOT been run."

source ./util.sh

source ./use-app.sh

check_git_docker_compose_commands_exist
Expand Down
2 changes: 2 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
# set -e: This option tells the script to exit immediately if any command returns a non-zero status (i.e., if a command fails). This prevents the script from continuing execution when an error occurs, making it easier to catch issues early.
# set -u: This option causes the script to throw an error and stop if it tries to use an undefined variable. This helps catch typos or missing variable definitions that could lead to unexpected behavior.
set -eu

source ./util.sh
Expand Down
5 changes: 5 additions & 0 deletions set-safe-permissions.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/bash
set -eu

source ./util.sh
check_gnu_sed_installed

sudo sed -i -e "s/\r$//g" $(basename $0) || sed -i -e "s/\r$//g" $(basename $0)
sudo chmod 770 *
sudo chmod 770 .env.*
Expand Down
10 changes: 7 additions & 3 deletions stop-all-containers.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/bash
source ./util.sh
check_bash_version
check_gnu_grep_installed
check_gnu_sed_installed
check_git_docker_compose_commands_exist

sudo sed -i -e "s/\r$//g" $(basename $0)
set -e

git config apply.whitespace nowarn
git config core.filemode false
Expand All @@ -10,8 +15,7 @@ bash prevent-crlf.sh
git config apply.whitespace nowarn
git config core.filemode false

sleep 3
source ./util.sh
sleep 2

cache_non_dependent_global_vars

Expand Down
38 changes: 18 additions & 20 deletions util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ cache_global_vars() {

}


check_yq_installed(){
required_version="4.35.1"

Expand Down Expand Up @@ -446,6 +445,24 @@ check_bash_version() {
fi
}

check_git_docker_compose_commands_exist(){

command -v git >/dev/null 2>&1 ||
{ echo >&2 "[ERROR] git NOT installed. Exiting...";
exit 1
}

if ! docker info > /dev/null 2>&1; then
echo "[ERROR] docker is NOT run. Exiting..."
exit 1
fi

if ! docker-compose --version > /dev/null 2>&1; then
echo "[ERROR] docker-compose is NOT installed. Exiting..."
exit 1
fi
}

get_value_from_env(){

if [ ! -f ".env" ]; then
Expand Down Expand Up @@ -543,25 +560,6 @@ concat_safe_port() {
}




check_git_docker_compose_commands_exist(){

command -v git >/dev/null 2>&1 ||
{ echo >&2 "[ERROR] git NOT installed. Exiting...";
exit 1
}

if ! docker info > /dev/null 2>&1; then
echo "[ERROR] docker is NOT run. Exiting..."
exit 1
fi

if ! docker-compose --version > /dev/null 2>&1; then
echo "[ERROR] docker-compose is NOT installed. Exiting..."
exit 1
fi
}
check_command_in_container_or_fail(){
# 컨테이너 이름 또는 ID
CONTAINER_NAME=${1}
Expand Down

0 comments on commit 706fbe9

Please sign in to comment.