Playbooks to a new Lilik
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.

36 lines
1.0 KiB

  1. #!/bin/bash
  2. # wrapper for conditional setting of nextcloud occ variables
  3. # derived from ansible-openwrt
  4. # parameters are command, key, value
  5. source ${1}
  6. logger occ $(cat ${1})
  7. unquoted_key="$(echo $key | sed -e s/\'//g)"
  8. unquoted_value="$(echo $value | sed -e s/\'//g)"
  9. # Hardcoded
  10. cd /opt/nextcloud
  11. # test if we need to apply a change
  12. case "$command" in
  13. 'config:app:set')
  14. [ "$(sudo -u www-data php occ config:app:get $unquoted_key)" = "$unquoted_value" ]
  15. changed=$?
  16. ;;
  17. 'config:system:set')
  18. [ "$(sudo -u www-data php occ config:system:get $unquoted_key)" = "$unquoted_value" ]
  19. changed=$?
  20. ;;
  21. esac
  22. if [ $changed -eq 0 ]
  23. then
  24. echo -n '{"changed": false}'
  25. else
  26. if [ -z "${_ansible_check_mode}" -o "${_ansible_check_mode}" = "False" ]
  27. then
  28. logger occ $(sudo -u www-data php occ "${command}" ${unquoted_key} --value="${unquoted_value}")
  29. fi
  30. echo -n '{"changed": true, "msg": "executed sudo -u www:data php occ '${command}' '${unquoted_key}' --value='${value}'"}'
  31. fi