fork 0k-charms
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.

60 lines
1.4 KiB

  1. # -*- mode: shell-script -*-
  2. CONFIG_FILE=/data/gitea/conf/app.ini
  3. ini() {
  4. local action="$1"
  5. shift
  6. crudini "--$action" "$SERVICE_DATASTORE$CONFIG_FILE" "$@"
  7. }
  8. gitea_config_hash() {
  9. config_hash=$(cat "$SERVICE_DATASTORE$CONFIG_FILE" | md5_compat) || exit 1
  10. init-config-add "
  11. $MASTER_BASE_SERVICE_NAME:
  12. labels:
  13. - compose.config_hash=$config_hash
  14. "
  15. }
  16. join_by_dot() {
  17. local IFS="."
  18. echo "$*"
  19. }
  20. gitea:ini-make() {
  21. local key val type
  22. local sep=
  23. [ -n "$1" ] && printf "\n[%s]\n" "$(IFS="."; echo "$*")"
  24. while read-0 key type val; do
  25. case "${type##*\!}" in
  26. map|seq)
  27. e "$val" | gitea:ini-make "$@" "$key" || return 1
  28. continue
  29. ;;
  30. bool)
  31. val="${val%$'\n'}"
  32. case "${val,,}" in
  33. true|ok|yes|y)
  34. val=true
  35. ;;
  36. false|ko|nok|no|n)
  37. val=false
  38. ;;
  39. *)
  40. die "Invalid value for ${WHITE}$key$NORMAL, please use a boolean value."
  41. ;;
  42. esac
  43. ;;
  44. str|*)
  45. val="${val%$'\n'}"
  46. ;;
  47. esac
  48. key=${key//-/_}
  49. key=${key^^}
  50. printf "%s = %s\n" "$key" "$val"
  51. done < <( yq -0 'to_entries | map([.key, .value | type, .value | to_yaml])[] | .[]' )
  52. }