2024-09-23 02:44:39 +08:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
2024-11-18 23:12:52 +08:00
|
|
|
|
declare docker_compose_path="$1"
|
2024-09-23 02:44:39 +08:00
|
|
|
|
if ! command -v docker &> /dev/null; then
|
2024-11-18 23:12:52 +08:00
|
|
|
|
echo "未安装 Docker"
|
2024-09-23 02:44:39 +08:00
|
|
|
|
exit
|
|
|
|
|
fi
|
2024-09-23 16:47:48 +08:00
|
|
|
|
|
2024-11-18 23:12:52 +08:00
|
|
|
|
declare data_directory
|
|
|
|
|
read -p "请输入数据目录,默认 /var/www :" data_directory
|
|
|
|
|
if [[ -z ${data_directory} ]];then
|
|
|
|
|
data_directory='/var/www'
|
2024-09-23 02:44:39 +08:00
|
|
|
|
fi
|
2024-11-18 23:12:52 +08:00
|
|
|
|
cat > "${docker_compose_path}/up-docker_compose.sh" << EOF
|
2024-09-23 02:44:39 +08:00
|
|
|
|
#!/bin/bash
|
2024-11-18 23:12:52 +08:00
|
|
|
|
for dir in "${data_directory}"/*/; do
|
2024-09-23 02:44:39 +08:00
|
|
|
|
cd "\$dir" || exit
|
|
|
|
|
sudo docker compose pull
|
|
|
|
|
sudo docker compose up -d
|
|
|
|
|
done
|
|
|
|
|
EOF
|