When expanding your current OnApp cloud infrastructure, or when setting up new infrastructure at a different location, one of the tasks that you will have to perform on the new OnApp Control Panel Server is to configure the user roles. With 20+ pages of role permissions that have to be individually enabled/disabled, this can be a time consuming task. Here is a simple script we created that will allow you to export the roles you need so that they can be imported into the new OnApp Control Panel Server. The script can be downloaded here:
http://xfernet.net/files/onapp/export-roles.sh.gz
How To Use The Script
Note: It is recommended that you perform this import before adding any additional roles through the web interface on the new OnApp Control Panel Server to avoid any conflicting role IDs.
The script is completely menu driven, so all you need to do is execute the script and answer the questions. After executing the script, it will display the database connection information that it will be using. This is read from /onapp/interface/config/database.yml:
sh export-roles.sh Using database configuration: Database: onapp Username: ***** Password: **********
Continue (y/n)? y
The script will now iterate through the roles in the database table and prompt if you would like to export each one:
Export role Administrator? n Skipping Administrator
Export role User? n Skipping User
Export role Customer? y Adding Customer to export list
Next, the script will display which roles are to be exported. You will be asked to supply a filename to dump the SQL to. If you enter a filename that already exists, the script will exit.
Enter dump file name: test.sql Dumping SQL to test.sql Dumping SQL for Customer Dumping SQL for Customer permissions Export complete.
Lastly, you need to transfer the dump file to the new CP server and import with the mysql command:
mysql -u user -p onapp < test.sql
The roles should now be visible on the new OnApp Control Panel Server.