You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.7 KiB

  1. #!/bin/bash
  2. blocks_dir=blocks
  3. docker_dir=docker
  4. template_dir=templates
  5. docker_file=Dockerfile
  6. gogs_config_file=conf.tmp
  7. gogs_config=config
  8. gogs_init_file=$docker_dir/init_gogs.sh
  9. compose_file=docker-compose.yml
  10. compose_config=docker-compose
  11. gogs_init_template=$template_dir/init_gogs.sh.tpl
  12. if [ "$#" == 0 ]; then
  13. blocks=`ls $blocks_dir`
  14. if [ -z "$blocks" ]; then
  15. echo "No Blocks available in $blocks_dir"
  16. else
  17. echo "Available Blocks:"
  18. for block in $blocks; do
  19. echo " $block"
  20. done
  21. fi
  22. exit 0
  23. fi
  24. for file in $gogs_config_file $compose_file; do
  25. if [ -e $file ]; then
  26. echo "Deleting $file"
  27. rm $file
  28. fi
  29. done
  30. for dir in $@; do
  31. current_dir=$blocks_dir/$dir
  32. if [ ! -d "$current_dir" ]; then
  33. echo "$current_dir is not a directory"
  34. exit 1
  35. fi
  36. if [ -e $current_dir/$docker_file ]; then
  37. echo "Copying $current_dir/$docker_file to $docker_dir/$docker_file"
  38. cp $current_dir/$docker_file $docker_dir/$docker_file
  39. fi
  40. if [ -e $current_dir/$gogs_config ]; then
  41. echo "Adding $current_dir/$gogs_config to $gogs_config_file"
  42. cat $current_dir/$gogs_config >> $gogs_config_file
  43. echo "" >> $gogs_config_file
  44. fi
  45. if [ -e $current_dir/$compose_config ]; then
  46. echo "Adding $current_dir/$compose_config to $compose_file"
  47. cat $current_dir/$compose_config >> $compose_file
  48. echo "" >> $compose_file
  49. fi
  50. done
  51. echo "Creating $gogs_init_file"
  52. sed "/{{ CONFIG }}/{
  53. r $gogs_config_file
  54. d
  55. }" $gogs_init_template > $gogs_init_file
  56. if [ -e $gogs_config_file ]; then
  57. echo "Removing temporary GoGS config"
  58. rm $gogs_config_file
  59. fi