lego-config.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/bash
  2. # Download go-acme/lego repository
  3. download_and_extract() {
  4. local repo_url="https://github.com/go-acme/lego/archive/refs/heads/master.zip"
  5. local target_dir="$1"
  6. # Check if wget and unzip are installed
  7. if ! command -v wget >/dev/null || ! command -v unzip >/dev/null; then
  8. echo "Please ensure wget and unzip are installed."
  9. exit 1
  10. fi
  11. # Download and extract the source code
  12. wget -q -O lego-master.zip "$repo_url"
  13. unzip -q lego-master.zip -d "$target_dir"
  14. rm lego-master.zip
  15. }
  16. # Copy .toml files from providers to the specified directory
  17. copy_toml_files() {
  18. local source_dir="$1/lego-master/providers"
  19. local target_dir="internal/cert/config"
  20. # Remove the lego-master folder
  21. if [ ! -d "$target_dir" ]; then
  22. mkdir -p "$target_dir"
  23. fi
  24. # Copy .toml files
  25. find "$source_dir" -type f -name "*.toml" -exec cp {} "$target_dir" \;
  26. }
  27. # Remove the lego-master folder
  28. remove_lego_master_folder() {
  29. local folder="$1/lego-master"
  30. rm -rf "$folder"
  31. }
  32. destination="./tmp"
  33. download_and_extract "$destination"
  34. copy_toml_files "$destination"
  35. remove_lego_master_folder "$destination"