#!/usr/bin/env bash RT="$(readlink -f "$(dirname $(readlink -f ${BASH_SOURCE[0]}))/../../..")" #" DSHOST="${DSHOST:-japet.local}" DSPORT="${DSPORT:-4001}" DSROOT="${DSROOT:-server}" DSROOTKEYFILE="${DSROOTKEYFILE:-${RT}/etc/superuser-rsa}" DSUSER="${DSUSER:-test}" DSADMIN="${DSADMIN:-admin}" DSUSERKEYFILE="${DSUSERKEYFILE:-${RT}/etc/user-rsa}" DSUSERPUBKEY="$( cat ${RT}/etc/user-rsa.pub | awk '{ print $2; }' )" #DSUSERPUBKEY="$( cat ./etc/user-rsa.pub | head -n1 )" DOECHO=1 err_exit(){ exit $1 } dsystem_super(){ [ -n "${DOECHO}" ] && { echo "command: ${@}"; } ssh -i "${DSROOTKEYFILE}" -p "${DSPORT}" "${DSROOT}@${DSHOST}" "${@}" } dsystem_user(){ [ -n "${DOECHO}" ] && { echo "command: ${@}"; } ssh -i "${DSUSERKEYFILE}" -p "${DSPORT}" "${DSUSER}@${DSHOST}" "${@}" } dsystem_admin(){ [ -n "${DOECHO}" ] && { echo "command: ${@}"; } ssh -i "${DSUSERKEYFILE}" -p "${DSPORT}" "${DSADMIN}@${DSHOST}" "${@}" } dsystem_super create role administrator with descr:'"Administrator role"' || err_exit $? dsystem_super create role user with descr:'"Common user role"' || err_exit $? dsystem_super create user "${DSADMIN}" with roles:[administrator] descr:'"admin user"' || err_exit $? dsystem_super create key "${DSADMIN}" "'${DSUSERPUBKEY}'" || err_exit $? dsystem_super create user "${DSUSER}" with roles:[user] descr:'"test user"' || err_exit $? dsystem_super create key "${DSUSER}" "'${DSUSERPUBKEY}'" || err_exit $? dsystem_super create acl @table:@users administrator all || err_exit $? dsystem_super create acl @table:@roles administrator all || err_exit $? dsystem_super create acl @table:@schemes administrator all || err_exit $? dsystem_super create acl @table:@machines administrator all || err_exit $? dsystem_super create acl @table:@triggers administrator all || err_exit $? dsystem_super create acl @table:@authmap administrator all || err_exit $? dsystem_super create acl @table:@system administrator all || err_exit $? dsystem_admin create machine dummy with description:"'dummy machine'" maxtasks:1000 conn:{ addr:"'localhost:4002'" login:dummy pass:dummy } online:true dsystem_admin create scheme test1 with descr:"'test scheme'" command:"'echo'" ttl:"'1d'" dsystem_admin link scheme test1 to dummy with spri:50 mpri:50 dsystem_admin create acl @scheme:test1 all exec dsystem_admin create scheme test2 with descr:"'test scheme'" command:"'echo'" ttl:"'1d'" dsystem_admin link scheme test2 to dummy with spri:50 mpri:50 #dsystem_admin create acl @scheme:test all exec dsystem_admin create scheme test3 with descr:"'test scheme'" command:"'echo'" ttl:"'1d'" dsystem_admin link scheme test3 to dummy with spri:50 mpri:50 #dsystem_admin create acl @scheme:test all exec dsystem_admin create trigger test1 with \ cond:"'SCHEME=\'test1\' and RESULT=0'" \ body:"'start test2 \${arg:0} \${arg:1}'" \ enabled:true dsystem_admin create trigger test2 with \ cond:"'SCHEME=\'test2\' and RESULT=0'" \ body:"'start test3 \${arg:0} \${arg:1}'" \ enabled:true dsystem_admin create trigger test11 with \ cond:"'SCHEME=\'test1\' and RESULT=0 and VALUE_mode=\'operative\''" \ body:"'start test2 { mode:operative } \${arg:0} \${arg:1}'" \ enabled:true dsystem_admin create trigger test21 with \ cond:"'SCHEME=\'test2\' and RESULT=0 and VALUE_mode=\'operative\''" \ body:"'start test3 { mode:operative } \${arg:0} \${arg:1}'" \ enabled:true #dsystem_super system status || err_exit $?