v-open-fs-config 992 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. # info: open config
  3. # options: CONFIG
  4. #
  5. # The function opens/reads config files on the file system
  6. src_file=$1
  7. # Checking arguments
  8. if [ -z "$src_file" ]; then
  9. echo "Usage: CONFIG"
  10. exit 1
  11. fi
  12. # Checking vesta user
  13. if [ ! -e "$VESTA/data/users/$user" ]; then
  14. echo "Error: vesta user $user doesn't exist"
  15. exit 3
  16. fi
  17. # Checking file on fs
  18. if [ ! -e "$src_file" ]; then
  19. echo "Error: $src_file file doesn't exist"
  20. exit 3
  21. fi
  22. # Checking path
  23. if [ ! -z "$src_file" ]; then
  24. rpath=$(readlink -f "$src_file")
  25. services="nginx|apache|httpd|php|ftp|bind|named|exim|dovecot|spamassassin"
  26. services="$services|clam|mysql|postgresql|pgsql|cron|fail2ban|iptables"
  27. spath=$(echo "$rpath" |egrep "$services")
  28. if [ -z "$spath" ]; then
  29. echo "Error: invalid source path $src_file"
  30. exit 2
  31. fi
  32. fi
  33. # Reading conf
  34. cat "$src_file" 2>/dev/null
  35. if [ $? -ne 0 ]; then
  36. echo "Error: file $src_file was not opened"
  37. exit 3
  38. fi
  39. # Exiting
  40. exit