start.sh 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/bash
  2. # @Contact : liuyuqi.gov@msn.cn
  3. # @Time : 2023/12/17 03:57:36
  4. # @License : (C)Copyright 2022 liuyuqi.
  5. # @Desc : 执行 /opt/repo_sync/repo_sync 命令
  6. # 传入两个参数,/opt/repo_sync/repo_sync create --platform github --repo_path /home/workspace/xx
  7. ###############################################################################
  8. # 打印logo,用户使用指南
  9. function print_logo() {
  10. echo -e "\033[32
  11. repo sync 项目同步工具 v1.0
  12. 作者:liuyuqi
  13. Usage:
  14. repo_sync create --platform github --repo_path /home/workspace/xx
  15. repo_sync delete --platform github --repo_path /home/workspace/xx
  16. repo_sync update --platform github --repo_path /home/workspace/xx
  17. repo_sync list --platform github --repo_path /home/workspace/xx
  18. repo_sync help
  19. \033[0m"
  20. }
  21. print_logo
  22. while true; do
  23. echo "请输入操作,create(1),push(2),pull(3),delete(4), 回车默认1"
  24. read -p "请输入操作:" action
  25. if [ $action == 1 ] || [ $action == 2 ] || [ $action == 3 ] || [ $action == 4 ] || [ $action == 5 ] || [ $action == 6 ] || [ $action == 7 ]; then
  26. break
  27. fi
  28. done
  29. while true; do
  30. # 请输入平台,github(1),gitlab(2),coding(3),gitee(4),gogs(5)
  31. echo "请输入平台,github(1),gitlab(2),coding(3),gitee(4),gogs(5)"
  32. read -p "请输入平台:" platform
  33. if [ $platform == 1 ] || [ $platform == 2 ] || [ $platform == 3 ] || [ $platform == 4 ] || [ $platform == 5 ]; then
  34. if [ $platform == 1 ]; then
  35. platform="github"
  36. elif [ $platform == 2 ]; then
  37. platform="gitlab"
  38. elif [ $platform == 3 ]; then
  39. platform="coding"
  40. elif [ $platform == 4 ]; then
  41. platform="gitee"
  42. elif [ $platform == 5 ]; then
  43. platform="gogs"
  44. fi
  45. break
  46. fi
  47. done
  48. # 请输入仓库路径,/home/workspace/xx
  49. echo "请输入仓库路径,/home/workspace/xx"
  50. read -p "请输入仓库路径:" repo_path
  51. cd /opt/repo_sync
  52. if [ $action == 1 ]; then
  53. /opt/repo_sync/repo_sync create --platform $platform --repo_path $repo_path
  54. elif [ $action == 2 ]; then
  55. /opt/repo_sync/repo_sync push --platform $platform --repo_path $repo_path
  56. elif [ $action == 3 ]; then
  57. /opt/repo_sync/repo_sync pull --platform $platform --repo_path $repo_path
  58. elif [ $action == 4 ]; then
  59. /opt/repo_sync/repo_sync delete --platform $platform --repo_path $repo_path
  60. elif [ $action == 5 ]; then
  61. /opt/repo_sync/repo_sync update --platform $platform --repo_path $repo_path
  62. elif [ $action == 6 ]; then
  63. /opt/repo_sync/repo_sync list --platform $platform --repo_path $repo_path
  64. elif [ $action == 7 ]; then
  65. print_logo
  66. else
  67. print_logo
  68. fi