├── lib.js ├── .gitignore ├── SCREENCAP.GIF ├── .gitattributes ├── .github └── workflows │ ├── DEVKING_TRACKER.yml │ ├── DEVKING_CHECK.yml │ ├── DEVKING_CLEANUP.yml │ └── DEVKING_RELEASE.yml ├── package.json ├── CHANGELOG.md ├── README.md ├── app.js └── LICENSE /lib.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | .env.* 3 | node_modules/ -------------------------------------------------------------------------------- /SCREENCAP.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cogsmith/dclone/HEAD/SCREENCAP.GIF -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/workflows/DEVKING_TRACKER.yml: -------------------------------------------------------------------------------- 1 | name: DEVKING_TRACKER 2 | on: 3 | workflow_dispatch: 4 | jobs: 5 | build: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: cogsmith/devking-tracker@main -------------------------------------------------------------------------------- /.github/workflows/DEVKING_CHECK.yml: -------------------------------------------------------------------------------- 1 | name: DEVKING_CHECK 2 | on: 3 | workflow_dispatch: 4 | push: 5 | branches: [ main ] 6 | jobs: 7 | build: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v2 11 | - run: npm -v 12 | - run: npm ci 13 | continue-on-error: true 14 | - run: find . -maxdepth 1 -name '*.js' -exec echo node --check {} \; 15 | - run: find . -maxdepth 1 -name '*.js' -exec node --check {} \; 16 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "npmpublish": true, 3 | "license": "GPLv3", 4 | "version": "0.0.3-dev", 5 | "nametag": "DCLONE", 6 | "namelong": "DCLONE", 7 | "description": "Disk Cloner", 8 | "dependencies": { 9 | "@cogsmith/xt": "^1.0.167", 10 | "ansi-term": "0.0.2", 11 | "blessed": "^0.1.81", 12 | "blessed-contrib": "^4.10.0", 13 | "blessed-xterm": "^1.4.1", 14 | "execa": "^5.1.1" 15 | }, 16 | "versiontaglast": "0.0.2" 17 | } 18 | -------------------------------------------------------------------------------- /.github/workflows/DEVKING_CLEANUP.yml: -------------------------------------------------------------------------------- 1 | name: DEVKING_CLEANUP 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | ACTIONDO: 6 | required: true 7 | default: 'CLEANUP' 8 | description: 'ACTIONDO' 9 | workflow_run: 10 | workflows: ['*'] 11 | types: [completed] 12 | jobs: 13 | build: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v2 17 | with: 18 | fetch-depth: 0 19 | - uses: cogsmith/devking-cleanup@main -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # [0.0.2](https://github.com/cogsmith/dclone/compare/0.0.2...main) @ [2021-07-23](https://github.com/cogsmith/dclone/releases/tag/0.0.2) 4 | 5 | ## DIFF 6 | - [2 COMMITS SINCE LAST TAG = 0.0.1](https://github.com/cogsmith/dclone/compare/0.0.1...0.0.2) 7 | 8 | 9 | 10 | --- 11 | 12 | 13 | # [0.0.1](https://github.com/cogsmith/dclone/compare/0.0.1...main) @ [2021-07-23](https://github.com/cogsmith/dclone/releases/tag/0.0.1) 14 | 15 | ## DIFF 16 | - [ LAST TAG = 0.0.0](https://github.com/cogsmith/dclone/compare/0.0.0...0.0.1) 17 | 18 | 19 | 20 | --- 21 | -------------------------------------------------------------------------------- /.github/workflows/DEVKING_RELEASE.yml: -------------------------------------------------------------------------------- 1 | name: DEVKING_RELEASE 2 | on: 3 | push: 4 | branches: [ main ] 5 | workflow_dispatch: 6 | inputs: 7 | NEXTVERSION: 8 | required: true 9 | default: 'PATCH' 10 | description: 'NEXTVERSION' 11 | jobs: 12 | JOB: 13 | if: | 14 | github.event_name == 'workflow_dispatch' 15 | || ( github.event.head_commit.message == 'TAG' 16 | || github.event.head_commit.message == 'TAG PATCH' 17 | || github.event.head_commit.message == 'TAG MINOR' 18 | || github.event.head_commit.message == 'TAG MAJOR' 19 | || startsWith(github.event.head_commit.message, 'TAG ') 20 | ) 21 | runs-on: ubuntu-latest 22 | steps: 23 | - uses: actions/checkout@v2 24 | with: 25 | fetch-depth: 0 26 | - uses: cogsmith/devking-release@main 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 💾 DCLONE: Terminal Menu Guided Disk Imaging 💾 2 | ## Simple frontend for common open-source tools: lsblk dd squashfs kpartx 3 | 4 | --- 5 | 6 | 7 | 8 | #### [GITHUB REPO] 9 | 10 | #### 🧾 [VIEW APP SOURCE CODE] 11 | 12 | #### 📅 [PROJECT TRACKER BOARD] 13 | 14 | --- 15 | 16 | [![](https://shields.io/github/package-json/v/cogsmith/dclone?label=codebase)](http://github.com/cogsmith/dclone) 17 | [![](https://shields.io/github/last-commit/cogsmith/dclone)](https://github.com/cogsmith/dclone/commits/main) 18 | [![](https://github.com/cogsmith/dclone/actions/workflows/DEVKING_CHECK.yml/badge.svg)](https://github.com/cogsmith/dclone/actions/workflows/DEVKING_CHECK.yml) 19 | 20 | [![](https://shields.io/github/v/release/cogsmith/dclone?label=latest+release)](https://github.com/cogsmith/dclone/releases) 21 | [![](https://shields.io/github/release-date/cogsmith/dclone?color=blue)](https://github.com/cogsmith/dclone/releases) 22 | [![](https://shields.io/github/commits-since/cogsmith/dclone/latest)](https://github.com/cogsmith/dclone/commits/main) 23 | 24 | 25 | [![](https://shields.io/github/license/cogsmith/dclone?color=lightgray)](https://github.com/cogsmith/dclone/blob/main/LICENSE) 26 | [![](https://shields.io/github/languages/code-size/cogsmith/dclone)](http://github.com/cogsmith/dclone) 27 | [![](https://shields.io/github/repo-size/cogsmith/dclone)](http://github.com/cogsmith/dclone) 28 | [![](https://shields.io/github/issues-raw/cogsmith/dclone)](https://github.com/cogsmith/dclone/issues) 29 | 30 | --- 31 | 32 | * lsblk 33 | * dd 34 | * squashfs 35 | * kpartx 36 | 37 | --- 38 | 39 | Single step streaming technique originally sourced from this StackOverflow post: 40 | https://unix.stackexchange.com/a/75590/23232 41 | 42 | --- 43 | 44 | ![SCREENSHOT](SCREENCAP.GIF) 45 | 46 | --- 47 | 48 |

Disk cloning app that uses open-source tools like dd mksquashfs and kpartx to backup and restore images easily.

49 |

It gives a guided menu interface to picking out a disk and entering a filename, then lets you observe the streaming output from spawned tasks in an embedded tty buffer.

50 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | // npm install blessed blessed-contrib blessed-xterm execa ansi-term @cogsmith/xt 2 | 3 | const nodeos = require('os'); 4 | 5 | const JSONFANCY = function (x) { return require('util').inspect(x, { colors: true, depth: null, breakLength: 99 }); }; 6 | 7 | AppExit = function (exit) { 8 | try { screen.destroy(); } catch (ex) { } 9 | console.log({ EXIT: exit }); 10 | process.exit(1); 11 | } 12 | 13 | process.on('unhandledRejection', (reason, p) => { AppExit({ Msg: 'ERROR_UNEX_PromiseRejection' }); }); 14 | process.on('uncaughtException', (err) => { AppExit({ Msg: 'ERROR_UNEX_ThrowNoCatch', Err: err }); }); 15 | process.on('SIGINT', () => { AppExit({ Msg: 'EXIT_SIGINT' }); }); 16 | //process.on('exit', () => { AppExit({ Msg: 'EXIT_EXIT' }); }); 17 | 18 | const BXTERM = require("blessed-xterm"); 19 | 20 | const execa = require('execa'); 21 | const spawn = require('child_process').spawn; 22 | 23 | //const stripAnsi = require('strip-ansi'); 24 | const stripAnsi = function (string) { return string.replace(ansiRegex(), ''); } 25 | const ansiRegex = function ({ onlyFirst = false } = {}) { 26 | const pattern = ['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'].join('|'); 27 | return new RegExp(pattern, onlyFirst ? undefined : 'g'); 28 | } 29 | 30 | 31 | const blessed = require('blessed'); 32 | const blessedc = require('blessed-contrib'); 33 | const Canvas = blessedc.canvas; 34 | const Node = blessed.Node; 35 | const Box = blessed.Box; 36 | 37 | const XT = require('@cogsmith/xt').Init(); 38 | const App = XT.App; const LOG = XT.LOG; 39 | 40 | // 41 | 42 | bp = false; 43 | screen = false; 44 | App.TUI = {}; 45 | App.TUI.FX = {}; 46 | App.TUI.Node = {}; 47 | 48 | // 49 | 50 | let MyGauge = function (options) { 51 | if (!(this instanceof Node)) { return new MyGauge(options); } 52 | 53 | var self = this; 54 | options = options || {}; 55 | options.left = options.left || 2; 56 | 57 | self.options = options; 58 | self.options.stroke = options.stroke || 'magenta'; 59 | self.options.fill = 'white'; 60 | self.options.data = options.data || []; 61 | self.options.showLabel = options.showLabel !== false; 62 | 63 | Canvas.call(this, options, require('ansi-term')); 64 | 65 | this.on('attach', function () { 66 | if (self.options.stack) { 67 | var stack = this.stack = self.options.stack; 68 | this.setStack(stack); 69 | } 70 | else { 71 | var percent = this.percent = self.options.percent || 0; 72 | this.setData(percent); 73 | } 74 | }); 75 | } 76 | 77 | MyGauge.prototype = Object.create(Canvas.prototype); 78 | MyGauge.prototype.getOptionsPrototype = function () { return { percent: 10 }; }; 79 | MyGauge.prototype.type = 'gauge'; 80 | 81 | MyGauge.prototype.calcSize = function () { 82 | this.width = this.width - 2; 83 | this.canvasSize = { width: this.width + 0, height: this.height }; 84 | }; 85 | 86 | MyGauge.prototype.setData = function (data) { 87 | if (typeof (data) == typeof ([]) && data.length > 0) { this.setStack(data); } 88 | else if (typeof (data) == typeof (1)) { this.setPercent(data); } 89 | }; 90 | 91 | MyGauge.prototype.setPercent = function (percent) { 92 | if (!this.ctx) { throw 'error: canvas context does not exist. setData() for gauges must be called after the gauge has been added to the screen via screen.append()'; } 93 | 94 | var c = this.ctx; 95 | c.strokeStyle = this.options.stroke;//'magenta' 96 | c.fillStyle = this.options.fill;//'white' 97 | 98 | c.clearRect(0, 0, this.canvasSize.width, this.canvasSize.height); 99 | if (percent < 1.001) { percent = percent * 100; } 100 | var width = percent / 100 * (this.canvasSize.width - 2); 101 | c.fillRect(1, 2, width, this.height); 102 | 103 | var textX = 7; 104 | if (width < textX) { c.strokeStyle = 'normal'; } 105 | 106 | // if (this.options.showLabel) c.fillText(Math.round(percent) + '%', textX, 3); 107 | if (this.options.showLabel) { c.fillText(currentStack.label || percent + '%', textX, this.height / 2); } 108 | }; 109 | 110 | MyGauge.prototype.setStack = function (stack) { 111 | var colors = ['green', 'magenta', 'cyan', 'red', 'blue']; 112 | if (!this.ctx) { throw 'error: canvas context does not exist. setData() for gauges must be called after the gauge has been added to the screen via screen.append()'; } 113 | 114 | var c = this.ctx; 115 | var leftStart = 0; 116 | var textLeft = 5; 117 | c.clearRect(0, 0, this.canvasSize.width, this.canvasSize.height); 118 | 119 | for (var i = 0; i < stack.length; i++) { 120 | var currentStack = stack[i]; 121 | 122 | let percent; 123 | if (typeof (currentStack) == typeof ({})) { percent = currentStack.percent; } else { percent = currentStack; } 124 | 125 | c.strokeStyle = currentStack.stroke || colors[(i % colors.length)]; // use specified or choose from the array of colors 126 | c.fillStyle = this.options.fill;//'white' 127 | 128 | textLeft = 5; 129 | if (percent < 1.001) { percent = percent * 100; } 130 | var width = percent / 100 * (this.canvasSize.width - 2); 131 | 132 | if (currentStack.stroke != 'black') { c.fillRect(leftStart, 0, width, this.height); } 133 | 134 | textLeft = (width / 2) - ((currentStack.label ? currentStack.label.length : 0) / 2) + 2; 135 | var textX = leftStart + textLeft; 136 | 137 | if ((leftStart + width) < textX) { c.strokeStyle = 'normal'; } 138 | 139 | // if (this.options.showLabel) c.fillText(percent + '%', textX, 3); 140 | if (this.options.showLabel) { c.fillText(currentStack.label || percent + '%', textX, this.height / 2); } 141 | 142 | leftStart += width; 143 | } 144 | }; 145 | 146 | App.TUI.Node.Gauge = MyGauge; 147 | 148 | // 149 | 150 | function MyTable(options) { 151 | var self = this; 152 | if (!(this instanceof Node)) { return new MyTable(options); } 153 | 154 | if (Array.isArray(options.columnSpacing)) { throw 'Error: columnSpacing cannot be an array.\r\n' + 'Note: From release 2.0.0 use property columnWidth instead of columnSpacing.\r\n' + 'Please refere to the README or to https://github.com/yaronn/blessed-contrib/issues/39'; } 155 | if (!options.columnWidth) { throw 'Error: A table must get columnWidth as a property. Please refer to the README.'; } 156 | 157 | options = options || {}; 158 | options.columnSpacing = options.columnSpacing == null ? 10 : options.columnSpacing; 159 | options.bold = true; 160 | options.selectedFg = options.selectedFg || 'white'; 161 | options.selectedBg = options.selectedBg || 'blue'; 162 | options.fg = options.fg || 'green'; 163 | options.bg = options.bg || ''; 164 | options.interactive = (typeof options.interactive === 'undefined') ? true : options.interactive; 165 | 166 | //options.left = options.left || 1; 167 | //options.right = options.right || 1; 168 | 169 | this.options = options; 170 | Box.call(this, options); 171 | 172 | this.rows = blessed.list({ 173 | //height: 0, 174 | top: 2, 175 | width: 0, 176 | left: 1, 177 | style: { 178 | selected: { fg: options.selectedFg, bg: options.selectedBg }, 179 | item: { fg: options.fg, bg: options.bg } 180 | }, 181 | keys: options.keys, 182 | vi: options.vi, 183 | mouse: options.mouse, 184 | tags: true, 185 | interactive: options.interactive, 186 | screen: this.screen 187 | }); 188 | 189 | this.append(this.rows); 190 | 191 | this.on('attach', function () { if (self.options.data) { self.setData(self.options.data); } }); 192 | } 193 | 194 | MyTable.prototype = Object.create(Box.prototype); 195 | MyTable.prototype.type = 'table'; 196 | MyTable.prototype.focus = function () { this.rows.focus(); }; 197 | 198 | MyTable.prototype.render = function () { 199 | if (this.screen.focused == this.rows) { this.rows.focus(); } 200 | 201 | this.rows.width = this.width - 3; 202 | this.rows.height = this.height - 3; 203 | Box.prototype.render.call(this); 204 | }; 205 | 206 | MyTable.prototype.setData = function (table) { 207 | var self = this; 208 | 209 | var dataToString = function (d) { 210 | var str = ''; 211 | d.forEach(function (r, i) { 212 | var colsize = self.options.columnWidth[i]; 213 | var strip = stripAnsi(r.toString()); 214 | var ansiLen = r.toString().length - strip.length; 215 | var spaceLength = colsize - strip.length + self.options.columnSpacing; 216 | r = r.toString().substring(0, colsize + ansiLen); //compensate for ansi len 217 | if (spaceLength < 0) { spaceLength = 0; } 218 | var spaces = new Array(spaceLength).join(' '); 219 | str += r + spaces; 220 | }); 221 | return str; 222 | }; 223 | 224 | var formatted = []; 225 | 226 | table.data.forEach(function (d) { var str = dataToString(d); formatted.push(str); }); 227 | this.setContent(dataToString(table.headers)); 228 | this.rows.setItems(formatted); 229 | }; 230 | 231 | MyTable.prototype.getOptionsPrototype = function () { 232 | return { 233 | keys: true, 234 | fg: 'white', 235 | interactive: false, 236 | label: 'Active Processes', 237 | width: '30%', 238 | height: '30%', 239 | border: { type: 'line', fg: 'blue' }, 240 | columnSpacing: 10, 241 | columnWidth: [16, 12], 242 | data: { 243 | headers: ['col1', 'col2'], 244 | data: [ 245 | ['a', 'b'], 246 | ['5', 'u'], 247 | ['x', '16.1'] 248 | ] 249 | } 250 | }; 251 | }; 252 | 253 | App.TUI.Node.Table = MyTable; 254 | 255 | // 256 | 257 | App.Disks = {}; 258 | 259 | App.Disks.BackupPath = '/backup'; 260 | 261 | App.Disks.GetInfo = function () { 262 | let exec = execa.commandSync('lsblk -pJ --output-all', { shell: true }); 263 | let info = JSON.parse(exec.stdout); 264 | return info; 265 | } 266 | 267 | App.Disks.GetTableData = function () { 268 | let info = App.Disks.GetInfo(); 269 | 270 | let disks = {}; 271 | let parts = {}; 272 | 273 | for (let dev of info.blockdevices) { 274 | if (dev.type == 'disk') { disks[dev.name] = dev; } 275 | if (dev.children) { 276 | for (let child of dev.children) { if (!parts[dev.name]) { parts[dev.name] = []; } parts[dev.name].push(child); } 277 | } 278 | } 279 | 280 | let sizetotal = 0; 281 | 282 | App.Disks.DiskDB = {}; 283 | App.Disks.Usages = {}; 284 | let rows = []; 285 | for (let diskid in disks) { 286 | let disk = disks[diskid]; 287 | App.Disks.DiskDB[diskid] = disk; 288 | //let row = [disk.name, disk.vendor, disk.model, disk.fstype, disk.label, disk.size, disk.fsused, disk.fsavail, disk.mountpoint]; 289 | let row = [disk.name, disk.vendor, disk.model, disk.size]; 290 | rows.push(row); 291 | 292 | disk.size = disk.size.toString() || ''; 293 | let sizeint = 0; let sizenum = disk.size.replace('M', '').replace('G', '').replace('T', ''); 294 | if (false) { } 295 | else if (disk.size.includes('M')) { sizeint = sizenum / 1024; } 296 | else if (disk.size.includes('G')) { sizeint = sizenum * 1; } 297 | else if (disk.size.includes('T')) { sizeint = sizenum * 1024; } 298 | sizetotal += sizeint; 299 | 300 | for (let part of disk.children) { 301 | partsizetext = part.size; 302 | part.size = part.size.toString() || ''; 303 | let partsizeint = 0; let partsizenum = part.size.replace('M', '').replace('G', '').replace('T', ''); 304 | if (false) { } 305 | else if (part.size.includes('M')) { partsizeint = partsizenum / 1024; } 306 | else if (part.size.includes('G')) { partsizeint = partsizenum * 1; } 307 | else if (part.size.includes('T')) { partsizeint = partsizenum * 1024; } 308 | 309 | console.log(part.name + ' = ' + part['fsuse%']); 310 | let partused = 0; try { partused = part['fsuse%'].replace('%', ''); } catch (ex) { } 311 | let usage = { ID: part.name, Label: part.label, Size: partsizeint, DiskSize: sizeint, SizeText: part.size, Used: partused * 1 }; 312 | //if (!App.Disks.Usages[diskid]) { App.Disks.Usages[diskid] = {}; } App.Disks.Usages[diskid][part.name] = usage; 313 | if (!App.Disks.Usages[diskid]) { App.Disks.Usages[diskid] = []; } App.Disks.Usages[diskid].push(usage); 314 | //console.log(disk); 315 | } 316 | 317 | } 318 | App.Disks.SizeTotal = sizetotal; 319 | 320 | for (let rowi = 0; rowi < rows.length; rowi++) { 321 | let r = rows[rowi]; 322 | for (let i = 0; i < r.length; i++) { if (!r[i]) { rows[rowi][i] = ''; } } 323 | } 324 | 325 | return rows; 326 | } 327 | 328 | App.Disks.DB = { Rows: App.Disks.GetTableData(), Info: App.Disks.GetInfo(), DiskDB: App.Disks.DiskDB, Usages: App.Disks.Usages }; 329 | 330 | // 331 | 332 | App.TUI.Append = function (el, to) { 333 | if (typeof (el) == 'object') { 334 | if (to.ViewHeight == undefined) { to.ViewHeight = 0; } 335 | if (to.ViewHeightFixed == undefined) { to.ViewHeightFixed = 0; } 336 | 337 | el.top = to.ViewHeight; 338 | if (el.position.bottom >= 0) { delete el.position.top; } 339 | 340 | to.ViewHeight = to.ViewHeight + el.height; 341 | if (el.flex) { el.height = to.ViewHeight - to.ViewHeightFixed; } else { to.ViewHeightFixed += el.height; } 342 | //if (el.flex) { } else { to.ViewHeightFixed += el.height; } 343 | 344 | if (!to.ViewHeights) { to.ViewHeights = []; } 345 | to.ViewHeights.push(el.height); 346 | 347 | to.append(el); 348 | 349 | screen.render(); 350 | } 351 | else { LOG.WARN('TUI.Append: !EL'); } 352 | } 353 | 354 | App.TUI.Init = function () { 355 | let bp = blessed.program(); 356 | //bp.cols = 144; bp.rows = 36; 357 | //bp.cols = 99; bp.rows = 24; 358 | //bp.cols = 80; bp.rows = 20; 359 | 360 | screen = blessed.screen({ debug: true, autoPadding: false, dockBorders: true, program: bp, cursor: { blink: true, color: 'red' } }); 361 | App.TUI.BP = bp; App.TUI.Screen = screen; 362 | 363 | screen.key(['q', 'C-c'], function (ch, key) { AppExit(); }); 364 | //screen.key(['escape'], function (ch, key) { AppExit(); }); 365 | 366 | App.TUI.NullBox = blessed.box({ height: 0, width: 0, hidden: false, style: { fg: 'white', bg: 'red' } }); 367 | 368 | for (let k in App.TUI.FX) { 369 | //LOG.TRACE('TUI.FX: ' + k); 370 | let el = App.TUI.FX[k].apply(null, []); 371 | if (!el) { el = App.TUI.NullBox; LOG.WARN('TUI.FX: ' + k + ' = NULLBOX'); } 372 | App.TUI[k] = el; 373 | } 374 | 375 | App.TUI.DiskView.append(App.TUI.ListBox); 376 | App.TUI.DiskView.append(App.TUI.UsageBox); 377 | 378 | App.TUI.Append(App.TUI.DiskView, App.TUI.ViewsBox); 379 | //App.TUI.Append(App.TUI.FilesystemView, App.TUI.ViewsBox); 380 | App.TUI.Append(App.TUI.OutputView, App.TUI.ViewsBox); 381 | //App.TUI.Append(App.TUI.AppView, App.TUI.ViewsBox); 382 | 383 | //App.TUI.AppView.append(App.TUI.NodeStatsBox); 384 | //App.TUI.AppView.append(App.TUI.AppInfoBox); 385 | 386 | for (let z of App.TUI.ViewsBox.children) { 387 | if (z.flex) { 388 | z.height = App.TUI.ViewsBox.height - App.TUI.ViewsBox.ViewHeightFixed; 389 | //z.height = screen.height - 2 - App.TUI.ViewsBox.ViewHeightFixed; 390 | for (let zz of z.children) { 391 | if (zz.flex) { zz.height = App.TUI.ViewsBox.height - App.TUI.ViewsBox.ViewHeightFixed; } 392 | //if (zz.flex) { zz.height = screen.height - 2 - App.TUI.ViewsBox.ViewHeightFixed; } 393 | } 394 | } 395 | } 396 | 397 | for (let i = 1; i < App.TUI.ViewsBox.children.length; i++) { 398 | let zlast = App.TUI.ViewsBox.children[i - 1]; 399 | let znow = App.TUI.ViewsBox.children[i]; 400 | if (zlast.flex) { znow.top = 10 + App.TUI.ViewsBox.height - App.TUI.ViewsBox.ViewHeightFixed; screen.render(); } 401 | } 402 | 403 | App.TUI.Screen.append(App.TUI.Header); 404 | App.TUI.Screen.append(App.TUI.Footer); 405 | App.TUI.Screen.append(App.TUI.ViewsBox); 406 | 407 | App.TUI.Screen.render(); 408 | } 409 | 410 | // 411 | 412 | App.TUI.FX.NodeStatsBox = function () { 413 | let box = blessed.box({ 414 | top: 0, height: 8, width: '20%', right: 0, 415 | style: { fg: 'white', bg: 'black' }, 416 | content: 'NODESTATBOX' 417 | }); 418 | 419 | return box; 420 | } 421 | 422 | App.TUI.FX.AppInfoBox = function () { 423 | let box = blessed.box({ 424 | top: 0, height: 8, width: '80%', 425 | style: { fg: 'white', bg: 'black' }, 426 | content: 'APPINFOBOX' 427 | }); 428 | 429 | return box; 430 | } 431 | 432 | App.TUI.FX.InputZone = function () { 433 | let box = blessed.box({ height: 1, width: '75%', top: 0, left: 0 }); 434 | return box; 435 | } 436 | 437 | App.TUI.FX.InputBox = function () { 438 | let box = blessed.textbox({ 439 | //top: 0, left: 0, height: 1, width: '50%', 440 | style: { fg: 'white', bg: 'blue', focus: { fg: 'black', bg: 'white' } }, 441 | tags: true, 442 | //content: '{green-fg}✔️ ▶ ✅ {/green-fg} ▶ ⭐ ⛔ ✅ HEADER_LEFT ⏸️ ⚡' 443 | // content: '▶ DCLONE ◀' 444 | //content: '▶ DCLONE: Disk Cloner [0.0.1-dev]' 445 | content: ' ▶ ' + App.Meta.Full + '' 446 | }); 447 | 448 | box.on('mouseout', () => { box.setContent(' ▶ ' + App.Meta.Full + ''); screen.render(); }); 449 | box.on('mouseover', () => { box.setContent(' ▶ COGSMITH IT Solutions Provider'); screen.render(); }); 450 | 451 | return box; 452 | } 453 | 454 | App.TUI.FX.InfoBox = function () { 455 | let box = blessed.box({ 456 | top: 0, right: 1, height: 1, width: '25%', align: 'right', 457 | style: { fg: 'white', bg: 'blue' }, 458 | content: nodeos.userInfo().username + ' @ ' + nodeos.hostname() + ' ' + App.Disks.BackupPath + ' ◀' 459 | }); 460 | 461 | return box; 462 | } 463 | 464 | App.TUI.FX.StatusBox = function () { 465 | let box = blessed.textbox({ 466 | bottom: 0, left: 0, height: 1, width: '50%', 467 | style: { fg: 'white', bg: 'blue', focus: { bg: 'red' }, hover: { bg: 'green' } }, 468 | content: '▶ FOOTER_LEFT', 469 | mouse: true, 470 | inputOnFocus: true, focus: { bg: 'red' }, 471 | tags: true 472 | }); 473 | 474 | //box.setContent(' ┋ ▾ ◂ ◆ ▸ ◀ ▲ ❯ ☒ > ▼ ◄ ⚠ ‼ ℹ i ✔ √ █ ■ ◉ ◉ ♦ ━ ◇ ▶ ✖ × ► ◊ ☰ ≡ ▶ ► ≡ ◆ ★ ♥ ✶ ★ ⬢ ⏏ ♦ ⏸ ⏺ ⏭ ▙ ▣ ■ ◼ ◉ STATUS') 475 | //box.setContent(' • ◆ ■ ◀ █ ▶ ▲ ▼ ♥ ≡ = - STATUS') 476 | box.setContent(' {bold}{#777-fg}◆{/#777-fg}{/bold} {bold}App.Init:{/bold} DCLONE'); screen.render(); 477 | 478 | loopfx = function () { 479 | box.setContent(' {bold}{yellow-fg}◆{/yellow-fg}{/bold} {bold}App.Init:{/bold} Loading...'); screen.render(); 480 | setTimeout(function () { box.setContent(' {bold}{#777-fg}◆{/#777-fg}{/bold} {bold}App.Init:{/bold} Loading...'); screen.render(); }, 500 + 250); 481 | setTimeout(function () { box.setContent(' {bold}{#777-fg} {/#777-fg}{/bold} {bold}App.Init:{/bold} Loading...'); screen.render(); }, 500 + 500); 482 | setTimeout(function () { box.setContent(' {bold}{#777-fg}◆{/#777-fg}{/bold} {bold}App.Init:{/bold} Loading...'); screen.render(); }, 500 + 750); 483 | }; setInterval(loopfx, 500 + 1000); 484 | 485 | return box; 486 | } 487 | 488 | App.TUI.FX.ClockBox = function () { 489 | let box = blessed.textbox({ 490 | bottom: 0, right: 0, height: 1, width: '50%', align: 'right', 491 | style: { fg: 'white', bg: 'blue', }, 492 | content: 'FOOTER_RIGHT ◀', 493 | mouse: true, 494 | inputOnFocus: false, 495 | }); 496 | 497 | setInterval(function () { box.setContent(new Date().toLocaleTimeString() + ' '); screen.render(); }, 500); 498 | 499 | return box; 500 | } 501 | 502 | // 503 | 504 | App.TUI.FX.ListBox = function () { 505 | var box = blessed.box({ height: 7, padding: { top: 0, left: 1, right: 1, bottom: 0 } }); 506 | 507 | var label = '[ ' + App.Disks.DB.Rows.length + ' disks = ' + Math.floor(App.Disks.SizeTotal / 10) + ' GB' + ' ]'; 508 | 509 | //App.TUI.LogAndExit(JSON.stringify(App.Disks.DB)); 510 | 511 | var boxlist = MyTable({ 512 | top: 0, 513 | keys: true, 514 | vi: true, 515 | interactive: true, 516 | fg: 'white', 517 | selectedFg: 'white', selectedBg: 'blue', 518 | label: label, 519 | width: 55, border: { type: "line", fg: "blue" }, columnSpacing: 3, columnWidth: [12, 12, 16, 8] 520 | }); 521 | 522 | boxlist.focus() 523 | 524 | box.append(boxlist); 525 | 526 | let rows = App.Disks.GetTableData(); 527 | boxlist.setData({ 528 | // headers: [('ID FS LABEL SIZE USED USED FREE FREE MOUNT'.split(' '))], 529 | headers: ['ID', 'VENDOR', 'MODEL', 'SIZE'], 530 | data: rows 531 | }) 532 | //App.Disks.DB.Rows = rows; 533 | 534 | screen.on('keypress', function (key, code) { 535 | if (code.name == 'up' || code.name == 'down') { 536 | setTimeout(() => { 537 | App.TUI.UsageBox.destroy(); 538 | App.TUI.UsageBox = App.TUI.FX.UsageBox(); 539 | App.TUI.DiskView.append(App.TUI.UsageBox); 540 | screen.render(); 541 | let rowdata = false; try { rowdata = App.Disks.DB.Rows[App.TUI.ListBox.children[0].rows.selected]; } catch (ex) { }; 542 | //App.TUI.UsageBox.setLabel('[ ' + rowdata[0] + ' = ' + rowdata[3] + ' ]'); 543 | screen.render(); 544 | }, 10); 545 | //console.log(rowdata); 546 | } 547 | }); 548 | 549 | boxlist.rows.on('select', (el, index) => { 550 | let inputpromptmsg = ' ▶ Enter Backup Filename: ' + App.Disks.BackupPath + '/'; 551 | let inputprompt = new blessed.box({ width: inputpromptmsg.length + 1, style: { bg: 'white', fg: 'black' }, content: inputpromptmsg }); 552 | App.TUI.InputBox.left = inputpromptmsg.length + 0; 553 | 554 | if (0) { 555 | const JSONFANCY = function (x) { return require('util').inspect(x, { colors: true, depth: null, breakLength: 99 }); }; 556 | screen.destroy(); 557 | console.log("\n\n\n\n========\n\n\n\n"); 558 | console.log(JSONFANCY(App.Disks.DB)); 559 | //LOG.WARN('Disks.DB', App.Disks.DB); 560 | process.exit(1); 561 | } 562 | 563 | let diskid = App.Disks.DB.Rows[index][0]; 564 | let partlabels = []; for (let zp of App.Disks.DB.Usages[diskid]) { partlabels.push(zp.Label); } 565 | 566 | //let backuplabel = rows[index][0]; 567 | let dnow = new Date().toISOString().replace(/(T|-|:|\.)/g, '').substring(0, 12); 568 | let disksizetext = Math.ceil(App.Disks.DB.Usages[diskid][0].DiskSize) + 'GB'; 569 | let backuplabel = 'DISK' + '_' + partlabels.join('+') + '_' + disksizetext + '.' + dnow; 570 | App.TUI.InputBox.setContent(backuplabel); screen.render(); 571 | App.TUI.InputBox.setValue(backuplabel); screen.render(); 572 | 573 | App.TUI.Header.remove(App.TUI.InputZone); 574 | App.TUI.InputZone.destroy(); 575 | App.TUI.InputZone = App.TUI.FX.InputZone(); 576 | App.TUI.InputZone.append(inputprompt); 577 | App.TUI.InputZone.append(App.TUI.InputBox); 578 | App.TUI.Header.append(App.TUI.InputZone); 579 | 580 | screen.render(); 581 | 582 | App.TUI.InputBox.readInput(function (z) { 583 | App.DoBackup(diskid, App.Disks.BackupPath, App.TUI.InputBox.value); 584 | 585 | App.TUI.Header.remove(App.TUI.InputZone); 586 | App.TUI.InputZone.destroy(); 587 | App.TUI.InputBox.left = 0; 588 | App.TUI.InputZone = App.TUI.FX.InputZone(); 589 | App.TUI.InputZone.append(App.TUI.InputBox); 590 | App.TUI.Header.append(App.TUI.InputZone); 591 | App.TUI.InputBox.setContent(' ▶ ' + App.Meta.Full + ''); screen.render(); 592 | }); 593 | }); 594 | 595 | App.TUI.BoxList = boxlist; 596 | 597 | return box; 598 | } 599 | 600 | App.DoBackup = function (diskid, outdir, backupfile) { 601 | App.BXTERM.write("\n\r\n"); 602 | App.BXTERM.write('▶ DCLONE Backup: ' + diskid + ' => ' + outdir + '/' + backupfile); 603 | App.BXTERM.write("\n\r\n"); 604 | //App.BXTERM.spawn('/bin/sh', ['-c', '/usr/bin/curl -o /dev/null https://speed.hetzner.de/100MB.bin']); 605 | App.BXTERM.spawn('/bin/bash', ['-c', 'echo 123 ; echo 999']); 606 | 607 | let sqfsdir = outdir + ''; 608 | let cmds = []; 609 | cmds.push('mkdir -p ' + sqfsdir); 610 | cmds.push('cd ' + sqfsdir); 611 | cmds.push('time mksquashfs /dev/null ./' + backupfile + '.sqfs -p "' + backupfile + '.img f 444 root root dd if=' + diskid + ' bs=8M"'); 612 | let cmd = '(' + cmds.join(' ; ') + ')'; 613 | App.BXTERM.write(cmd); 614 | App.BXTERM.write("\n\r\n"); 615 | App.BXTERM.spawn('/bin/bash', ['-c', cmd]); 616 | } 617 | 618 | App.TUI.LogAndExit = function (msg) { 619 | screen.destroy(); 620 | msg = JSONFANCY(msg); 621 | console.log(msg); 622 | process.exit(1); 623 | } 624 | 625 | App.TUI.FX.UsageBox = function () { 626 | let rowdata = false; try { rowdata = App.Disks.DB.Rows[App.TUI.ListBox.children[0].rows.selected]; } catch (ex) { }; 627 | let diskid = rowdata[0]; 628 | let disksize = rowdata[3]; 629 | 630 | //App.TUI.LogAndExit(App.Disks.DB.Usages); 631 | //App.TUI.LogAndExit(App.Disks.DB.Usages[diskid]); 632 | 633 | let g0stack = []; 634 | let g1stack = []; 635 | let g2stack = []; 636 | 637 | let sizes = []; 638 | let usedtotal = 0; 639 | let zi = 0; 640 | let gstrokes = ['cyan', 'blue', 'cyan', 'blue', 'cyan', 'blue', 'cyan', 'blue', 'cyan', 'blue']; 641 | let vpz = 100; 642 | for (let z of App.Disks.DB.Usages[diskid]) { 643 | let p = z.Size / z.DiskSize * 100; 644 | if (p < 10) { vpz = vpz - 10; } // else { vpz = vpz - p; } 645 | } 646 | for (let z of App.Disks.DB.Usages[diskid]) { 647 | sizes.push(z.Size); 648 | usedtotal += Math.floor((z.Used / 100) * (z.Size / z.DiskSize) * 100); 649 | let p = (z.Size / z.DiskSize) * 100; 650 | let vp = p; if (p > vpz) { vp = vpz; vpz = vpz - vp; } if (p < 10) { vp = 10; } 651 | let g1p1 = (z.Used / 100) * vp; 652 | let g1p2 = ((100 - z.Used) / 100) * vp; 653 | if (g1p1 == 1) { g1p1 = 1.01; } 654 | if (g1p2 == 1) { g1p2 = 1.01; } 655 | if (g1p1 < 0.01) { g1p1 = 0.01; } 656 | if ((g1p1 + g1p2) > vp) { g1p2 = (vp - g1p1) * 1; } 657 | //g1p2 = p - g1p1 - 0.5; 658 | g0stack.push({ label: Math.floor(p) + '%', percent: vp, stroke: gstrokes[zi] }); 659 | g2stack.push({ label: z.Label, percent: vp, stroke: 'black' }); 660 | g1stack.push({ u: z.Used, p: p, vp: vp, percent: g1p1, stroke: 'yellow' }); 661 | g1stack.push({ u: z.Used, p: p, vp: vp, percent: g1p2, stroke: 'green' }); 662 | zi++; 663 | } 664 | 665 | if (diskid == '0/dev/mmcblk0') { 666 | //console.log(g0stack); 667 | console.log(g1stack); 668 | //console.log(g2stack); 669 | } 670 | 671 | //App.TUI.LogAndExit({ G0: g0stack, G2: g2stack, G1: g1stack }); 672 | 673 | //console.log(usedtotal); 674 | 675 | let boxlabel = '[ ' + diskid + ' = ' + disksize + ' GB'; if (usedtotal > 0) { boxlabel += ' = ' + usedtotal + '% Used'; } else { boxlabel += ' = Not Mounted'; } boxlabel += ' ]'; 676 | var box = blessed.box({ 677 | interactive: true, 678 | right: 0, top: 0, 679 | //keys: true 680 | //, vi: true 681 | fg: 'white', 682 | //bg: '#ff0000', 683 | selectedFg: 'white', selectedBg: 'blue', 684 | label: boxlabel, 685 | width: screen.width - 55 + 1, 686 | height: 7, 687 | padding: 0, 688 | border: { type: "line", fg: "blue" } 689 | }) 690 | 691 | let gauge = MyGauge({ 692 | height: 3, top: 2, width: box.width - 1, zalign: 'right', zpadding: 0, 693 | style: { fg: 'white' }, //border: { type: "line", fg: "cyan" }, 694 | //label: '[ Partitions ]', 695 | showLabel: true, 696 | stack: g0stack 697 | }); 698 | box.append(gauge); 699 | 700 | 701 | let g1 = MyGauge({ 702 | height: 1, top: 5, width: box.width - 1, padding: 0, 703 | style: { fg: 'white' }, //border: { type: "line", fg: "cyan" }, 704 | showLabel: false, 705 | /* 706 | stack: [ 707 | { percent: 3, stroke: 'yellow' }, { percent: 2, stroke: 'green' }, 708 | { percent: 20, stroke: 'yellow' }, { percent: 10, stroke: 'green' }, 709 | { percent: 5, stroke: 'yellow' }, { percent: 60, stroke: 'green' } 710 | ], 711 | */ 712 | stack: g1stack 713 | }); 714 | box.append(g1); 715 | 716 | let g2 = MyGauge({ 717 | height: 1, top: 1, width: box.width - 1, padding: 0, 718 | style: { fg: 'white' }, //border: { type: "line", fg: "cyan" }, 719 | showLabel: true, 720 | stack: g2stack 721 | }); 722 | box.append(g2); 723 | 724 | setTimeout(() => { 725 | screen.append(blessed.box({ height: 1, top: 6, right: 1, width: 1, style: { fg: 'white', bg: 'black' } })); 726 | screen.render(); 727 | }, 10); 728 | 729 | return box; 730 | } 731 | 732 | //App.TUI.FX.FilesystemBox = function () {} 733 | 734 | //App.TUI.FX.OutputBox = function () {} 735 | 736 | //App.TUI.FX.LogBox = function () {} 737 | 738 | //App.TUI.FX.StatBox = function () {} 739 | 740 | // 741 | 742 | App.TUI.FX.Header = function () { 743 | let header = blessed.box({ 744 | top: 0, left: 0, height: 1, width: '100%', 745 | style: { fg: 'white', bg: 'blue' }, 746 | }); 747 | 748 | header.append(App.TUI.InfoBox); 749 | 750 | App.TUI.InputZone.append(App.TUI.InputBox); 751 | header.append(App.TUI.InputZone); 752 | 753 | setTimeout(() => { App.TUI.InputBox.setContent(' ▶ ' + App.Meta.Full + ''); screen.render(); }, 99); 754 | 755 | return header; 756 | } 757 | 758 | App.TUI.FX.Footer = function () { 759 | let footer = blessed.box({ 760 | bottom: 0, left: 0, height: 1, width: '100%', 761 | style: { fg: 'white', bg: 'blue' }, 762 | }); 763 | 764 | footer.append(App.TUI.StatusBox); 765 | footer.append(App.TUI.ClockBox); 766 | 767 | return footer; 768 | } 769 | 770 | App.TUI.FX.ViewsBox = function () { 771 | let box = blessed.box({ 772 | top: 1, left: 0, height: screen.height - 2, width: '100%', 773 | style: { fg: 'white', bg: 'black' }, 774 | }); 775 | return box; 776 | } 777 | 778 | // 779 | 780 | App.TUI.FX.DiskView = function () { 781 | let box = blessed.box({ height: 6 }); 782 | return box; 783 | } 784 | 785 | App.TUI.FX.FilesystemView = function () { 786 | let box = blessed.box({ height: 10, style: { fg: 'white', bg: 'red' } }); 787 | //box.flex = true; 788 | 789 | const opts = { 790 | padding: { top: 0, left: 1, right: 1, bottom: 0 }, 791 | shell: '/bin/sh', 792 | //args: ['-c', '/usr/bin/curl -o /dev/null https://speed.hetzner.de/100MB.bin'], 793 | args: ['-c', '(lspci;echo;lsusb)'], 794 | env: process.env, 795 | cwd: process.cwd(), 796 | cursorType: "block", 797 | border: "line", 798 | scrollback: 1000, 799 | style: { 800 | fg: "default", bg: "default", 801 | border: { type: "line", fg: "blue" }, 802 | focus: { border: { fg: "green" } }, 803 | scrolling: { border: { fg: "red" } } 804 | } 805 | } 806 | 807 | let bxterm = new BXTERM(Object.assign({}, opts, { 808 | //args: ['-c', '(lsblk -Tp --output NAME,MAJ:MIN,UUID,SERIAL,STATE,TRAN,PTTYPE,TYPE,FSTYPE,LABEL,MOUNTPOINT,SIZE,FSUSED,FSUSE%,FSAVAIL,RO,RM,HOTPLUG | cut -c -' + (screen.width - 4) + ')'], 809 | args: ['-c', '(lsblk -Tp --output NAME,MAJ:MIN,STATE,TRAN,PTTYPE,TYPE,FSTYPE,LABEL,MOUNTPOINT,SIZE,FSUSED,FSUSE%,FSAVAIL,RO,RM,HOTPLUG | cut -c -' + (screen.width - 4) + ')'], 810 | width: screen.width, height: box.height, 811 | label: "[ Filesystems ]", 812 | border: { type: "line", fg: "blue" }, 813 | })); 814 | bxterm.flex = true; 815 | 816 | box.append(bxterm); 817 | 818 | return box; 819 | } 820 | 821 | App.TUI.FX.OutputView = function () { 822 | let box = blessed.box({ label: 'Shell Output', height: 10, border: { type: "line", fg: "blue" }, style: { fg: 'white', bg: 'magenta' } }); 823 | box.flex = true; 824 | 825 | let lsblk = 'lsblk -Tp --output NAME,MAJ:MIN,STATE,TRAN,PTTYPE,TYPE,FSTYPE,LABEL,MOUNTPOINT,SIZE,FSUSED,FSUSE%,FSAVAIL,RO,RM,HOTPLUG | cut -c -' + (screen.width - 4) + ''; 826 | const opts = { 827 | padding: { top: 0, left: 1 }, 828 | shell: '/bin/sh', 829 | //args: ['-c', '/usr/bin/curl -o /dev/null https://speed.hetzner.de/100MB.bin'], 830 | //args: ['-c', '(sudo fdisk --list)'], 831 | //args: ['-c', '(uname -a;echo;' + lsblk + ';echo;sudo bash /zx/dclone/test_cmd_backup.sh)'], 832 | args: ['-c', '(uname -a;echo;' + lsblk + ')'], 833 | env: process.env, 834 | cwd: process.cwd(), 835 | cursorType: "block", 836 | border: "line", 837 | scrollback: 1000, 838 | mouse: true, 839 | style: { 840 | fg: "default", bg: "default", 841 | //border: { type: "line", fg: "blue" }, 842 | focus: { border: { fg: "green" } }, 843 | scrolling: { border: { fg: "red" } } 844 | } 845 | } 846 | 847 | let bxterm = new BXTERM(Object.assign({}, opts, { 848 | //args: ['-c', '(lsblk -Tp --output NAME,MAJ:MIN,UUID,SERIAL,STATE,TRAN,PTTYPE,TYPE,FSTYPE,LABEL,MOUNTPOINT,SIZE,FSUSED,FSUSE%,FSAVAIL,RO,RM,HOTPLUG | cut -c -' + (screen.width - 4) + ')'], 849 | //args: ['-c', '(lsblk -Tp --output NAME,MAJ:MIN,STATE,TRAN,PTTYPE,TYPE,FSTYPE,LABEL,MOUNTPOINT,SIZE,FSUSED,FSUSE%,FSAVAIL,RO,RM,HOTPLUG | cut -c -' + (screen.width - 4) + ')'], 850 | width: screen.width, height: 10, 851 | label: "[ Shell Output ]", 852 | border: { type: "line", fg: "blue" }, 853 | controlKey: 'C-w' 854 | })); 855 | bxterm.flex = true; 856 | 857 | box.append(bxterm); 858 | screen.render(); 859 | 860 | console.log(App.Disks.DB.Usages); 861 | 862 | App.BXTERM = bxterm; 863 | 864 | //bxterm.write("\n" + JSONFANCY(App.Disks.DB.Usages) + "\n"); 865 | //bxterm.write(App.Disks.DB.Usages); 866 | //bxterm.write(JSON.stringify(App.Disks.DB.Usages)); 867 | //bxterm.focus(); 868 | 869 | //bxterm.write(JSONFANCY(App.Disks.DB.Usages).replace(/\n/g, "\n\r")); 870 | //bxterm.write("\n\r\n"); 871 | 872 | return box; 873 | } 874 | 875 | App.TUI.FX.AppView = function () { 876 | //let box = blessed.box({ label: 'App Info', height: 8, bottom: 0, left: 0, border: { type: "line", fg: "blue" }, style: { fg: 'white', bg: 'green' } }); 877 | //return box; 878 | let box = blessed.box({ height: 0, bottom: 0, left: 0, style: { fg: 'white', bg: 'red' } }); 879 | return box; 880 | } 881 | 882 | // 883 | 884 | App.InitArgs = function () { 885 | //App.Argy = yargs(process.argv); 886 | } 887 | 888 | App.InitInfo = function () { 889 | //App.SetInfo('App', function () { return 'DCLONE' }); 890 | } 891 | 892 | App.InitData = function () { 893 | } 894 | 895 | App.Init = function () { 896 | } 897 | 898 | App.InitDone = function () { 899 | } 900 | 901 | App.Main = function () { 902 | let rows = App.Disks.GetTableData(); 903 | App.TUI.Init(); 904 | setInterval(() => { }, 100); 905 | } 906 | 907 | App.Run(); 908 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------