Пример #1
0
        private static bool IsUpgradeRequired(SshClient client, SmartNodeServer node)
        {
            string version = "UNKNOWN";

            string getInfoResult = runCommand("smartcash-cli getinfo", client);

            if (String.IsNullOrEmpty(getInfoResult))
            {
                logMessage(node, "Not able to get current version");

                //maybe smartcasd crashed, try to run a reindex
                runCommand("smartcashd -reindex > /dev/null 2>&1", client);
            }
            else
            {
                version = returnNodeVersion(getInfoResult);

                if (version.Contains(LATEST_VERSION))
                {
                    string smartNodeSatusResult = runCommand("smartcash-cli smartnode status", client);

                    string nodeStausMessage = returnNodeStatusMessage(smartNodeSatusResult, version);
                    logMessage(node, nodeStausMessage);

                    return(false);
                }
                else
                {
                    return(true);
                }
            }


            return(false);
        }
Пример #2
0
        public static void CheckOrUpdateNode(SmartNodeServer node)
        {
            using (SshClient client = new SshClient(node.hostname, node.user, node.pass))
            {
                try
                {
                    client.Connect();

                    bool upgrade = IsUpgradeRequired(client, node);

                    if (upgrade)
                    {
                        logMessage(node, "Upgrade requested");

                        string cmd = "apt update";
                        cmd += " && apt update";
                        cmd += " && smartcash-cli stop";
                        cmd += " && sleep 5";
                        cmd += " && apt install smartcashd -y";

                        string response = runCommand(cmd, client);

                        //if (!String.IsNullOrEmpty(response))
                        //{
                        //  logMessage(node, "Upgrade completed");
                        //}
                    }

                    client.Disconnect();
                }
                catch (Exception ex)
                {
                    logMessage(node, String.Format("ERROR: {0}", ex.Message));
                }
            }
        }
Пример #3
0
        private static void logMessage(SmartNodeServer node, string msg)
        {
            string consoleMsg = String.Format("[{0}]\t{1}", node.alias, msg);

            Console.WriteLine(consoleMsg);
        }