diff --git a/Makefile b/Makefile index 65abe29cf..e8b70dc33 100644 --- a/Makefile +++ b/Makefile @@ -81,6 +81,9 @@ test : test-deps rel: locked-deps compile $(REBAR) as rel release +rel-rpm: locked-deps compile + $(REBAR) as rel,rpm release + relclean: rm -rf $(REL_DIR) rm -rf rel/riak @@ -256,11 +259,7 @@ get_dist_deps = mkdir distdir && \ # This enables the toplevel repository package to change names # when underlying dependencies change. NAME_HASH = $(shell git hash-object distdir/$(CLONEDIR)/$(MANIFEST_FILE) 2>/dev/null | cut -c 1-8) -ifeq ($(REVISION), $(MAJOR_VERSION)) PKG_ID := $(REPO_TAG) -else -PKG_ID = $(REPO)-$(MAJOR_VERSION)-$(NAME_HASH) -endif # To ensure a clean build, copy the CLONEDIR at a specific tag to a new directory # which will be the basis of the src tar file (and packages) @@ -305,9 +304,13 @@ pkgclean: ballclean # which differs from $REVISION that is repo-- PKG_VERSION = $(shell echo $(PKG_ID) | sed -e 's/^$(REPO)-//') -package: distdir/$(PKG_ID).tar.gz - ln -s distdir package - $(MAKE) -C package -f $(PKG_ID)/deps/node_package/Makefile +package: + git archive --format=tar HEAD | gzip >rel/pkg/out/riak-$(PKG_ID).tar.gz + $(MAKE) -C rel/pkg/ -f Makefile + +packageclean: + rm -rf rel/pkg/out/* + .PHONY: package export PKG_VERSION PKG_ID PKG_BUILD BASE_DIR ERLANG_BIN REBAR OVERLAY_VARS RELEASE diff --git a/apps/riak/src/riak.app.src b/apps/riak/src/riak.app.src index 23ae71d48..51c6ab0c7 100644 --- a/apps/riak/src/riak.app.src +++ b/apps/riak/src/riak.app.src @@ -17,9 +17,12 @@ runtime_tools, lager_syslog, cluster_info, - riak_kv, + cluster_metadata, +%% exometer_core, + stats, + riak_kv, riak_repl, riak_auth_mods - ]}, + ]}, {env, []} ]}. diff --git a/rebar.config b/rebar.config index 9860dde90..1e4d836f8 100644 --- a/rebar.config +++ b/rebar.config @@ -13,14 +13,15 @@ {deps, [ {lager_syslog, {git, "git://github.com/basho/lager_syslog.git", {branch, "develop-3.0"}}}, {cluster_info, {git, "git://github.com/basho/cluster_info.git", {branch, "develop-3.0"}}}, - {riak_kv, {git, "git://github.com/basho/riak_kv.git", {branch, "develop-3.0"}}}, + {riak_kv, {git, "git://github.com/basho/riak_kv.git", {branch, "develop-3.0-riak_stat"}}}, {riak_auth_mods, {git, "git://github.com/basho/riak_auth_mods.git", {branch, "develop-3.0"}}}, - {riak_repl, {git, "git://github.com/basho/riak_repl.git", {branch, "develop-3.0"}}}, - {yokozuna, {git, "git://github.com/basho/yokozuna.git", {branch, "develop-3.0"}}} - ]}. + {riak_repl, {git, "git://github.com/basho/riak_repl.git", {branch, "develop-3.0-riak_stat"}}}, + {yokozuna, {git, "git://github.com/basho/yokozuna.git", {branch, "develop-3.0-stats-work"}}} + +]}. {project_plugins, [ - {rebar3_cuttlefish, {git, "https://github.com/martincox/rebar3_cuttlefish", {branch, "fix/output-dir-awareness"}}} + {rebar3_cuttlefish, {git, "https://github.com/martincox/rebar3_cuttlefish", {branch, "fix/runner_dirs"}}} ]}. {cuttlefish, [ @@ -60,20 +61,23 @@ basho_stats, bitcask, clique, + cluster_metadata, + stats, riak_core, riak_pipe, riak_kv, riak_api, riak_repl, cluster_info, - yokozuna, + % yokozuna, riak_auth_mods]}, {dev_mode, false}, {include_erts, true}, {overlay, [ - {mkdir, "lib/riak-patches"}, + {mkdir, "lib/patches"}, + {mkdir, "data/ring"}, {template, "rel/files/advanced.config", "etc/advanced.config"}, @@ -82,6 +86,7 @@ {template, "rel/files/riak-debug", "bin/riak-debug"}, {template, "rel/files/riak-chkconfig", "bin/riak-chkconfig"}, {template, "rel/files/riak-repl", "bin/riak-repl"}, + {template, "_checkouts/stats/rel/files/stats","bin/riak-stat"}, {copy, "rel/files/check_ulimit", "bin/hooks/check_ulimit"}, {copy, "rel/files/riak_not_running", "bin/hooks/riak_not_running"} @@ -91,6 +96,7 @@ {generate_start_script, true}, {extended_start_script, true}, {extended_start_script_extensions, [ + {stat, "riak-stat"}, {admin, "riak-admin"}, {debug, "riak-debug"}, {repl, "riak-repl"}, @@ -113,12 +119,25 @@ {profiles, [ {rel, [ {relx, [ - {overlay_vars, "rel/vars.config"} + {overlay_vars, "rel/vars.config"} ]} ]}, {dev, [ {relx, [ - {dev_mode, true} + {dev_mode, true} + ]} + ]}, + {rpm, [ + {relx, [ + {overlay_vars, "rpm.vars.config"}, + {overlay, [ + {template, "rel/pkg/rpm/riak", "usr/bin/riak"} + ]} + ]} + ]}, + {deb, [ + {relx, [ + {overlay_vars, "deb.vars.config"} ]} ]} ]}. diff --git a/rebar.lock b/rebar.lock index 0cefc692f..6d5e12953 100644 --- a/rebar.lock +++ b/rebar.lock @@ -6,7 +6,7 @@ {<<"bear">>,{pkg,<<"bear">>,<<"0.8.7">>},4}, {<<"bitcask">>, {git,"git://github.com/basho/bitcask.git", - {ref,"9184f763b135f9ff5061fa3ce1892cefa54cfe3a"}}, + {ref,"1bb4c98d0285fe6caa76b89d51c50f4e504d2554"}}, 1}, {<<"canola">>, {git,"git://github.com/basho/canola.git", @@ -20,10 +20,18 @@ {git,"git://github.com/basho/cluster_info.git", {ref,"18ed572102055626c1597339015d6501989df287"}}, 0}, + {<<"cluster_metadata">>, + {git,"https://github.com/bet365/cluster_metadata.git", + {ref,"5c09cc24bc727f57c985c96cebe602bd61f0b56d"}}, + 2}, {<<"cuttlefish">>, {git,"https://github.com/basho/cuttlefish.git", {ref,"1b4381e5f682d88a2f20ddb8511ff35098c40ea5"}}, 3}, + {<<"dvvset">>, + {git,"git://github.com/ricardobcl/dotted-version-vectors.git", + {ref,"27fd1225c10a7dc4890e5e55abddf6db2392f6cc"}}, + 3}, {<<"ebloom">>, {git,"git://github.com/basho/ebloom.git", {ref,"3c25f9ef61a73d5f1d2c2601da464dd03975721d"}}, @@ -32,8 +40,11 @@ {git,"git://github.com/basho/eleveldb.git", {ref,"5ca7491c947d24c764eb0a359370e83dcc0bb021"}}, 2}, - {<<"exometer_core">>,{pkg,<<"exometer_core">>,<<"1.5.7">>},2}, - {<<"folsom">>,{pkg,<<"folsom">>,<<"0.8.7">>},3}, + {<<"eunit_formatters">>, + {git,"git://github.com/seancribbs/eunit_formatters", + {ref,"473e0cd89bf5608e97886a3bdf9047a16edc88f0"}}, + 1}, + {<<"folsom">>,{pkg,<<"folsom">>,<<"0.8.8">>},3}, {<<"fuse">>, {git,"https://github.com/jlouis/fuse.git", {ref,"21c6e52ced3af294f2fe636039106068da12eeeb"}}, @@ -44,18 +55,22 @@ {ref,"880030ff0cbecb73ba75a78a7aa0cc1dcb7fe331"}}, 4}, {<<"goldrush">>,{pkg,<<"goldrush">>,<<"0.1.9">>},2}, - {<<"hut">>,{pkg,<<"hut">>,<<"1.2.1">>},3}, + {<<"hashtree">>, + {git,"git://github.com/martincox/hashtree.git", + {ref,"267974bc81e7bcb0287038cd9accc61d4079d108"}}, + 3}, + {<<"hut">>,{pkg,<<"hut">>,<<"1.3.0">>},3}, {<<"hyper">>, {git,"git://github.com/basho/hyper", {ref,"d0bf3d67fd17b8ed2610b266aebd54b1027ea916"}}, 1}, {<<"ibrowse">>, - {git,"git://github.com/basho/ibrowse.git", - {ref,"893864e25573b4ccd31a82b9412639751733ba40"}}, + {git,"git://github.com/cmullaparthi/ibrowse.git", + {ref,"7529807170cf3c8f6a8c5c95526e670420ff591b"}}, 1}, {<<"kv_index_tictactree">>, {git,"https://github.com/martinsumner/kv_index_tictactree.git", - {ref,"b2423eaf11493eb51fc8089a843f8c24d951404b"}}, + {ref,"9c667cf656856877da9d9b84da120490d8196ae7"}}, 1}, {<<"kvc">>, {git,"git://github.com/etrepum/kvc.git", @@ -71,7 +86,7 @@ 0}, {<<"leveled">>, {git,"https://github.com/martinsumner/leveled.git", - {ref,"432fe71bf09987f52fc407a776c23e8eca802451"}}, + {ref,"4d550ef2a1a2b7ff6f6dd2dc28e3b1aed44cf21d"}}, 1}, {<<"lz4">>, {git,"https://github.com/szktty/erlang-lz4", @@ -102,18 +117,10 @@ {git,"https://github.com/massemanet/redbug", {ref,"c583d4567d1e2b8a540593ad0512559798d42565"}}, 1}, - {<<"riak_api">>, - {git,"git://github.com/basho/riak_api.git", - {ref,"ada7e27a43ef3e98790df7b607f6dd0f0e4f13df"}}, - 1}, {<<"riak_auth_mods">>, {git,"git://github.com/basho/riak_auth_mods.git", {ref,"a991fd05929237413a641b60fc826412f98e099e"}}, 0}, - {<<"riak_core">>, - {git,"git://github.com/basho/riak_core.git", - {ref,"b726b0b4c5bbef1a20b95d551d3e32f6dc8741b5"}}, - 1}, {<<"riak_dt">>, {git,"git://github.com/basho/riak_dt.git", {ref,"cdf8cbf3009b7ecb4d659c1576a466cbefe47f55"}}, @@ -122,26 +129,18 @@ {git,"https://github.com/basho/riak_ensemble", {ref,"495833f7a79bb43e288a2a36c9acddfd27e8d90f"}}, 2}, - {<<"riak_kv">>, - {git,"git://github.com/basho/riak_kv.git", - {ref,"56cb3a1737c373fe4b09ca03681f36e56928a034"}}, - 0}, {<<"riak_pb">>, {git,"git://github.com/basho/riak_pb.git", {ref,"55fab3a2642edf2293228d5a43748a0fc3c8e554"}}, 1}, - {<<"riak_pipe">>, - {git,"git://github.com/basho/riak_pipe.git", - {ref,"98944cb1b83fa83ab6011e3958252061f48e2172"}}, + {<<"riak_repl_pb_api">>, + {git,"git://github.com/basho/riak_repl_pb_api.git", + {ref,"6c9ce4abd1170ea77c2267addc18e0c5ad72bb1e"}}, 1}, - {<<"riak_repl">>, - {git,"git://github.com/basho/riak_repl.git", - {ref,"8fcc415e89e867ee85a79949869b2497172360a4"}}, - 0}, {<<"riak_sysmon">>,{pkg,<<"riak_sysmon">>,<<"2.1.7">>},2}, {<<"riakc">>, {git,"git://github.com/basho/riak-erlang-client", - {ref,"28b1349d2b9e0cf855baf8142a44815c116f39ad"}}, + {ref,"302974b5e442ba6f01a89f81e6b393809200e5e4"}}, 1}, {<<"setup">>,{pkg,<<"setup">>,<<"2.0.2">>},3}, {<<"sext">>, @@ -162,16 +161,15 @@ 2}, {<<"yokozuna">>, {git,"git://github.com/basho/yokozuna.git", - {ref,"328265b5beff5e65f5353cd708e3b6b4cc8363cd"}}, + {ref,"02d09d260f74eaa3c86256e822633509dcdfc1ee"}}, 0}]}. [ {pkg_hash,[ {<<"bear">>, <<"16264309AE5D005D03718A5C82641FCC259C9E8F09ADEB6FD79CA4271168656F">>}, - {<<"exometer_core">>, <<"AB97E34A5D69AB14E6AE161DB4CCA5B5E655E635B842F830EE6AB2CBFCFDC30A">>}, - {<<"folsom">>, <<"A885F0AEEE4C84270954C88A55A5A473D6B2C7493E32FFDC5765412DD555A951">>}, + {<<"folsom">>, <<"9A2B02010F6727CB1948EF34E21CB66F3554B63355C3A31E8BCB10FB172C3170">>}, {<<"gen_fsm_compat">>, <<"5903549F67D595F58A7101154CBE0FDD46955FBFBE40813F1E53C23A970FF5F4">>}, {<<"goldrush">>, <<"F06E5D5F1277DA5C413E84D5A2924174182FB108DABB39D5EC548B27424CD106">>}, - {<<"hut">>, <<"08D46679523043424870723923971889E8A34D63B2F946A35B46CF921D1236E7">>}, + {<<"hut">>, <<"71F2F054E657C03F959CF1ACC43F436EA87580696528CA2A55C8AFB1B06C85E7">>}, {<<"parse_trans">>, <<"09765507A3C7590A784615CFD421D101AEC25098D50B89D7AA1D66646BC571C1">>}, {<<"riak_sysmon">>, <<"AF420DF0F7569E1F12BCD465745164CB6189EB93F118D5CDB3F90FEB3F8BF47D">>}, {<<"setup">>, <<"1203F4CDA11306C2E34434244576DED0A7BBFB0908D9A572356C809BD0CDF085">>}]} diff --git a/rel/files/riak-admin b/rel/files/riak-admin index 1b1b2657e..e1f5d1427 100755 --- a/rel/files/riak-admin +++ b/rel/files/riak-admin @@ -14,214 +14,15 @@ SCRIPT=`basename $0` usage() { echo "Usage: $SCRIPT { cluster | join | leave | backup | restore | test | " echo " reip | js-reload | erl-reload | wait-for-service | " - echo " ringready | transfers | force-remove | down |" + echo " ringready | transfers | force-remove | down | push |" echo " cluster-info | member-status | ring-status | vnode-status |" - echo " aae-status | diag | stat | status | transfer-limit | reformat-indexes |" - echo " top [-interval N] [-sort reductions|memory|msg_q] [-lines N] |" + echo " aae-status | diag | status | transfer-limit |" + echo " reformat-indexes | top [-interval N] [-sort reductions|memory|msg_q] [-lines N] |" echo " downgrade-objects | security | bucket-type | repair-2i |" echo " search | services | ensemble-status | handoff | set |" echo " show | describe }" } -stat_admin() -{ - case "$1" in - show) - shift - relx_nodetool rpc riak_core_console stat_show "$*" - ;; - info) - shift - relx_nodetool rpc riak_core_console stat_info "$*" - ;; - enable) - shift - relx_nodetool rpc riak_core_console stat_enable "$*" - ;; - disable) - shift - relx_nodetool rpc riak_core_console stat_disable "$*" - ;; - reset) - shift - relx_nodetool rpc riak_core_console stat_reset "$*" - ;; - help) - shift - case $1 in - show) - stat_show_help - ;; - enable) - stat_enable_help - ;; - disable) - stat_enable_help - ;; - info) - stat_info_help - ;; - *) - stat_help - esac - ;; - *) - stat_help - esac -} - -stat_help() -{ - echo "\ -Usage: $SCRIPT stat - -The following commands display, enable/disable and reset statistics. -A statistics entry is given either as a 'dotted' exometer name - -Identifiers separated by periods, '.', e.g. riak.riak_kv.node.gets, -or as a 'legacy' name (same as in riak-admin status) - e.g. node_gets. -When a legacy name is listed, the corresponding exometer name is shown as well. - -Two kinds of wildcard are suppored: -* - matches anything up to the next separator ('.' or '_') or end of name; -** - matches anything including separators. -Quoting is permitted. - -Use \`$SCRIPT stat help \` for more details. - - show Show the value(s) of a specific entry or entries - enable Enable entry or entries - disable Disable entry or entries - reset Reset entry or entries - info [ -name | -type | Display information about the entry or entries. - | -module The attributes are described in the Exometer docs - | -value | -cache - | -status | -timestamp - | -options | -ref - | -datapoints ] -" -} - -stat_show_help() -{ - echo "\ -Usage: $SCRIPT stat show [/type=][/status=][/[,]] - -Show matching stats entries together with corresponding values - -The format of can be one of: -- 'Dotted exometer name': In Exometer, entries are represented as [A,B,...]. -These names can be emulated on the command-line as A.B.... Wildcards are -supported: '*' will match anything between deliminators (dots), whereas -'**' will match anything including deliminators. Thus \`stat show \"*.**\"\` -will match all stats entries. All Riak stat entry names start with 'riak', -so \`stat show riak.**\` will match all riak stat entries. - -Example: -\$ bin/riak-admin stat show riak.riak_kv.node.gets -[riak,riak_kv,node,gets]: [{count,0},{one,0}] - -- 'Legacy name': The stat names used e.g. in \`$SCRIPT status\` can be used -here, but also with wildcard support. The corresponding Exometer name and -datapoint will be shown as well. - -Example: -\$ bin/riak-admin stat show node_gets -== node_gets (Legacy pattern): == -node_gets: 0 ([riak,riak_kv,node,gets]/one) - -(Note: A single '*' is treated as a legacy name and would match all such -names that contain no underscores; to match all exometer names, a '.' must -be present, so '*.**' would work as a catch-all expression.) - -Each Exometer entry has a type and a set of datapoints. A filter can be -given on the command line, selecting only a subset of datapoints: - -\$ bin/riak-admin stat show riak.riak_kv.node.gets/one -[riak,riak_kv,node,gets]: [{one,0}] - -The type can also be restricted: -\$ bin/riak-admin stat show *.**/type=duration/mean,max -[riak,riak_core,converge_delay]: [{mean,0},{max,0}] -[riak,riak_core,rebalance_delay]: [{mean,0},{max,0}] - -Note how multiple datapoints are separated by comma (no space). - -Showing disabled entries: -\$ bin/riak-admin stat show riak.riak_kv.node.gets -No matching stats -\$ bin/riak-admin stat show riak.riak_kv.node.gets/status=* -[riak,riak_kv,node,gets]: disabled -\$ bin/riak-admin stat show riak.riak_kv.node.gets/status=disabled -[riak,riak_kv,node,gets]: disabled -" -} - -stat_enable_help() -{ - echo "\ -Exometer stats can be disabled and enabled, and this can be done from $SCRIPT -using \`$SCRIPT enable|disable \`. Disabled entries are not actively -updated, and have no value. - -The same syntax can be used as in \`stat show\`. The requested action will be -performed on the matching entries. - -\$ bin/riak-admin stat disable node_gets -== node_gets (Legacy pattern): == -[riak,riak_kv,node,gets]: disabled -\$ bin/riak-admin stat enable node_gets -== node_gets (Legacy pattern): == -[riak,riak_kv,node,gets]: enabled - -Wildcards can be used: - -\$ bin/riak-admin stat disable riak.riak_kv.node.* -[riak,riak_kv,node,gets]: disabled -[riak,riak_kv,node,puts]: disabled -" -} - -stat_info_help() -{ - echo "\ -Display Exometer meta-data for matching entries. Type of data can be controlled -with options: - - info [ -name | -type - | -module - | -value | -cache - | -status | -timestamp - | -options | -ref - | -datapoints ] - -The same entry formats can be used as for all other stat subcommands. - -Example: -\$ bin/riak-admin stat info riak.riak_kv.node.gets -[riak,riak_kv,node,gets]: name = [riak,riak_kv,node,gets] - type = spiral - module = exometer_spiral - value = disabled - cache = 0 - status = disabled - timestamp = undefined - options = [{status,disabled}] - -\$ bin/riak-admin stat info -type -status riak.riak_kv.node.gets -[riak,riak_kv,node,gets]: type = spiral - status = disabled -" -} - -stat_reset_help() -{ - echo "\ -Usage: $SCRIPT stat reset - -Reset matching stat entries. Only enabled entries can be reset. -" -} - cluster_admin() { case "$1" in @@ -1005,10 +806,6 @@ case "$1" in shift cluster_admin "$@" ;; - stat) - shift - stat_admin "$@" - ;; bucket-type) shift btype_admin "$@" diff --git a/rel/files/riak-stat b/rel/files/riak-stat new file mode 100755 index 000000000..48283a4fd --- /dev/null +++ b/rel/files/riak-stat @@ -0,0 +1,616 @@ +#!/bin/sh +# -*- tab-width:4;indent-tabs-mode:nil -*- +# ex: ts=4 sw=4 et + +# Keep track of where script was invoked +ORIGINAL_DIR=$(pwd) + +# Make sure CWD is set to runner run dir +cd $RUNNER_BASE_DIR + +# Identify the script name +SCRIPT=`basename $0` + +usage() { + echo "Usage: $SCRIPT stat { show | info | enable | disable | reset" + echo " metadata | help | push | profile }" +} + +profile_admin() +{ + if [ -n "$2" ]; then + case "$1" in + load) + shift + relx_nodetool rpc riak_core_stat_persist load_profile "$*" + ;; + load-all) + shift + relx_nodetool rpc riak_core_stat_persist load_profile_all "$*" + ;; + save) + shift + relx_nodetool rpc riak_core_stat_persist save_profile "$*" + ;; + delete) + shift + relx_nodetool rpc riak_core_stat_persist delete_profile "$*" + ;; + help) + case "$2" in + load) + profile_load_help + ;; + load-all) + profile_load_help + ;; + save) + profile_save_help + ;; + delete) + profile_delete_help + ;; + reset) + profile_reset_help + ;; + *) + profile_help + esac + ;; + *) + profile_help + esac + + elif [ -z "$2" ]; then + case "$1" in + help) + profile_help + ;; + reset) + shift + relx_nodetool rpc riak_core_stat_persist reset_profile + ;; + *) + profile_help + esac + fi +} + +profile_help() +{ + echo "\ + + Usage: $SCRIPT stat profile (load | save | delete | reset | help) + + Profiles are the specific set up of stats, whether enabled or disabled, + saved in the metadata to allow consistency in testing and laziness in + setting up. + + load Loads the stats configuration saved under + + save Takes the current configuration of stats and saves + under + + delete Deletes the from metadata, does not affect the + configuration of stats + + reset Reset the configuration of stats back to enabled, + unload any profile - does not affect the stats values. + + " +} + +profile_load_help() +{ + echo "\ + + Usage: $SCRIPT profile load + $SCRPIT profile load-all + + Load all the stats in a \`profile\`, changing any stats with a different + cnofiguration to the one in the profile. + + A profile created on a different node in the cluster can be loaded on + another node or all nodes at once. + + Any profile loaded before shutdown will be reloaded after reboot. + + Example: + \$ riak stat profile load test-profile + + " +} + +profile_save_help() +{ + echo "\ + + Usage: $SCRIPT profile save + + Save as the profile's name for the current configuration of stats, + if a profile of that name already exists then it will be overwritten. + + Example: + \$ riak stat profile save test-profile + + " +} + +profile_delete_help() +{ + echo "\ + + Usage: $SCRIPT profile delete + + Delete the profile from the metadata for all nodes in the cluster, it will + remove it's record from the metadata but not affect the stats and their + current status. + + Example: + \$ riak stat profile delete test-profile + + " +} + +profile_reset_help() +{ + echo "\ + + Usage: $SCRIPT profile reset + + Remove the profile current loaded (without deletion), re-enable all the + stats that are disabled in exometer + + Example: + \$ riak stat profile reset + + " +} + +push_admin() +{ + if [ -n "$2" ]; then + case "$1" in + setup) + if [ -n "$4" ] && [[ "$3" == @(udp|tcp) ]]; then + shift + relx_nodetool rpc riak_core_console setup "$@" + else + echo "No Instance name Entered or wrong Protocol type" + push_setup_help + fi + ;; + setdown) + shift + relx_nodetool rpc riak_core_console setdown "$@" + ;; + info) + shift + relx_nodetool rpc riak_core_console find_push_stats "$@" + ;; + info-all) + shift + relx_nodetool rpc riak_core_console find_push_stats_all "$@" + ;; + help) + case "$2" in + setup) + push_setup_help + ;; + setdown) + push_setdown_help + ;; + info) + push_info_help + ;; + info-all) + push_info_all_help + ;; + *) + push_help + esac + ;; + *) + push_help + esac + elif [ -z "$2" ]; then + case "$1" in + help) + push_help + ;; + *) + echo "No Argument Entered" + esac + fi +} + +push_help() +{ + echo "\ + + Usage: $SCRIPT push (setup | setdown | info | info-all) + :: : [] + + Control the polling of stats from exometer and the output to an endpoint + using UDP and TCP protocols. + + setup : [] + + setdown (specific) + | (all instances of that protocol) + | [[:] []] []] + + info [[:] []] []] + (return information about current and previous setups of + this nodes stat pushing) + + info-all : [ []] + (return information about current and previous setups of + all nodes in the cluster, for stat pushing) + + name without spaces + tcp | udp | * + serverip | hostname + 0...65535 + riak.. + (see riak stat help) + + " +} + +push_setup_help() +{ + echo "\ + + Usage: $SCRIPT push setup : [] + + Setup the polling of stats in exometer and pushing to an endpoint of + the hostname:port provided. + + ipaddr | hostname + 0...65535 + tcp | udp + name of instance (no spaces) + as riak admin stat show etc... + + If is not provided all the stats are polled by default (enabled ones) + + Example : + \$ riak stat push setup 127.0.0.1:8000 udp test-udp riak.riak_kv.node.** + + " +} + +push_setdown_help() +{ + echo "\ + + Usage: $SCRIPT push setdown [[[:] []] ] + + Stop the polling and pushing of stats to an endpoint, It is best to give the + instance of the setup specifically - as the instances are unique to each one. + Multiple instances can be shutdown at once if calling for a generic denominator + + For Example: + + \$ riak stat push setdown tcp + (will stop all tcp instances) + + \$ riak stat push setdown *:8080 udp + (stops udp instances going to 8080 port, of any host) + + " +} + +push_info_help() +{ + echo "\ + + Usage: $SCRIPT push info [[] []] ] + + Find all the instances with details given on this node. + Works in a smiilar way to \`riak stat push setdown __\`, information on + multiple instances can be returned if a generic denominator is called. + + For Example: + + \$ riak stat push info tcp + (will return information on all tcp instances + + \$ riak stat push info *:8080 udp + (will return information on udp instances that a pushing to + a port : 8080) + + \$ riak stat push info * + (will return information on everything + + " +} + +push_info_all_help() +{ + echo "\ + + Usage: $SCRIPT push info-all [[] []] ] + + works in the same way as \`riak stat push info ___\` except it returns + the information on instances for all the nodes. + + " +} + +stat_admin() +{ + if [ -n "$2" ]; then + case "$1" in + show) + shift + relx_nodetool rpc riak_core_console show_stat "$*" + ;; + info) + shift + relx_nodetool rpc riak_core_console stat_info "$*" + ;; + enable) + shift + relx_nodetool rpc riak_core_console stat_enable "$*" + ;; + disable) + shift + relx_nodetool rpc riak_core_console stat_disable "$*" + ;; + reset) + shift + relx_nodetool rpc riak_core_console reset_stat "$*" + ;; + metadata) + case "$2" in + enable|disable|status) + relx_nodetool rpc riak_core_console stat_metadata "$2" + ;; + *) + echo "Wrong Argument Type entered" + stat_metadata_help + esac + ;; + help) + case "$2" in + show) + stat_show_help + ;; + enable) + stat_enable_help + ;; + disable) + stat_enable_help + ;; + info) + stat_info_help + ;; + reset) + stat_reset_help + ;; + metadata) + stat_metadata_help + ;; + *) + help + esac + ;; + *) + help + esac + + else + case "$1" in + help) + help + ;; + *) + usage + esac + fi +} + + +help() +{ +echo "\ + + Usage: $SCRIPT stat + + The following commands display, enable/disable and reset stats. + A stats entry is given either as a 'dotted' exometer name - with + Identifiers separated by periods, '.', e.g. riak.riak_kv.node.gets, + or as a 'legacy' name (same as in riak-admin status) - e.g. node_gets. + When a legacy name is listed, the corresponding exometer name is shown as well. + + Two kinds of wildcard are suppored: + * - matches anything up to the next separator ('.' or '_') or end of name; + ** - matches anything including separators. + Quoting is permitted. + + Use \`$SCRIPT admin stat help \` for more details. + + show Show the value(s) of a specific entry or entries + enable Enable entry or entries + disable Disable entry or entries + reset Reset entry or entries + info [ -name | -type | Display information about the entry or entries. + | -module The attributes are described in the Exometer docs + | -value | -cache + | -status | -timestamp + | -options | -ref + | -datapoints ] + + Additional Functions : + + Enable the persistence of stats and their configuration, as well as house the profiles + functionality, gives more control over the use and status of all stats within riak + + metadata :: enable | disable + Enables or disables the use of metadata in riak_stat, disabling the + metadata will prevent the persistence of stats configuration + +" +} + +stat_show_help() +{ + echo "\ + + Usage: $SCRIPT stat show [/type=][/status=][/[,]] + + Show matching stats entries together with corresponding values + + The format of can be one of: + - 'Dotted exometer name': In Exometer, entries are represented as [A,B,...]. + These names can be emulated on the command-line as A.B.... Wildcards are + supported: '*' will match anything between deliminators (dots), whereas + '**' will match anything including deliminators. Thus \`stat show \"*.**\"\` + will match all stats entries. All Riak stat entry names start with 'riak', + so \`stat show riak.**\` will match all riak stat entries. + + Example: + \$ riak stat show riak.riak_kv.node.gets + [riak,riak_kv,node,gets]: [{count,0},{one,0}] + + - 'Legacy name': The stat names used e.g. in \`$SCRIPT admin status\` can be used + here, but also with wildcard support. The corresponding Exometer name and + datapoint will be shown as well. + + Example: + \$ riak stat show node_gets + == node_gets (Legacy pattern): == + node_gets: 0 ([riak,riak_kv,node,gets]/one) + + (Note: A single '*' is treated as a legacy name and would match all such + names that contain no underscores; to match all exometer names, a '.' must + be present, so '*.**' would work as a catch-all expression.) + + Each Exometer entry has a type and a set of datapoints. A filter can be + given on the command line, selecting only a subset of datapoints: + + \$ riak stat show riak.riak_kv.node.gets/one + [riak,riak_kv,node,gets]: [{one,0}] + + The type can also be restricted: + \$ riak stat show *.**/type=duration/mean,max + [riak,riak_core,converge_delay]: [{mean,0},{max,0}] + [riak,riak_core,rebalance_delay]: [{mean,0},{max,0}] + + Note how multiple datapoints are separated by comma (no space). + + Showing disabled entries: + \$ riak stat show riak.riak_kv.node.gets + No matching stats + \$ riak stat show riak.riak_kv.node.gets/status=* + [riak,riak_kv,node,gets]: disabled + \$ riak stat show riak.riak_kv.node.gets/status=disabled + [riak,riak_kv,node,gets]: disabled +" +} + +stat_enable_help() +{ + echo "\ + + Exometer stats can be disabled and enabled, and this can be done + using \`$SCRIPT stat enable|disable \`. Disabled entries are not actively + updated, and have no value. + + The same syntax can be used as in \`stat show\`. The requested action will be + performed on the matching entries. + + \$ riak stat disable node_gets + == node_gets (Legacy pattern): == + [riak,riak_kv,node,gets]: disabled + \$ riak stat enable node_gets + == node_gets (Legacy pattern): == + [riak,riak_kv,node,gets]: enabled + + Wildcards can be used: + + \$ riak stat disable riak.riak_kv.node.* + [riak,riak_kv,node,gets]: disabled + [riak,riak_kv,node,puts]: disabled +" +} + +stat_info_help() +{ + echo "\ + + Usage: $SCRIPT stat info [- [-]] + + Display Exometer meta-data for matching entries. Type of data can be controlled + with options: + + info [ -name + | -type + | -module + | -value + | -cache + | -status + | -timestamp + | -options + | -ref + | -datapoints ] + + The same entry formats can be used as for all other stat subcommands. + + Example: + \$ riak stat info riak.riak_kv.node.gets + [riak,riak_kv,node,gets]:[{name,[riak,riak_kv,node,gets]}, + {type,spiral}, + {module,exometer_spiral}, + {value,disabled}, + {cache,0}, + {status,disabled}, + {timestamp,undefined}, + {options,[{status,disabled}]}] + + \$ riak stat info -type -status riak.riak_kv.node.gets + [riak,riak_kv,node,gets]:[{type,spiral}, + {status,disabled}] +" +} + +stat_reset_help() +{ + echo "\ + + Usage: $SCRIPT stat reset + + Reset matching stat entries. Only enabled entries can be reset. +" +} + +stat_metadata_help() +{ + echo "\ + + Usage $SCRIPT stat metadata = enable | disable | status + + Enable or Disable the persistence of stat options and configuration in + the metadata. Disabling would mean the status of the stat, i.e. whether + it is enabled or disabled would not be persisted, meaning on reboot the + stat will be enabled as default. + +" +} + +case "$1" in + profile) + shift + profile_admin "$@" + ;; + push) + shift + push_admin "$@" + ;; + *) + stat_admin "$@" +esac + +exit 0 \ No newline at end of file diff --git a/rel/pkg/Makefile b/rel/pkg/Makefile new file mode 100644 index 000000000..81bf3c246 --- /dev/null +++ b/rel/pkg/Makefile @@ -0,0 +1,91 @@ +## +## Export all variables to sub-invocation +## +export + +OS = $(shell uname -s) +ERLANG_BIN ?= $(shell dirname $(shell which erl)) +DEPS_DIR ?= deps + +## +## Support RPM and Debian based linux systems +## +ifeq ($(OS),Linux) +ARCH = $(shell uname -m) +ISRPM = $(shell cat /etc/redhat-release 2> /dev/null) +ISDEB = $(shell cat /etc/debian_version 2> /dev/null) +ISSLES = $(shell cat /etc/SuSE-release 2> /dev/null) +ifneq ($(ISRPM),) +OSNAME = RedHat +PKGERDIR = rpm +BUILDDIR = rpmbuild +else +ifneq ($(ISDEB),) +OSNAME = Debian +PKGERDIR = deb +BUILDDIR = debuild +else +ifneq ($(ISSLES),) +OSNAME = SLES +PKGERDIR = rpm +BUILDDIR = rpmbuild +endif # SLES +endif # deb +endif # rpm +endif # linux + +ifeq ($(OS),Darwin) # OSX +OSNAME = OSX +ARCH = $(shell file `which erlc` | grep -c x86_64 2> /dev/null | awk \ + '{if ($$1 == "0") {print "i386"} else {print "x86_64"}}') +PKGERDIR = osx +BUILDDIR = osxbuild +endif + +ifeq ($(OS),FreeBSD) +OSNAME = FreeBSD +ARCH = $(shell uname -m) +BUILDDIR = fbsdbuild +PKGNG = $(shell uname -r | awk -F. '{ print ($$1 > 9) ? "true" : "false" }') +ifeq ($(PKGNG),true) # FreeBSD 10.0 or greater +PKGERDIR = fbsdng +else # Older FreeBSD pkg_add +PKGERDIR = fbsd +endif +endif + +ifeq ($(OS),SunOS) # Solaris flavors +KERNELVER = $(shell uname -v | grep -c joyent 2> /dev/null) +ARCH = $(shell file `which erlc` | grep -c 64-bit 2> /dev/null | awk \ + '{if ($$1 == "0") {print "i386"} else {print "x86_64"}}') + +ifneq ($(KERNELVER),0) # SmartOS +OSNAME = SmartOS +PKGERDIR = smartos +BUILDDIR = smartosbuild +else # Solaris / OmniOS +DISTRO = $(shell head -1 /etc/release|awk \ + '{if ($$1 == "OmniOS") {print $$1} else {print "Solaris"}}') +OSNAME = ${DISTRO} +PKGERDIR = solaris +BUILDDIR = solarisbuild +endif + +endif + +DATE = $(shell date +%Y-%m-%d) + +# Default the package build version to 1 if not already set +PKG_BUILD ?= 1 + +.PHONY: ostype varcheck + +## Call platform dependent makefile +ostype: varcheck + $(if $(PKGERDIR),,$(error "Operating system '$(OS)' not supported by node_package")) + $(MAKE) -C $(PKGERDIR) -f Makefile + +## Check required settings before continuing +varcheck: + $(if $(PKG_VERSION),,$(error "Variable PKG_VERSION must be set and exported, see basho/node_package readme")) + $(if $(PKG_ID),,$(error "Variable PKG_ID must be set and exported, see basho/node_package readme")) diff --git a/rel/pkg/deb/Makefile b/rel/pkg/deb/Makefile new file mode 100644 index 000000000..79fda8215 --- /dev/null +++ b/rel/pkg/deb/Makefile @@ -0,0 +1,19 @@ + +default: + ln -sf $(PKG_ID).tar.gz ../{{package_name}}_$(PKG_VERSION).orig.tar.gz + export DEBFULLNAME="{{vendor_contact_name}}"; \ + export DEBEMAIL="{{vendor_contact_email}}"; \ + dch --create --package {{package_name}} -v "$(PKG_VERSION)-$(PKG_BUILD)" \ + "Build from $(PKG_VERSION)";\ + debuild --prepend-path=$(ERLANG_BIN) \ + -e REVISION=$(PKG_VERSION) \ + -e RELEASE=$(PKG_BUILD) \ + -e REBAR=$(REBAR) \ + {{debuild_extra_options}} \ + -uc -us + mkdir -p ../packages + cd .. && mv *$(PKG_VERSION)-$(PKG_BUILD)_*.deb packages + cd ../packages && \ + for debfile in *.deb; do \ + sha256sum $${debfile} > $${debfile}.sha \ + ; done diff --git a/rel/pkg/deb/compat b/rel/pkg/deb/compat new file mode 100644 index 000000000..7f8f011eb --- /dev/null +++ b/rel/pkg/deb/compat @@ -0,0 +1 @@ +7 diff --git a/rel/pkg/deb/control b/rel/pkg/deb/control new file mode 100644 index 000000000..37090553f --- /dev/null +++ b/rel/pkg/deb/control @@ -0,0 +1,16 @@ +Source: {{package_name}} +Section: net +Priority: extra +Maintainer: {{vendor_contact_name}} <{{vendor_contact_email}}> +Build-Depends: debhelper (>= 7) +Standards-Version: 3.9.3 +Homepage: {{vendor_url}} + +Package: {{package_name}} +Architecture: any +Depends: ${misc:Depends}, ${shlibs:Depends}, adduser, logrotate, sudo, {{deb_depends}} +Homepage: {{vendor_url}} +Description: {{package_shortdesc}} + {{package_desc}} +{{package_replacement_line}} +{{package_conflicts_line}} diff --git a/rel/pkg/deb/copyright b/rel/pkg/deb/copyright new file mode 100644 index 000000000..d02cb9889 --- /dev/null +++ b/rel/pkg/deb/copyright @@ -0,0 +1,8 @@ +Format: http://dep.debian.net/deps/dep5 +Upstream-Name: {{package_name}} +Upstream-Contact: {{vendor_contact_name}} <{{vendor_contact_email}}> + +Files: * +Copyright: {{copyright}} +License: {{license_type}} + {{license_full_text}} diff --git a/rel/pkg/deb/deb.template b/rel/pkg/deb/deb.template new file mode 100644 index 000000000..1f0c07c13 --- /dev/null +++ b/rel/pkg/deb/deb.template @@ -0,0 +1,41 @@ +%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*- +%% +{variables, [ + {package_name, "package_name"}, + {package_install_name, "package_install_name"}, + {package_install_user, "package_install_user"}, + {package_install_user_desc, "package_install_user_desc"}, + {package_install_group, "package_install_group"}, + {package_replacement_line, "{{package_replacement_line_debian}}"}, + {package_conflicts_line, "{{package_conflicts_line_debian}}"}, + {vendor_name, "vendor_name"}, + {vendor_url, "vendor_url"}, + {vendor_contact_name, "vendor_contact_name"}, + {vendor_contact_email, "vendor_contact_email"}, + {copyright, "copyright"}, + {license_type, "license_type"}, + {license_full_text, ""}, + {bin_or_sbin, "bin"}, + + %% Platform Specific Settings + {platform_bin_dir, "/usr/{{bin_or_sbin}}"}, + {platform_data_dir, "/var/lib/{{package_install_name}}"}, + {platform_etc_dir, "/etc/{{package_install_name}}"}, + {platform_base_dir, "/usr/lib/{{package_install_name}}"}, + {platform_lib_dir, "/usr/lib/{{package_install_name}}/lib"}, + {platform_log_dir, "/var/log/{{package_install_name}}"} + ] +}. +{template, "Makefile", "Makefile"}. +{template, "compat", "compat"}. +{template, "control", "control"}. +{template, "copyright", "copyright"}. +{template, "dirs", "dirs"}. +{template, "install", "install"}. +{template, "postinst", "postinst"}. +{template, "postrm", "postrm"}. +{template, "rules", "rules"}. +{template, "vars.config", "vars.config"}. +{template, "init.script", "{{package_name}}.{{package_install_name}}.init"}. +{template, "package.service", "{{package_name}}.{{package_install_name}}.service"}. +{template, "package.manpages", "{{package_name}}.manpages"}. diff --git a/rel/pkg/deb/dirs b/rel/pkg/deb/dirs new file mode 100644 index 000000000..3220e0d31 --- /dev/null +++ b/rel/pkg/deb/dirs @@ -0,0 +1,2 @@ +etc/logrotate.d +var/log/{{package_install_name}} diff --git a/rel/pkg/deb/init.script b/rel/pkg/deb/init.script new file mode 100755 index 000000000..c0fbd9055 --- /dev/null +++ b/rel/pkg/deb/init.script @@ -0,0 +1,152 @@ +#! /bin/bash +### BEGIN INIT INFO +# Provides: {{package_name}} +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: {{package_shortdesc}} +# Description: {{package_desc}} +### END INIT INFO + +NAME={{package_install_name}} +DAEMON=/usr/{{bin_or_sbin}}/$NAME +SCRIPTNAME=/etc/init.d/$NAME +RUNDIR=/var/run/$NAME + +# Read configuration variable file if it is present +[ -r /etc/default/$NAME ] && . /etc/default/$NAME + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh +. /lib/lsb/init-functions + +# `service` strips all environmental VARS so +# if no HOME was set in /etc/default/$NAME then set one here +# to the data directory for erlexec's sake +if [ -z "$HOME" ]; then + export HOME={{platform_data_dir}} +fi + +# +# Function that starts the daemon/service +# +do_start() +{ + if [ ! -d $RUNDIR ]; then + mkdir $RUNDIR + chown {{package_install_user}}:{{package_install_group}} $RUNDIR + fi + # Return + # 0 if daemon has been started + # 1 if daemon was already running + # 2 if daemon could not be started + + # Startup with the appropriate user + start-stop-daemon --start \ + --name {{package_install_name}} \ + --user {{package_install_user}} \ + --exec $DAEMON -- start \ + || return 2 +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + # Identify the erts directory + ERTS_PATH=`$DAEMON ertspath` + + # Attempt a clean shutdown. + $DAEMON stop + + # Return + # 0 if daemon has been stopped + # 1 if daemon was already stopped + # 2 if daemon could not be stopped + # other if a failure occurred + # Make sure it's down by using a more direct approach + start-stop-daemon --stop \ + --quiet \ + --retry=TERM/30/KILL/5 \ + --user {{package_install_user}} \ + --exec $ERTS_PATH/run_erl + return $? +} + +# +# Function that graceful reload the daemon/service +# +do_reload() { + # Restart the VM without exiting the process + $DAEMON restart && return $? || return 2 +} + +# Checks the status of a node +do_status() { + $DAEMON ping && echo $"$NAME is running" && return 0 + echo $"$NAME is stopped" && return 2 +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $NAME" + $DAEMON ping >/dev/null 2>&1 && echo $"$NAME is already running" && exit 0 + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 + exit 1 + ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 + exit 1 + ;; + esac + ;; + ping) + # See if the VM is alive + $DAEMON ping || exit $? + ;; + reload|force-reload) + log_daemon_msg "Reloading $NAME" + do_reload + ES=$? + log_end_msg $ES + exit $ES + ;; + restart) + log_daemon_msg "Restarting $NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 && exit 1 ;; # Old process is still running + *) log_end_msg 1 && exit 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 && exit 1 + ;; + esac + ;; + status) + do_status && exit 0 || exit $? + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|ping|restart|force-reload|status}" >&2 + exit 3 + ;; +esac + +: diff --git a/rel/pkg/deb/install b/rel/pkg/deb/install new file mode 100644 index 000000000..5f314b5f2 --- /dev/null +++ b/rel/pkg/deb/install @@ -0,0 +1,10 @@ +rel/{{package_install_name}}/lib usr/lib/{{package_install_name}} +rel/{{package_install_name}}/erts* usr/lib/{{package_install_name}} +rel/{{package_install_name}}/releases usr/lib/{{package_install_name}} + +{{#package_commands}} +rel/{{package_install_name}}/bin/{{name}} usr/{{bin_or_sbin}} +{{/package_commands}} + +rel/{{package_install_name}}/etc/* etc/{{package_install_name}} +rel/{{package_install_name}}/data/* var/lib/{{package_install_name}} \ No newline at end of file diff --git a/rel/pkg/deb/package.manpages b/rel/pkg/deb/package.manpages new file mode 100644 index 000000000..e3db37c1b --- /dev/null +++ b/rel/pkg/deb/package.manpages @@ -0,0 +1 @@ +doc/man/man1/*.1.gz \ No newline at end of file diff --git a/rel/pkg/deb/package.service b/rel/pkg/deb/package.service new file mode 100644 index 000000000..751414252 --- /dev/null +++ b/rel/pkg/deb/package.service @@ -0,0 +1,14 @@ +[Unit] +Description={{package_shortdesc}} + +[Service] +ExecStart=/usr/{{bin_or_sbin}}/{{package_install_name}} start +ExecStop=/usr/{{bin_or_sbin}}/{{package_install_name}} stop +User={{package_install_user}} +Type=forking +PIDFile=/var/run/{{package_install_name}}/{{package_install_name}}.pid +EnvironmentFile=-/etc/default/{{package_install_name}} +RuntimeDirectory={{package_install_name}} + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/rel/pkg/deb/postinst b/rel/pkg/deb/postinst new file mode 100755 index 000000000..88f272a5f --- /dev/null +++ b/rel/pkg/deb/postinst @@ -0,0 +1,44 @@ +#!/bin/sh +# postinst script for {{package_name}} +# +# see: dh_installdeb(1) + +set -e + +# create group +if ! getent group {{package_install_group}} >/dev/null; then + addgroup --system {{package_install_group}} +fi + +# create user +if ! getent passwd {{package_install_user}} >/dev/null; then + adduser --ingroup {{package_install_group}} \ + --home /var/lib/{{package_install_name}} \ + --disabled-password \ + --system --shell /bin/bash --no-create-home \ + --gecos "{{package_install_user_desc}}" {{package_install_user}} +fi + +for i in lib log; do + chown -R {{package_install_user}}:{{package_install_group}} /var/$i/{{package_install_name}} +done + +case "$1" in + configure) + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/rel/pkg/deb/postrm b/rel/pkg/deb/postrm new file mode 100755 index 000000000..df83a1fb8 --- /dev/null +++ b/rel/pkg/deb/postrm @@ -0,0 +1,61 @@ +#!/bin/sh +# postrm script for {{package_name}} +# +# see: dh_installdeb(1) + + +# summary of how this script can be called: +# * `remove' +# * `purge' +# * `upgrade' +# * `failed-upgrade' +# * `abort-install' +# * `abort-install' +# * `abort-upgrade' +# * `disappear' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + +set -e + +case "$1" in + purge) + rm -f /etc/default/{{package_install_name}} + if [ -d /var/log/{{package_install_name}} ]; then + rm -r /var/log/{{package_install_name}} + fi + if [ -d /var/run/{{package_install_name}} ]; then + rm -r /var/run/{{package_install_name}} + fi + if [ -d /etc/{{package_install_name}} ]; then + rm -r /etc/{{package_install_name}} + fi + if [ -e /etc/init.d/{{package_install_name}} ]; then + rm /etc/init.d/{{package_install_name}} + fi + # Remove User & Group, killing any process owned by them + if getent passwd {{package_install_user}} >/dev/null; then + pkill -u {{package_install_user}} || true + deluser --quiet --system {{package_install_user}} + fi + if getent group {{package_install_group}} >/dev/null; then + delgroup --quiet --system --only-if-empty {{package_install_group}} || true + fi + ;; + + remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + *) + echo "postrm called with unknown argument \`$1\`" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/rel/pkg/deb/rules b/rel/pkg/deb/rules new file mode 100755 index 000000000..d06fee81f --- /dev/null +++ b/rel/pkg/deb/rules @@ -0,0 +1,63 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# modified for node_package by dizzyd@basho.com and jared@basho.com + +# Uncomment this to turn on verbose mode. +export DH_VERBOSE=1 + +ROOTDIR := debian/{{package_name}} + +## Clear variables that may confound our build of sub-projects; also +## note that it is necessary to use overlay_vars relative to .. as +## the generate command EXECUTES in rel/ +build: + unset CC CFLAGS CPPFLAGS LDFLAGS CXX CXXFLAGS \ + && OVERLAY_VARS="overlay_vars=../debian/vars.config" make rel + touch build + +clean: + dh_clean + rm -f build + make clean + +## dh_shlibdeps was added to figure out the dependencies on shared libraries +## and will populate the ${shlibs:Depends} callout in the control file +install: LIBDIR := $(ROOTDIR)/usr/lib/{{package_install_name}} +install: build + dh_testdir + dh_testroot + dh_prep + dh_installdirs + dh_install + dh_installman + dh_installinit --name={{package_install_name}} --no-start + dh_fixperms + chmod 0755 $(ROOTDIR)/etc/{{package_install_name}} + chmod -R a+rX $(ROOTDIR)/etc/{{package_install_name}} + for file in lib/env.sh lib/app_epath.sh erts-*/bin/nodetool; do \ + if [ -f $(LIBDIR)/$$file ]; then \ + chmod 0755 $(LIBDIR)/$$file; \ + fi; \ + done + chmod -R go+rX debian/{{package_name}}/usr/lib/{{package_install_name}}/lib/ + dh_shlibdeps + +# We have nothing to do by default. +binary-indep: install build-stamp +build-stamp: + +# Build architecture-dependent files here. +binary-arch: install + dh_strip -a + dh_compress -a + dh_installdeb + dh_gencontrol + dh_builddeb + +binary: binary-indep binary-arch diff --git a/rel/pkg/deb/vars.config b/rel/pkg/deb/vars.config new file mode 100644 index 000000000..6e3f56ed4 --- /dev/null +++ b/rel/pkg/deb/vars.config @@ -0,0 +1,21 @@ +%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*- +%% ex: ft=erlang ts=4 sw=4 et + +%% Platform-specific installation paths +{platform_bin_dir, "{{platform_bin_dir}}"}. +{platform_data_dir, "{{platform_data_dir}}"}. +{platform_etc_dir, "{{platform_etc_dir}}"}. +{platform_base_dir, "{{platform_base_dir}}"}. +{platform_lib_dir, "{{platform_lib_dir}}"}. +{platform_log_dir, "{{platform_log_dir}}"}. + +{runner_script_dir, "{{platform_bin_dir}}"}. +{runner_base_dir, "{{platform_base_dir}}"}. +{runner_etc_dir, "{{platform_etc_dir}}"}. +{runner_log_dir, "{{platform_log_dir}}"}. +{runner_user, "{{package_install_user}}"}. +{runner_lib_dir, "{{platform_lib_dir}}"}. +{runner_patch_dir, "{{platform_lib_dir}}/{{package_patch_dir}}"}. +{pipe_dir, "/tmp/{{package_install_name}}/"}. +{package_replacement_line, "{{package_replacement_line_debian}}"}. +{package_conflicts_line, "{{package_replacement_line_debian}}"}. diff --git a/rel/pkg/out/.gitignore b/rel/pkg/out/.gitignore new file mode 100644 index 000000000..5e7d2734c --- /dev/null +++ b/rel/pkg/out/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/rel/pkg/rpm/Makefile b/rel/pkg/rpm/Makefile new file mode 100644 index 000000000..19e50e426 --- /dev/null +++ b/rel/pkg/rpm/Makefile @@ -0,0 +1,24 @@ + +PWD = $(shell pwd) + + +# No hyphens are allowed in the _version field in RPM +PKG_VERSION_NO_H ?= $(shell echo $(PKG_VERSION) | tr - .) + +default: + rpmbuild --define "_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}$(DISTRO)%%{ARCH}.rpm" \ + --define '_topdir $(BASE_DIR)/rel/pkg/out/' \ + --define '_sourcedir $(BASE_DIR)/rel/pkg/out/' \ + --define '_specdir $(BASE_DIR)/rel/pkg/out/' \ + --define '_rpmdir $(BASE_DIR)/rel/pkg/out/packages' \ + --define '_srcrpmdir $(BASE_DIR)/rel/pkg/out/packages' \ + --define "_revision $(PKG_VERSION)" \ + --define "_version $(PKG_VERSION_NO_H)" \ + --define "_release $(PKG_BUILD)" \ + --define "_tarname riak-$(PKG_ID).tar.gz" \ + --define "_tarname_base riak-$(PKG_ID)" \ + -ba specfile + cd $(BASE_DIR)/rel/pkg/out/packages && \ + for rpmfile in *.rpm; do \ + sha256sum $${rpmfile} > $${rpmfile}.sha \ + ; done diff --git a/rel/pkg/rpm/riak b/rel/pkg/rpm/riak new file mode 100755 index 000000000..3a6372f53 --- /dev/null +++ b/rel/pkg/rpm/riak @@ -0,0 +1,17 @@ +#!/bin/sh + +COMMAND={{platform_bin_dir}}/riak + +if [[ $EUID -ne 0 ]]; then + echo "You need to be root or use sudo to run this command." + exit 1 +fi + +case "$1" in + start|console|foreground) + su - riak -c "PIPE_DIR=${PIPE_DIR} ${COMMAND} ${*} -pa {{platform_lib_dir}}/patches" + ;; + *) + su - riak -c "PIPE_DIR=${PIPE_DIR} ${COMMAND} ${*}" + ;; +esac diff --git a/rel/pkg/rpm/specfile b/rel/pkg/rpm/specfile new file mode 100644 index 000000000..fd9a07412 --- /dev/null +++ b/rel/pkg/rpm/specfile @@ -0,0 +1,150 @@ +## ------------------------------------------------------------------- +## +## Copyright (c) 2014 Basho Technologies, Inc. +## +## This file is provided to you under the Apache License, +## Version 2.0 (the "License"); you may not use this file +## except in compliance with the License. You may obtain +## a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, +## software distributed under the License is distributed on an +## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +## KIND, either express or implied. See the License for the +## specific language governing permissions and limitations +## under the License. +## +## ------------------------------------------------------------------- + +Name: riak +Version: %{_version} +Release: %{_release}%{?dist} +License: "Apacke 2.0" +Group: Development/Libraries +Source: %{_tarname} +URL: "https://riak.com" +Vendor: "Riak" +Packager: "Riak Package Maint" <"packaging@riak.com"> +BuildRoot: %{_tmppath}/%{name}-%{_revision}-%{release}-root +Summary: "Riak is a distributed data store" +Obsoletes: riak + +%description +"Riak is a distributed data store" + +%define init_script %{_sysconfdir}/init.d/riak +%define debug_package %{nil} +%define __prelink_undo_cmd /bin/cat prelink library + +%define platform_data_dir %{_localstatedir}/lib/riak +%define platform_etc_dir %{_sysconfdir}/riak +%define platform_base_dir %{_libdir}/riak +%define platform_bin_dir %{platform_base_dir}/bin +%define platform_lib_dir %{platform_base_dir}/lib +%define platform_log_dir %{_localstatedir}/log/riak + + +%prep +%setup -q -n %{_tarname_base} -c %{_tarname_base} + +# Setup vars.config like other platforms, but do it inside of spec file +cat > rpm.vars.config </dev/null 2>&1; then + groupadd -r riak +fi + +if getent passwd riak >/dev/null 2>&1; then + usermod -d %{_localstatedir}/lib/riak riak || true +else + useradd -r -g riak \ + --home %{_localstatedir}/lib/riak \ + --comment "Riak User" \ + --shell /bin/bash \ + riak +fi + + +%post +# Post Installation Script + +# For distros with SELinux (RHEL/Fedora) +if [ `which selinuxenabled > /dev/null 2>&1` ] ; then + # Fixup perms for SELinux (if it is enabled) + selinuxenabled && find %{_localstatedir}/lib/riak -name "*.so" -exec chcon -t textrel_shlib_t {} \; +fi + +%preun +# Pre-uninstall script + +# Only on uninstall, not upgrades +if [ "$1" = 0 ] ; then + /sbin/service riak stop > /dev/null 2>&1 +fi +exit 0 + + +# Man pages are optional and might be missing, read from file +%files +%defattr(-,riak,riak) +%{_localstatedir}/lib/riak +%{_localstatedir}/log/riak +%{_libdir}/* +%defattr(-,root,root) +%dir %{_sysconfdir}/riak +/usr/bin/* +%config(noreplace) %{_sysconfdir}/riak/* + +%clean +#rm -rf %{buildroot}