Advertisement
QuarkDoe

system init

May 11th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.42 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. RT="$(readlink -f "$(dirname $(readlink -f ${BASH_SOURCE[0]}))/../../..")" #"
  4. DSHOST="${DSHOST:-japet.local}"
  5. DSPORT="${DSPORT:-4001}"
  6. DSROOT="${DSROOT:-server}"
  7. DSROOTKEYFILE="${DSROOTKEYFILE:-${RT}/etc/superuser-rsa}"
  8. DSUSER="${DSUSER:-test}"
  9. DSADMIN="${DSADMIN:-admin}"
  10. DSUSERKEYFILE="${DSUSERKEYFILE:-${RT}/etc/user-rsa}"
  11. DSUSERPUBKEY="$( cat ${RT}/etc/user-rsa.pub | awk '{ print $2; }' )"
  12. #DSUSERPUBKEY="$( cat ./etc/user-rsa.pub | head -n1 )"
  13.  
  14. DOECHO=1
  15. err_exit(){
  16.     exit $1
  17. }
  18.  
  19. dsystem_super(){
  20.     [ -n "${DOECHO}" ] && { echo "command: ${@}"; }
  21.     ssh -i "${DSROOTKEYFILE}" -p "${DSPORT}" "${DSROOT}@${DSHOST}" "${@}"
  22. }
  23.  
  24. dsystem_user(){
  25.     [ -n "${DOECHO}" ] && { echo "command: ${@}"; }
  26.     ssh -i "${DSUSERKEYFILE}" -p "${DSPORT}" "${DSUSER}@${DSHOST}" "${@}"
  27. }
  28.  
  29. dsystem_admin(){
  30.     [ -n "${DOECHO}" ] && { echo "command: ${@}"; }
  31.     ssh -i "${DSUSERKEYFILE}" -p "${DSPORT}" "${DSADMIN}@${DSHOST}" "${@}"
  32. }
  33.  
  34. dsystem_super create role administrator with descr:'"Administrator role"' || err_exit $?
  35. dsystem_super create role user with descr:'"Common user role"' || err_exit $?
  36.  
  37. dsystem_super create user "${DSADMIN}" with roles:[administrator] descr:'"admin user"' || err_exit $?
  38. dsystem_super create key "${DSADMIN}" "'${DSUSERPUBKEY}'" || err_exit $?
  39.  
  40. dsystem_super create user "${DSUSER}" with roles:[user] descr:'"test user"' || err_exit $?
  41. dsystem_super create key "${DSUSER}" "'${DSUSERPUBKEY}'" || err_exit $?
  42.  
  43. dsystem_super create acl @table:@users administrator all || err_exit $?
  44. dsystem_super create acl @table:@roles administrator all || err_exit $?
  45. dsystem_super create acl @table:@schemes administrator all || err_exit $?
  46. dsystem_super create acl @table:@machines administrator all || err_exit $?
  47. dsystem_super create acl @table:@triggers administrator all || err_exit $?
  48. dsystem_super create acl @table:@authmap administrator all || err_exit $?
  49. dsystem_super create acl @table:@system administrator all || err_exit $?
  50.  
  51. dsystem_admin create machine dummy with description:"'dummy machine'" maxtasks:1000 conn:{ addr:"'localhost:4002'" login:dummy pass:dummy } online:true
  52.  
  53. dsystem_admin create scheme test1 with descr:"'test scheme'" command:"'echo'" ttl:"'1d'"
  54. dsystem_admin link scheme test1 to dummy with spri:50 mpri:50
  55. dsystem_admin create acl @scheme:test1 all exec
  56.  
  57. dsystem_admin create scheme test2 with descr:"'test scheme'" command:"'echo'" ttl:"'1d'"
  58. dsystem_admin link scheme test2 to dummy with spri:50 mpri:50
  59. #dsystem_admin create acl @scheme:test all exec
  60.  
  61. dsystem_admin create scheme test3 with descr:"'test scheme'" command:"'echo'" ttl:"'1d'"
  62. dsystem_admin link scheme test3 to dummy with spri:50 mpri:50
  63. #dsystem_admin create acl @scheme:test all exec
  64.  
  65. dsystem_admin create trigger test1 with \
  66.  cond:"'SCHEME=\'test1\' and RESULT=0'" \
  67.  body:"'start test2 \${arg:0} \${arg:1}'" \
  68.  enabled:true
  69.  
  70. dsystem_admin create trigger test2 with \
  71.  cond:"'SCHEME=\'test2\' and RESULT=0'" \
  72.  body:"'start test3 \${arg:0} \${arg:1}'" \
  73.  enabled:true
  74.  
  75. dsystem_admin create trigger test11 with \
  76.  cond:"'SCHEME=\'test1\' and RESULT=0 and VALUE_mode=\'operative\''" \
  77.  body:"'start test2 { mode:operative } \${arg:0} \${arg:1}'" \
  78.  enabled:true
  79.  
  80. dsystem_admin create trigger test21 with \
  81.  cond:"'SCHEME=\'test2\' and RESULT=0 and VALUE_mode=\'operative\''" \
  82.  body:"'start test3 { mode:operative } \${arg:0} \${arg:1}'" \
  83.  enabled:true
  84.  
  85. #dsystem_super system status || err_exit $?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement