aboutsummaryrefslogtreecommitdiffstats
path: root/priv
diff options
context:
space:
mode:
Diffstat (limited to 'priv')
-rw-r--r--priv/templates/extended_bin.dtl20
-rw-r--r--priv/templates/install_upgrade_escript.dtl32
2 files changed, 49 insertions, 3 deletions
diff --git a/priv/templates/extended_bin.dtl b/priv/templates/extended_bin.dtl
index 70b4ee2..87f69ba 100644
--- a/priv/templates/extended_bin.dtl
+++ b/priv/templates/extended_bin.dtl
@@ -289,7 +289,25 @@ case "$1" in
fi
exec "$BINDIR/escript" "$ROOTDIR/bin/install_upgrade.escript" \
- "$REL_NAME" "$NAME" "$COOKIE" "$2"
+ "install" "$REL_NAME" "$NAME" "$COOKIE" "$2"
+ ;;
+
+ unpack)
+ if [ -z "$2" ]; then
+ echo "Missing package argument"
+ echo "Usage: $REL_NAME $1 {package base name}"
+ echo "NOTE {package base name} MUST NOT include the .tar.gz suffix"
+ exit 1
+ fi
+
+ # Make sure a node IS running
+ if ! relx_nodetool "ping" > /dev/null; then
+ echo "Node is not running!"
+ exit 1
+ fi
+
+ exec "$BINDIR/escript" "$ROOTDIR/bin/install_upgrade.escript" \
+ "unpack" "$REL_NAME" "$NAME" "$COOKIE" "$2"
;;
console|console_clean|console_boot)
diff --git a/priv/templates/install_upgrade_escript.dtl b/priv/templates/install_upgrade_escript.dtl
index dce2e11..3fb9d04 100644
--- a/priv/templates/install_upgrade_escript.dtl
+++ b/priv/templates/install_upgrade_escript.dtl
@@ -6,8 +6,36 @@
-define(TIMEOUT, 300000).
-define(INFO(Fmt,Args), io:format(Fmt,Args)).
-%% Upgrades, to a new tar.gz release
-main([RelName, NodeName, Cookie, VersionArg]) ->
+%% Unpack or upgrade to a new tar.gz release
+main(["unpack", RelName, NodeName, Cookie, VersionArg]) ->
+ TargetNode = start_distribution(NodeName, Cookie),
+ WhichReleases = which_releases(TargetNode),
+ Version = parse_version(VersionArg),
+ case proplists:get_value(Version, WhichReleases) of
+ undefined ->
+ %% not installed, so unpack tarball:
+ ?INFO("Release ~s not found, attempting to unpack releases/~s/~s.tar.gz~n",[Version,Version,RelName]),
+ ReleasePackage = Version ++ "/" ++ RelName,
+ case rpc:call(TargetNode, release_handler, unpack_release,
+ [ReleasePackage], ?TIMEOUT) of
+ {ok, Vsn} ->
+ ?INFO("Unpacked successfully: ~p~n", [Vsn]);
+ {error, UnpackReason} ->
+ print_existing_versions(TargetNode),
+ ?INFO("Unpack failed: ~p~n",[UnpackReason]),
+ erlang:halt(2)
+ end;
+ old ->
+ %% no need to unpack, has been installed previously
+ ?INFO("Release ~s is marked old, switching to it.~n",[Version]);
+ unpacked ->
+ ?INFO("Release ~s is already unpacked, now installing.~n",[Version]);
+ current ->
+ ?INFO("Release ~s is already installed and current. Making permanent.~n",[Version]);
+ permanent ->
+ ?INFO("Release ~s is already installed, and set permanent.~n",[Version])
+ end;
+main(["install", RelName, NodeName, Cookie, VersionArg]) ->
TargetNode = start_distribution(NodeName, Cookie),
WhichReleases = which_releases(TargetNode),
Version = parse_version(VersionArg),