linuxtool/Config/Automation/up-docker_compose.sh

23 lines
522 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
declare path="$1"
if ! command -v docker &> /dev/null; then
echo "docker未安装"
exit
fi
if [[ -f "${path}/up-docker_compose.sh" ]];then
echo "该路径文件已经存在"
fi
declare web_path
read -p "请输入数据目录,默认 /var/www " web_path
if [[ -z ${web_path} ]];then
web_path='/var/www'
fi
cat > "${path}/up-docker_compose.sh" << EOF
#!/bin/bash
for dir in "${web_path}"/*/; do
cd "\$dir" || exit
sudo docker compose pull
sudo docker compose up -d
done
EOF