3using System.Text.RegularExpressions;
4using System.Threading.Tasks;
19 : base(
@"^(upgrade|update|install)(\s+nobackup)?(\s+[^\s]+){0,2}$")
26 public override string Name =>
"Install";
31 public override string[]
Aliases =>
new string[] {
"Update",
"Upgrade" };
41 public override async Task
Execute(
ChatState State,
string[] Arguments,
string OrgMessage, Match Details,
45 int c = Arguments.Length;
48 if (i < c &&
string.Compare(Arguments[i],
"nobackup",
true) == 0)
55 await
XmppServerModule.Instance.UpdateSoftware(
null, State, Backup, ResponseCallback);
58 string PackageFileName = Arguments[i++];
59 Package Package = await Provisioning.ProvisioningComponent.GetPackage(PackageFileName);
62 await ResponseCallback(
"Package not found.",
string.Empty);
66 string FullFileName = Path.Combine(
XmppServerModule.PackagesFolder, PackageFileName);
67 if (!File.Exists(FullFileName))
69 await ResponseCallback(
"Package file not found.",
string.Empty);
75 await ResponseCallback(
"Reserved package.",
string.Empty);
84 string Key = Arguments[i++];
86 if (Key.Length != 76 && Key.Length != 76 + 32)
88 await ResponseCallback(
"Invalid key.",
string.Empty);
92 PublicKey = Convert.FromBase64String(Key.Substring(0, 76));
101 using (FileStream fs = File.OpenRead(FullFileName))
105 await ResponseCallback(
"Invalid public key.",
string.Empty);
111 Package.PublicKey = PublicKey;
112 Package.AesKey = AesKey;
115 await Persistence.Database.Update(
Package);
129 new HelpItem(
"upgrade",
"Upgrades the software of the service, including installed packages. Performas a backup first."),
130 new HelpItem(
"upgrade PACKAGE",
"Upgrades a specific software package that is already installed. Performas a backup first."),
131 new HelpItem(
"install PACKAGE KEY",
"install a specific software package that is downloaded but not installed. Performas a backup first."),
132 new HelpItem(
"upgrade nobackup",
"Upgrades the software of the service, including installed packages. Does not perform a backup first."),
133 new HelpItem(
"upgrade nobackup PACKAGE",
"Upgrades a specific software package that is already installed. Does not perform a backup first."),
134 new HelpItem(
"install nobackup PACKAGE KEY",
"install a specific software package that is downloaded but not installed. Does not perform a backup first."),
Contains methods for simple hash calculations.
static byte[] StringToBinary(string s)
Parses a hex string.
An administrative command whose syntax is validated with a regular expression.
Contains an item of information about a command.
Upgrades the service to the latest version.
override HelpItem[] GetHelp()
Gets help about the command.
override string[] Aliases
Optional set of aliases. Can be null.
override async Task Execute(ChatState State, string[] Arguments, string OrgMessage, Match Details, ResponseCallbackHandler ResponseCallback)
Executes the command.
Install()
Upgrades the service to the latest version.
override string Name
Command name
Identity of the IoT Broker package.
const string FileName
IoTBroker.package
Contains information about a software package.
byte[] PublicKey
Public key of issuer, used to create signature.
byte[] Signature
Cryptographic signature of package, as calculated by the issuer of the package.
CaseInsensitiveString FileName
Filename of package.
DateTime Published
When package was published.
byte[] AesKey
Symmetric cipher used to encrypt package file.
Service Module hosting the XMPP broker and its components.
delegate Task< string > ResponseCallbackHandler(string Markdown, string MessageId)
Delegate for response callback handler methods.