v_change_sys_config_value 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/bash
  2. # info: changing sysconfig value
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. key=$(echo "$1" | tr '[:lower:]' '[:upper:]' )
  8. value=${2// /%spc%}
  9. # Importing variables
  10. source $VESTA/conf/vars.conf
  11. source $V_FUNC/shared.func
  12. #----------------------------------------------------------#
  13. # Verifications #
  14. #----------------------------------------------------------#
  15. # Checking args
  16. check_args '2' "$#" 'key value'
  17. # Checking argument format
  18. format_validation 'key'
  19. # Checking key existance
  20. check_ckey=$(grep "^$key='" $V_CONF/vesta.conf)
  21. if [ -z "$check_ckey" ]; then
  22. echo "Error: key not found"
  23. log_event 'debug' "$E_KEY_INVALID $V_EVENT"
  24. exit $E_KEY_INVALID
  25. fi
  26. #----------------------------------------------------------#
  27. # Action #
  28. #----------------------------------------------------------#
  29. # Updating conf
  30. sed -i "s/$key=.*/$key='$value'/g" /tmp/vesta.conf
  31. #----------------------------------------------------------#
  32. # Vesta #
  33. #----------------------------------------------------------#
  34. # Logging
  35. log_event 'system' "$V_EVENT"
  36. exit