Skip to content

Commit 86fbf5c

Browse files
增加部署完成自动启动选项 (#54)
* 增加部署完成自动启动选项 * feata(初始化):更新数据初始化数据的翻译 --------- Co-authored-by: TranscodeGroupDeveloper <transcodegroupdeveloper@gmail.com>
1 parent df43e6d commit 86fbf5c

File tree

2 files changed

+46
-8
lines changed

2 files changed

+46
-8
lines changed

mysql8/initdb/02-maintain-init-data.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ SET FOREIGN_KEY_CHECKS = 0;
2424
-- ----------------------------
2525
-- Records of user_info
2626
-- ----------------------------
27-
INSERT INTO `user_info` VALUES (1, 'dca0f9e348384d23958e151bb4adb98f', '系统管理员', 'sysadmin', '{bcrypt-md5}$2a$10$dsfVEzh5NlfrgkcLFbrPLOuSsm5zJMJJwYqlQfTSWs3qKzwhQx5Ku', '', NULL, NULL, '+08:00', NULL, 0, 0, 100, 0, '', '系统账号', '2025-04-29 09:27:50', NULL, NULL, '2025-04-29 03:46:24', 0, NULL, '', 0, '2025-04-29 03:46:24', '2025-04-29 09:28:57');
28-
INSERT INTO `user_info` VALUES (2, '25d19d8c917747ea', '组织管理员', 'tgadmin', '{bcrypt-md5}$2a$10$dsfVEzh5NlfrgkcLFbrPLOuSsm5zJMJJwYqlQfTSWs3qKzwhQx5Ku', '', NULL, NULL, '+08:00', NULL, 0, 0, 1, 0, '', NULL, '2025-04-30 08:04:22', NULL, NULL, '2025-04-30 07:35:32', 0, 110, '', 0, '2025-04-30 07:35:32', '2025-04-30 08:22:00');
27+
INSERT INTO `user_info` VALUES (1, 'dca0f9e348384d23958e151bb4adb98f', 'sysadmin', 'sysadmin', '{bcrypt-md5}$2a$10$dsfVEzh5NlfrgkcLFbrPLOuSsm5zJMJJwYqlQfTSWs3qKzwhQx5Ku', '', NULL, NULL, '+08:00', NULL, 0, 0, 100, 0, '', '系统账号', '2025-04-29 09:27:50', NULL, NULL, '2025-04-29 03:46:24', 0, NULL, '', 0, '2025-04-29 03:46:24', '2025-04-29 09:28:57');
28+
INSERT INTO `user_info` VALUES (2, '25d19d8c917747ea', 'tgadmin', 'tgadmin', '{bcrypt-md5}$2a$10$dsfVEzh5NlfrgkcLFbrPLOuSsm5zJMJJwYqlQfTSWs3qKzwhQx5Ku', '', NULL, NULL, '+08:00', NULL, 0, 0, 1, 0, '', NULL, '2025-04-30 08:04:22', NULL, NULL, '2025-04-30 07:35:32', 0, 110, '', 0, '2025-04-30 07:35:32', '2025-04-30 08:22:00');
2929

3030

3131
-- ----------------------------
3232
-- Records of organize_role
3333
-- ----------------------------
34-
INSERT INTO `organize_role` VALUES (221, '', '系统内部角色', 'engineer', '工程师', 1, '{\"Monitor\":[\"view\"],\"History\":[\"view\"],\"Safety\":[\"view\"],\"Tire\":[\"view\"]}', NULL, NULL, 'dca0f9e348384d23958e151bb4adb98f', '2025-04-29 03:46:24', '2025-04-29 03:46:24');
35-
INSERT INTO `organize_role` VALUES (222, '', '系统内部角色', 'service', '客服', 1, '', NULL, NULL, 'dca0f9e348384d23958e151bb4adb98f', '2025-04-29 03:46:24', '2025-04-29 03:46:24');
34+
INSERT INTO `organize_role` VALUES (221, '', 'System Internal Role', 'engineer', 'engineer', 1, '{\"Monitor\":[\"view\"],\"History\":[\"view\"],\"Safety\":[\"view\"],\"Tire\":[\"view\"]}', NULL, NULL, 'dca0f9e348384d23958e151bb4adb98f', '2025-04-29 03:46:24', '2025-04-29 03:46:24');
35+
INSERT INTO `organize_role` VALUES (222, '', 'System Internal Role', 'service', 'service', 1, '', NULL, NULL, 'dca0f9e348384d23958e151bb4adb98f', '2025-04-29 03:46:24', '2025-04-29 03:46:24');
3636

3737
-- ----------------------------
3838
-- Records of system_alarm_platform

setup-services.sh

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,45 @@ if [ -n "$INPUT_IP" ]; then
423423
fi
424424
fi
425425

426-
echo -e "\nTo start services:"
427-
echo -e "${BLUE}cd $TARGET_DIR${NC}"
428-
echo -e "${BLUE}docker compose up -d${NC}"
429-
echo -e "${BLUE}docker compose restart nginx${NC} (If SSL certs updated)"
426+
# --- 6. Auto-start Services ---
427+
echo -e "\n${BLUE}Service Startup${NC}"
428+
429+
START_SERVICES="n"
430+
431+
if [ "$AUTO_YES" == "true" ]; then
432+
START_SERVICES="y"
433+
echo -e "${YELLOW}Auto-starting services in non-interactive mode.${NC}"
434+
else
435+
read -p "Do you want to start the services now? (y/N) " START_SERVICES
436+
fi
437+
438+
if [[ "$START_SERVICES" == "y" || "$START_SERVICES" == "Y" ]]; then
439+
echo -e "${BLUE}Starting Docker services...${NC}"
440+
cd "$TARGET_DIR" || { echo -e "${RED}Failed to change directory to $TARGET_DIR${NC}"; exit 1; }
441+
442+
# Check if docker-compose command is available (v2 vs v1)
443+
if docker compose version &> /dev/null; then
444+
DOCKER_CMD="docker compose"
445+
elif docker-compose version &> /dev/null; then
446+
DOCKER_CMD="docker-compose"
447+
else
448+
echo -e "${RED}Error: Neither 'docker compose' nor 'docker-compose' found.${NC}"
449+
exit 1
450+
fi
451+
452+
echo -e "${BLUE}Executing: $DOCKER_CMD up -d${NC}"
453+
$DOCKER_CMD up -d
454+
455+
if [ $? -eq 0 ]; then
456+
echo -e "${GREEN}Services started successfully!${NC}"
457+
echo -e "${YELLOW}Note: Some services (like databases) may take a few moments to initialize completely.${NC}"
458+
else
459+
echo -e "${RED}Failed to start services.${NC}"
460+
exit 1
461+
fi
462+
else
463+
echo -e "\nTo start services manually:"
464+
echo -e "${BLUE}cd $TARGET_DIR${NC}"
465+
echo -e "${BLUE}docker compose up -d${NC}"
466+
echo -e "${BLUE}docker compose restart nginx${NC} (If SSL certs updated)"
467+
fi

0 commit comments

Comments
 (0)