I've like 10 repos running in the same machine, I some times change machines and want to deploy them automatically and fast so I made this script to execute each repo installation file at the same time two repos by two
#!/bin/bashecho "Staring temp runner"script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"temp_scripts_folder="$script_dir/temp"mapfile -t scripts < <(find "$temp_scripts_folder" -maxdepth 1 -type f -name "*.sh")for ((i = 0; i < ${#scripts[@]}; i+=2)); do script1="${scripts[i]}" script2="${scripts[i+1]}" if [[ -n $script2 ]]; then echo "Script 1: $script1 and Script 2: $script2" echo "execution $script1" echo "logs are $script1.logs" sudo chmod +x "$script1" && "$script1" >> "$script1.logs" & echo "logs are $script2.logs" echo "execution $script2" sudo chmod +x "$script2" && "$script2" >> "$script2.logs" & else if [ -f "$script1" ]; then echo "Only one file is found: $script1" # Execute the script echo "execution $script1" sudo chmod +x "$script1" && "$script1" & else echo "File does not exist: $script1" fi fidone
it runs multiple bash script files at the same time, all of them work fine but only two files don't work properly and IDK why
here's the content of the failed file
#!/bin/bashcd /home/ubuntusudo mkdir -p {baseFolderName}cd {baseFolderName}if [ -d "RepoFolder" ]; then cd /home/ubuntu/{baseFolderName}/RepoFolder sudo git checkout dev sudo git pull origin develse sudo git clone {url} cd /home/ubuntu/{baseFolderName}/RepoFolder sudo git checkout dev sudo rm -rf src/subModule sudo git rm --cached src/subModule sudo git submodule add {url} src/sh>ficd /home/ubuntu/{baseFolderName}/RepoFolder/src/subModulesudo git checkout mainsudo git pull origin maincd /home/ubuntu/{baseFolderName}/RepoFoldersudo rm -rf nginx/logssudo docker compose -f docker-compose-dev.yml build app --no-cachesudo docker compose -f docker-compose-dev.yml down -vsudo docker compose -f docker-compose-dev.yml up -dsudo docker system prune -fsudo docker volume prune -fsudo docker image prune -fsudo docker container prune -fsudo docker network prune -f
the docker compose up -d does not work at all and not prints anything like it was never there
what I get in logs:
Your branch is up to date with 'origin/dev'.Already up to date.Your branch is up to date with 'origin/main'.Already up to date.Total reclaimed space: 0BTotal reclaimed space: 0BTotal reclaimed space: 0BTotal reclaimed space: 0B