drupal-setup.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/sh
  2. ##
  3. ## drupal-setup.sh -- Drupal RDBMS Setup Utility
  4. ##
  5. # database configuration
  6. db_name="drupal"
  7. db_user="drupal"
  8. db_pass="drupal"
  9. # determine RDBMS-specific details
  10. db_suser=`grep "^user" @l_prefix@/etc/mysql/my.pwd |\
  11. sed -e 's;^user[^=]*= *;;' -e 's; *$;;'`
  12. db_spass=`grep "^password" @l_prefix@/etc/mysql/my.pwd |\
  13. sed -e 's;^password[^=]*= *;;' -e 's; *$;;'`
  14. # dispatch operation
  15. cmd="${1:-"install"}"
  16. case "$cmd" in
  17. install )
  18. # create the database
  19. @l_prefix@/bin/mysqladmin --user="$db_suser" --password="$db_spass" create "$db_name"
  20. ( echo "GRANT ALL PRIVILEGES ON $db_name.* TO $db_user@localhost IDENTIFIED BY '$db_pass';"
  21. echo "FLUSH PRIVILEGES;"
  22. ) | @l_prefix@/bin/mysql --user="$db_suser" --password="$db_spass" mysql
  23. # activate configuration directory
  24. # (is automatically deactivated by installer afterwards)
  25. chmod 777 @l_prefix@/share/drupal/sites/default
  26. ;;
  27. uninstall )
  28. # remove the database
  29. ( echo "DROP DATABASE $db_name;"
  30. ) | @l_prefix@/bin/mysql --user="$db_suser" --password="$db_spass" mysql
  31. # remove the generated configuration
  32. rm -f @l_prefix@/share/drupal/sites/default/settings.php
  33. rm -f @l_prefix@/var/drupal/files/*
  34. ;;
  35. esac