diff options
author | Jordan Wilberding <[email protected]> | 2015-01-06 23:18:34 -0800 |
---|---|---|
committer | Jordan Wilberding <[email protected]> | 2015-01-06 23:18:34 -0800 |
commit | 8b85968aef3145fb883c9558fd21702100e9ac9f (patch) | |
tree | 2dce5e6d643ee684a5e8bd029f01580c74bf159a /priv/templates/install_upgrade_escript.dtl | |
parent | e045a0fcb860d8a21c143228f40d23b7d42fb784 (diff) | |
parent | 358eb115ddf1530939b1273e88e7f38271b2a3de (diff) | |
download | relx-8b85968aef3145fb883c9558fd21702100e9ac9f.tar.gz relx-8b85968aef3145fb883c9558fd21702100e9ac9f.tar.bz2 relx-8b85968aef3145fb883c9558fd21702100e9ac9f.zip |
Merge pull request #290 from tsloughter/unpack_command
add unpack option to install scripts
Diffstat (limited to 'priv/templates/install_upgrade_escript.dtl')
-rw-r--r-- | priv/templates/install_upgrade_escript.dtl | 32 |
1 files changed, 30 insertions, 2 deletions
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), |