23 lines
522 B
Bash
23 lines
522 B
Bash
|
#!/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
|