nanokvm 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c4dbfc58ba42afd4eb0023e7cbbba8fca9d14a970587f0c417ca7f1d5b823363
4
+ data.tar.gz: 1ce5ae6d4fde33cf03996018754e5fa4a80eb94cc3fdb73fa159cdaa4e498922
5
+ SHA512:
6
+ metadata.gz: eecc93304d4412c74d79768ed5cb6032e5a06e26e3b9cd76e89d97d114b2c0772d926ed9a0f0809cd1666b4c01d7ad033462608d9ff753766a385dc27c831ade
7
+ data.tar.gz: fe335aa81f118362864e7c30fe8825e3784978bf638835f2e069ee0806694f26da873dbe30bd01b034c9255daeba3bd437940308c82e9bdde47b009b9467fdec
data/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2025-04-21
9
+
10
+ ### Added
11
+ - Initial release
12
+ - Basic NanoKVM API client
13
+ - CLI interface for common operations
14
+ - Support for authentication, power control, virtual devices, and more
15
+ - Download status now shows time estimates and download speed
16
+ - Added --timeout option to download-status command for limiting monitoring time
17
+ - Download status now includes bytes downloaded and total file size
18
+ - Automatic HTTP file size detection for download URLs
19
+ - Improved progress display with visual progress bar
20
+ - Smooth in-place refresh of download status without screen flickering
21
+
22
+ ### Fixed
23
+ - Fixed error when calculating download speed without size information
24
+ - Fixed timeout display in download monitoring
data/README.md ADDED
@@ -0,0 +1,314 @@
1
+ # NanoKVM Ruby Gem
2
+
3
+ A Ruby library and CLI for controlling NanoKVM devices.
4
+
5
+ ## Installation
6
+
7
+ Install the gem:
8
+
9
+ ```bash
10
+ gem install nanokvm
11
+ ```
12
+
13
+ Or add to your Gemfile:
14
+
15
+ ```ruby
16
+ gem 'nanokvm'
17
+ ```
18
+
19
+ ## CLI Usage
20
+
21
+ The nanokvm command provides a convenient way to interact with your NanoKVM device.
22
+
23
+ ### Configuration
24
+
25
+ First, configure your default device settings:
26
+
27
+ ```bash
28
+ nanokvm configure --host 192.168.1.18 --username admin --password admin
29
+ ```
30
+
31
+ ### Getting Device Info
32
+
33
+ ```bash
34
+ nanokvm info
35
+ ```
36
+
37
+ ### Power Control
38
+
39
+ Press the power button (short press):
40
+
41
+ ```bash
42
+ nanokvm power
43
+ ```
44
+
45
+ Long press (force shutdown):
46
+
47
+ ```bash
48
+ nanokvm power --duration 8000
49
+ ```
50
+
51
+ Press the reset button:
52
+
53
+ ```bash
54
+ nanokvm reset
55
+ ```
56
+
57
+ ### LED Status
58
+
59
+ ```bash
60
+ nanokvm leds
61
+ ```
62
+
63
+ ### Password Status
64
+
65
+ Check if the device is using the default password:
66
+
67
+ ```bash
68
+ nanokvm is-password-updated
69
+ ```
70
+
71
+ ### Virtual Disks
72
+
73
+ List available images:
74
+
75
+ ```bash
76
+ nanokvm images
77
+ ```
78
+
79
+ Mount an image:
80
+
81
+ ```bash
82
+ nanokvm mount /data/ubuntu-24.04-desktop-amd64.iso
83
+ ```
84
+
85
+ ### Virtual Devices
86
+
87
+ Show virtual device status:
88
+
89
+ ```bash
90
+ nanokvm virtual
91
+ ```
92
+
93
+ Toggle virtual network or disk:
94
+
95
+ ```bash
96
+ nanokvm toggle network
97
+ nanokvm toggle disk
98
+ ```
99
+
100
+ ### Type Text
101
+
102
+ Send keyboard input to the target:
103
+
104
+ ```bash
105
+ nanokvm type "ls -la"
106
+ ```
107
+
108
+ ### Tailscale
109
+
110
+ Check Tailscale extension status:
111
+
112
+ ```bash
113
+ nanokvm tailscale
114
+ ```
115
+
116
+ ### Image Download
117
+
118
+ Check if downloading images is enabled:
119
+
120
+ ```bash
121
+ nanokvm download-enabled
122
+ ```
123
+
124
+ Check status of image download:
125
+
126
+ ```bash
127
+ nanokvm download-status
128
+ ```
129
+
130
+ Monitor download progress until completion (includes download speed and time estimate):
131
+
132
+ ```bash
133
+ nanokvm download-status --monitor
134
+ nanokvm download-status --monitor --interval=5 # Update every 5 seconds
135
+ nanokvm download-status --monitor --timeout=60 # Stop monitoring after 60 seconds
136
+ ```
137
+
138
+ Download an image from URL:
139
+
140
+ ```bash
141
+ nanokvm download-image https://releases.ubuntu.com/24.04.2/ubuntu-24.04.2-live-server-amd64.iso
142
+ ```
143
+
144
+ ### Hardware Information
145
+
146
+ Get information about the NanoKVM hardware:
147
+
148
+ ```bash
149
+ nanokvm hardware
150
+ ```
151
+
152
+ ### Memory Management
153
+
154
+ Get or set memory limits:
155
+
156
+ ```bash
157
+ nanokvm memory-limit
158
+ nanokvm memory-limit --enabled=true --limit=512
159
+ ```
160
+
161
+ ### OLED Settings
162
+
163
+ Get or set OLED sleep timeout:
164
+
165
+ ```bash
166
+ nanokvm oled
167
+ nanokvm oled --sleep=60
168
+ ```
169
+
170
+ ### SSH, mDNS and Wake-on-LAN
171
+
172
+ Get SSH server status:
173
+
174
+ ```bash
175
+ nanokvm ssh-status
176
+ ```
177
+
178
+ Get mDNS status:
179
+
180
+ ```bash
181
+ nanokvm mdns
182
+ ```
183
+
184
+ Get Wake-on-LAN MAC address:
185
+
186
+ ```bash
187
+ nanokvm wol-mac
188
+ ```
189
+
190
+ ### CD-ROM and Script
191
+
192
+ Get CD-ROM information:
193
+
194
+ ```bash
195
+ nanokvm cdrom
196
+ ```
197
+
198
+ Get script information:
199
+
200
+ ```bash
201
+ nanokvm script
202
+ ```
203
+
204
+ ### HID Mode and Preview
205
+
206
+ Get or set HID mode:
207
+
208
+ ```bash
209
+ nanokvm hid-mode
210
+ nanokvm hid-mode --mode=usb
211
+ ```
212
+
213
+ Get or set preview state:
214
+
215
+ ```bash
216
+ nanokvm preview
217
+ nanokvm preview --enable=true
218
+ ```
219
+
220
+ ## Ruby Library Usage
221
+
222
+ ### Basic Usage
223
+
224
+ ```ruby
225
+ require 'nanokvm'
226
+
227
+ # Create a client
228
+ client = NanoKVM::Client.new(
229
+ host: "192.168.1.18",
230
+ username: "admin",
231
+ password: "admin"
232
+ )
233
+
234
+ # Authenticate
235
+ client.login
236
+
237
+ # Get device info
238
+ info = client.get_device_info
239
+ puts info.inspect
240
+
241
+ # Press power button
242
+ client.power_button
243
+
244
+ # Mount ISO
245
+ client.mount_image("/data/ubuntu-24.04-desktop-amd64.iso")
246
+
247
+ # Send text
248
+ client.send_text("Hello from Ruby")
249
+ ```
250
+
251
+ ### Configuration
252
+
253
+ You can set default configuration options:
254
+
255
+ ```ruby
256
+ NanoKVM.configure do |config|
257
+ config.default_host = "192.168.1.18"
258
+ config.default_username = "admin"
259
+ config.default_password = "admin"
260
+ end
261
+
262
+ # Now you can create clients without specifying parameters
263
+ client = NanoKVM::Client.new
264
+ client.login
265
+ ```
266
+
267
+ ## Available Methods
268
+
269
+ The client provides these main methods:
270
+
271
+ - `login`
272
+ - `get_device_info`
273
+ - `get_gpio_state`
274
+ - `power_button(duration = 800)`
275
+ - `reset_button(duration = 200)`
276
+ - `get_available_images`
277
+ - `get_mounted_image`
278
+ - `mount_image(file_path)`
279
+ - `get_virtual_device_status`
280
+ - `toggle_virtual_device(device)` (device can be "network" or "disk")
281
+ - `send_text(content)`
282
+ - `reset_hid`
283
+ - `is_password_updated`
284
+ - `get_account_info`
285
+ - `get_network_info`
286
+ - `get_app_version`
287
+ - `system_reboot`
288
+ - `reset_hdmi`
289
+ - `get_tailscale_status`
290
+ - `is_download_image_enabled`
291
+ - `get_download_image_status`
292
+ - `download_image(url)`
293
+ - `get_hardware_info`
294
+ - `get_script_info`
295
+ - `get_memory_limit`
296
+ - `set_memory_limit(enabled, limit_mb)`
297
+ - `get_oled_info`
298
+ - `set_oled_sleep(sleep_seconds)`
299
+ - `get_ssh_status`
300
+ - `get_mdns_status`
301
+ - `get_cdrom_info`
302
+ - `get_wol_mac`
303
+ - `get_hid_mode`
304
+ - `set_hid_mode(mode)`
305
+ - `get_preview_state`
306
+ - `set_preview_state(enable)`
307
+
308
+ ## Contributing
309
+
310
+ Bug reports and pull requests are welcome on GitHub.
311
+
312
+ ## License
313
+
314
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/bin/nanokvm ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ $LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
5
+
6
+ require "nanokvm"
7
+ require "nanokvm/cli"
8
+
9
+ NanoKVM::CLI.start(ARGV)