diff --git a/README.md b/README.md index 12dd50a..12f7389 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ No images are provided for this, but the process has been written to be a single As root, run the following: ``` -curl https://raw.githubusercontent.com/bitfocus/companion-satellite/main/pi-image/install.sh | sh +curl https://raw.githubusercontent.com/bitfocus/companion-satellite/main/pi-image/install.sh | bash ``` After this, you can use `sudo satellite-update` to change the version it has installed. Note: this is currently not fully implemented. diff --git a/assets/linux/README b/assets/linux/README index ce68e4b..8794ec4 100644 --- a/assets/linux/README +++ b/assets/linux/README @@ -5,7 +5,7 @@ If you want to run satellite on a headless machine, consider using the install script This can be run with: - $ curl https://raw.githubusercontent.com/bitfocus/companion-satellite/main/pi-image/install.sh | sh + $ curl https://raw.githubusercontent.com/bitfocus/companion-satellite/main/pi-image/install.sh | bash The benefit of this approach is that it will setup and manage any required dependencies, udev rules for you, and provide you with an easy script to run to perform an update. diff --git a/pi-image/.gitignore b/pi-image/.gitignore index 307f30e..b41d93a 100644 --- a/pi-image/.gitignore +++ b/pi-image/.gitignore @@ -1 +1,2 @@ -output-* \ No newline at end of file +output-* +*/.yarn/ \ No newline at end of file diff --git a/pi-image/install.sh b/pi-image/install.sh index e96a142..e014194 100644 --- a/pi-image/install.sh +++ b/pi-image/install.sh @@ -1,6 +1,18 @@ #!/usr/bin/env bash set -e +if [ ! "$BASH_VERSION" ] ; then + echo "You must use bash to run this script. If running this script from curl, make sure the final word is 'bash'" 1>&2 + exit 1 +fi + +CURRENT_ARCH=$(dpkg --print-architecture) +if [[ "$CURRENT_ARCH" != "x64" && "$CURRENT_ARCH" != "amd64" && "$CURRENT_ARCH" != "arm64" ]]; then + echo "$CURRENT_ARCH is not a supported cpu architecture for running Companion Satellite." + echo "If you are running on an arm device (such as a Raspberry Pi), make sure to use an arm64 image." + exit 1 +fi + echo "This will attempt to install Companion Satellite as a system service on this device." echo "It is designed to be run on headless servers, but can be used on desktop machines if you are happy to not have the tray icon." echo "A user called 'satellite' will be created to run the service, and various scripts will be installed to manage the service" @@ -10,6 +22,10 @@ if [ $(/usr/bin/id -u) -ne 0 ]; then exit 1 fi +# Install a specific stable build. It is advised to not use this, as attempting to install a build that doesn't +# exist can leave your system in a broken state that needs fixing manually +SATELLITE_BUILD="${SATELLITE_BUILD:-beta}" +# Development only: Allow building using a testing branch of this updater SATELLITE_BRANCH="${SATELLITE_BRANCH:-main}" # add a system user @@ -36,8 +52,17 @@ cd /usr/local/src/companion-satellite # configure git for future updates git config --global pull.rebase false + # run the update script -./pi-image/update.sh $SATELLITE_BRANCH +if [ "$SATELLITE_BUILD" == "beta" ] || [ "$SATELLITE_BUILD" == "experimental" ]; then + ./pi-image/update.sh beta +else + ./pi-image/update.sh stable "$SATELLITE_BUILD" +fi +# ./pi-image/update.sh $SATELLITE_BRANCH + +# install update script dependencies, as they were ignored +yarn --cwd "/usr/local/src/companion-satellite/update-prompt" install # enable start on boot systemctl enable satellite @@ -49,5 +74,12 @@ cp ./pi-image/satellite-config /boot/satellite-config # TODO - verify permissions echo "export PATH=/opt/fnm/aliases/default/bin:\$PATH" >> /home/satellite/.bashrc +# check that a build of satellite was installed +if [ ! -d "/opt/companion-satellite" ] +then + echo "No Companion Satellite build was installed!\nIt should be possible to recover from this with \"sudo satellite-update\"" + exit 9999 # die with error code 9999 +fi + echo "Companion Satellite is installed!" echo "You should edit the configuration file at \"/boot/satellite-config\" then can start it with \"sudo systemctl start satellite\" or \"sudo satellite-update\"" diff --git a/pi-image/update-prompt/.gitignore b/pi-image/update-prompt/.gitignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/pi-image/update-prompt/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/pi-image/update-prompt/main.js b/pi-image/update-prompt/main.js new file mode 100644 index 0000000..e2870ca --- /dev/null +++ b/pi-image/update-prompt/main.js @@ -0,0 +1,176 @@ +// @ts-check +import semver from 'semver' +import inquirer from 'inquirer' +import fs from 'fs' + +const ALLOWED_VERSIONS = '^1.5.0' + +let currentVersion +try { + currentVersion = fs.readFileSync('/opt/companion-satellite/BUILD').toString().trim() +} catch (e) { + // Assume none installed +} + +async function getLatestBuildsForBranch(branch, targetCount) { + targetCount *= 10 // HACK until the api changes + // eslint-disable-next-line no-undef + const data = await fetch( + `https://api.bitfocus.io/v1/product/companion-satellite/packages?branch=${branch}&limit=${targetCount}` + ) + const jsonData = await data.json() + + // TODO - make sure this is durable + let target = `${process.platform}-${process.arch}-tgz` + if (target === 'linux-x64-tgz') target = 'linux-tgz' + + // console.log('searching for', target, 'in', data.data.packages) + + // assume the builds are sorted by date already + const result = [] + for (const pkg of jsonData.packages) { + if (pkg.target === target) { + try { + if (semver.satisfies(pkg.version, ALLOWED_VERSIONS)) { + result.push({ + name: pkg.version, + uri: pkg.uri, + published: new Date(pkg.published), + }) + } + } catch (e) { + // Not a semver tag, so ignore + } + } + } + + return result +} + +async function selectBuildOfType(type, targetBuild) { + const candidates = await getLatestBuildsForBranch(type, 1) + const selectedBuild = targetBuild ? candidates.find((c) => c.name == targetBuild) : candidates[0] + if (selectedBuild) { + if (selectedBuild.name === currentVersion) { + console.log(`The latest build of ${type} (${selectedBuild.name}) is already installed`) + } else { + console.log(`Selected ${type}: ${selectedBuild.name}`) + fs.writeFileSync('/tmp/satellite-version-selection', selectedBuild.uri) + fs.writeFileSync('/tmp/satellite-version-selection-name', selectedBuild.name) + } + } else { + console.error(`No matching ${type} build was found!`) + } +} +async function chooseOfType(type) { + const candidates = await getLatestBuildsForBranch(type, 10) + + if (candidates.length === 0) { + console.error(`No ${type} build was found!`) + } else { + const selectedBuild = await inquirer.prompt([ + { + type: 'list', + name: 'ref', + message: 'Which version do you want? ', + choices: [...candidates.map((c) => c.name), 'cancel'], + }, + ]) + + if (selectedBuild.ref && selectedBuild.ref !== 'cancel') { + if (selectedBuild.ref === currentVersion) { + const confirm = await inquirer.prompt([ + { + type: 'confirm', + name: 'confirm', + message: `Build "${currentVersion}" is already installed. Do you wish to reinstall it?`, + }, + ]) + if (!confirm.confirm) { + return + } + } + + const build = candidates.find((c) => c.name === selectedBuild.ref) + if (build) { + console.log(`Selected ${type}: ${build.name}`) + fs.writeFileSync('/tmp/satellite-version-selection', build.uri) + fs.writeFileSync('/tmp/satellite-version-selection-name', build.name) + } else { + console.error('Invalid selection!') + } + } else { + console.error('No version was selected!') + } + } +} + +async function runPrompt() { + console.log('Warning: Downgrading to an older version can cause issues with the database not being compatible') + + let isOnBeta = true + + console.log(`You are currently on "${currentVersion || 'Unknown'}"`) + + // TODO - restore this + // if (currentBranch) { + // console.log(`You are currently on branch: ${currentBranch}`) + // } else if (currentTag) { + // console.log(`You are currently on release: ${currentTag}`) + // } else { + // console.log('Unable to determine your current version') + // } + + const answer = await inquirer.prompt([ + { + type: 'list', + name: 'ref', + message: 'What version do you want? ', + choices: ['latest stable', 'latest beta', 'specific stable', 'specific beta', 'custom-url', 'cancel'], + default: isOnBeta ? 'latest beta' : 'latest stable', + }, + ]) + + if (answer.ref === 'custom-url') { + console.log( + 'Warning: This must be an linux build of Companion for the correct architecture, or companion will not be able to launch afterwards' + ) + const answer = await inquirer.prompt([ + { + type: 'input', + name: 'url', + message: 'What build url?', + }, + ]) + + const confirm = await inquirer.prompt([ + { + type: 'confirm', + name: 'confirm', + message: `Are you sure you to download the build "${answer.url}"?\nMake sure you trust the source.\nIf you don't know what you are doing you could break your CompanionPi installation`, + }, + ]) + if (!confirm.confirm) { + return runPrompt() + } else { + fs.writeFileSync('/tmp/satellite-version-selection', answer.url) + fs.unlinkSync('/tmp/satellite-version-selection-name') + } + } else if (!answer.ref || answer.ref === 'cancel') { + console.error('No version was selected!') + } else if (answer.ref === 'latest beta') { + selectBuildOfType('beta') + } else if (answer.ref === 'latest stable') { + selectBuildOfType('stable') + } else if (answer.ref === 'specific beta') { + chooseOfType('beta') + } else if (answer.ref === 'specific stable') { + chooseOfType('stable') + } +} + +if (process.argv[2]) { + selectBuildOfType(process.argv[2], process.argv[3]) +} else { + runPrompt() +} diff --git a/pi-image/update-prompt/package.json b/pi-image/update-prompt/package.json new file mode 100644 index 0000000..fe1aa11 --- /dev/null +++ b/pi-image/update-prompt/package.json @@ -0,0 +1,15 @@ +{ + "name": "update-prompt", + "version": "1.0.0", + "main": "main.js", + "type": "module", + "license": "MIT", + "dependencies": { + "inquirer": "^9.2.14", + "semver": "^7.6.0" + }, + "packageManager": "yarn@4.1.0", + "engines": { + "node": ">=18.18" + } +} diff --git a/pi-image/update-prompt/yarn.lock b/pi-image/update-prompt/yarn.lock new file mode 100644 index 0000000..5b3a60a --- /dev/null +++ b/pi-image/update-prompt/yarn.lock @@ -0,0 +1,606 @@ +# This file is generated by running "yarn install" inside your project. +# Manual changes might be lost - proceed with caution! + +__metadata: + version: 8 + cacheKey: 10c0 + +"@ljharb/through@npm:^2.3.12": + version: 2.3.12 + resolution: "@ljharb/through@npm:2.3.12" + dependencies: + call-bind: "npm:^1.0.5" + checksum: 10c0/7560aaef7b6ef88c16783ffde37278e2177c7f0f5427400059a8a7687b144dc711bf5b2347ab27e858a29f25e4b868d77c915c9614bc399b82b8123430614653 + languageName: node + linkType: hard + +"ansi-escapes@npm:^4.3.2": + version: 4.3.2 + resolution: "ansi-escapes@npm:4.3.2" + dependencies: + type-fest: "npm:^0.21.3" + checksum: 10c0/da917be01871525a3dfcf925ae2977bc59e8c513d4423368645634bf5d4ceba5401574eb705c1e92b79f7292af5a656f78c5725a4b0e1cec97c4b413705c1d50 + languageName: node + linkType: hard + +"ansi-regex@npm:^5.0.1": + version: 5.0.1 + resolution: "ansi-regex@npm:5.0.1" + checksum: 10c0/9a64bb8627b434ba9327b60c027742e5d17ac69277960d041898596271d992d4d52ba7267a63ca10232e29f6107fc8a835f6ce8d719b88c5f8493f8254813737 + languageName: node + linkType: hard + +"ansi-styles@npm:^4.0.0, ansi-styles@npm:^4.1.0": + version: 4.3.0 + resolution: "ansi-styles@npm:4.3.0" + dependencies: + color-convert: "npm:^2.0.1" + checksum: 10c0/895a23929da416f2bd3de7e9cb4eabd340949328ab85ddd6e484a637d8f6820d485f53933446f5291c3b760cbc488beb8e88573dd0f9c7daf83dccc8fe81b041 + languageName: node + linkType: hard + +"base64-js@npm:^1.3.1": + version: 1.5.1 + resolution: "base64-js@npm:1.5.1" + checksum: 10c0/f23823513b63173a001030fae4f2dabe283b99a9d324ade3ad3d148e218134676f1ee8568c877cd79ec1c53158dcf2d2ba527a97c606618928ba99dd930102bf + languageName: node + linkType: hard + +"bl@npm:^4.1.0": + version: 4.1.0 + resolution: "bl@npm:4.1.0" + dependencies: + buffer: "npm:^5.5.0" + inherits: "npm:^2.0.4" + readable-stream: "npm:^3.4.0" + checksum: 10c0/02847e1d2cb089c9dc6958add42e3cdeaf07d13f575973963335ac0fdece563a50ac770ac4c8fa06492d2dd276f6cc3b7f08c7cd9c7a7ad0f8d388b2a28def5f + languageName: node + linkType: hard + +"buffer@npm:^5.5.0": + version: 5.7.1 + resolution: "buffer@npm:5.7.1" + dependencies: + base64-js: "npm:^1.3.1" + ieee754: "npm:^1.1.13" + checksum: 10c0/27cac81cff434ed2876058d72e7c4789d11ff1120ef32c9de48f59eab58179b66710c488987d295ae89a228f835fc66d088652dffeb8e3ba8659f80eb091d55e + languageName: node + linkType: hard + +"call-bind@npm:^1.0.5": + version: 1.0.6 + resolution: "call-bind@npm:1.0.6" + dependencies: + es-errors: "npm:^1.3.0" + function-bind: "npm:^1.1.2" + get-intrinsic: "npm:^1.2.3" + set-function-length: "npm:^1.2.0" + checksum: 10c0/8dd9d4dad0a3ba4d1799a7baccc1b8dd4948ec99c6c7e88a8ac80bd814a34c87cc2b14680f0e343d9904e9e4a0a5b8c08758022ca0d1ef13f2723cd3720159f0 + languageName: node + linkType: hard + +"chalk@npm:^4.1.0": + version: 4.1.2 + resolution: "chalk@npm:4.1.2" + dependencies: + ansi-styles: "npm:^4.1.0" + supports-color: "npm:^7.1.0" + checksum: 10c0/4a3fef5cc34975c898ffe77141450f679721df9dde00f6c304353fa9c8b571929123b26a0e4617bde5018977eb655b31970c297b91b63ee83bb82aeb04666880 + languageName: node + linkType: hard + +"chalk@npm:^5.3.0": + version: 5.3.0 + resolution: "chalk@npm:5.3.0" + checksum: 10c0/8297d436b2c0f95801103ff2ef67268d362021b8210daf8ddbe349695333eb3610a71122172ff3b0272f1ef2cf7cc2c41fdaa4715f52e49ffe04c56340feed09 + languageName: node + linkType: hard + +"chardet@npm:^0.7.0": + version: 0.7.0 + resolution: "chardet@npm:0.7.0" + checksum: 10c0/96e4731b9ec8050cbb56ab684e8c48d6c33f7826b755802d14e3ebfdc51c57afeece3ea39bc6b09acc359e4363525388b915e16640c1378053820f5e70d0f27d + languageName: node + linkType: hard + +"cli-cursor@npm:^3.1.0": + version: 3.1.0 + resolution: "cli-cursor@npm:3.1.0" + dependencies: + restore-cursor: "npm:^3.1.0" + checksum: 10c0/92a2f98ff9037d09be3dfe1f0d749664797fb674bf388375a2207a1203b69d41847abf16434203e0089212479e47a358b13a0222ab9fccfe8e2644a7ccebd111 + languageName: node + linkType: hard + +"cli-spinners@npm:^2.5.0": + version: 2.9.2 + resolution: "cli-spinners@npm:2.9.2" + checksum: 10c0/907a1c227ddf0d7a101e7ab8b300affc742ead4b4ebe920a5bf1bc6d45dce2958fcd195eb28fa25275062fe6fa9b109b93b63bc8033396ed3bcb50297008b3a3 + languageName: node + linkType: hard + +"cli-width@npm:^4.1.0": + version: 4.1.0 + resolution: "cli-width@npm:4.1.0" + checksum: 10c0/1fbd56413578f6117abcaf858903ba1f4ad78370a4032f916745fa2c7e390183a9d9029cf837df320b0fdce8137668e522f60a30a5f3d6529ff3872d265a955f + languageName: node + linkType: hard + +"clone@npm:^1.0.2": + version: 1.0.4 + resolution: "clone@npm:1.0.4" + checksum: 10c0/2176952b3649293473999a95d7bebfc9dc96410f6cbd3d2595cf12fd401f63a4bf41a7adbfd3ab2ff09ed60cb9870c58c6acdd18b87767366fabfc163700f13b + languageName: node + linkType: hard + +"color-convert@npm:^2.0.1": + version: 2.0.1 + resolution: "color-convert@npm:2.0.1" + dependencies: + color-name: "npm:~1.1.4" + checksum: 10c0/37e1150172f2e311fe1b2df62c6293a342ee7380da7b9cfdba67ea539909afbd74da27033208d01d6d5cfc65ee7868a22e18d7e7648e004425441c0f8a15a7d7 + languageName: node + linkType: hard + +"color-name@npm:~1.1.4": + version: 1.1.4 + resolution: "color-name@npm:1.1.4" + checksum: 10c0/a1a3f914156960902f46f7f56bc62effc6c94e84b2cae157a526b1c1f74b677a47ec602bf68a61abfa2b42d15b7c5651c6dbe72a43af720bc588dff885b10f95 + languageName: node + linkType: hard + +"defaults@npm:^1.0.3": + version: 1.0.4 + resolution: "defaults@npm:1.0.4" + dependencies: + clone: "npm:^1.0.2" + checksum: 10c0/9cfbe498f5c8ed733775db62dfd585780387d93c17477949e1670bfcfb9346e0281ce8c4bf9f4ac1fc0f9b851113bd6dc9e41182ea1644ccd97de639fa13c35a + languageName: node + linkType: hard + +"define-data-property@npm:^1.1.1": + version: 1.1.2 + resolution: "define-data-property@npm:1.1.2" + dependencies: + es-errors: "npm:^1.3.0" + get-intrinsic: "npm:^1.2.2" + gopd: "npm:^1.0.1" + has-property-descriptors: "npm:^1.0.1" + checksum: 10c0/c496512a9b37c0a1708931a7ef419c120d23e672758fd41903f0593d6c48b2366976a484ad97bd45ed636da712dfa886c0908bf2c77b3f7ca36d7299b23a24bb + languageName: node + linkType: hard + +"emoji-regex@npm:^8.0.0": + version: 8.0.0 + resolution: "emoji-regex@npm:8.0.0" + checksum: 10c0/b6053ad39951c4cf338f9092d7bfba448cdfd46fe6a2a034700b149ac9ffbc137e361cbd3c442297f86bed2e5f7576c1b54cc0a6bf8ef5106cc62f496af35010 + languageName: node + linkType: hard + +"es-errors@npm:^1.3.0": + version: 1.3.0 + resolution: "es-errors@npm:1.3.0" + checksum: 10c0/0a61325670072f98d8ae3b914edab3559b6caa980f08054a3b872052640d91da01d38df55df797fcc916389d77fc92b8d5906cf028f4db46d7e3003abecbca85 + languageName: node + linkType: hard + +"escape-string-regexp@npm:^1.0.5": + version: 1.0.5 + resolution: "escape-string-regexp@npm:1.0.5" + checksum: 10c0/a968ad453dd0c2724e14a4f20e177aaf32bb384ab41b674a8454afe9a41c5e6fe8903323e0a1052f56289d04bd600f81278edf140b0fcc02f5cac98d0f5b5371 + languageName: node + linkType: hard + +"external-editor@npm:^3.1.0": + version: 3.1.0 + resolution: "external-editor@npm:3.1.0" + dependencies: + chardet: "npm:^0.7.0" + iconv-lite: "npm:^0.4.24" + tmp: "npm:^0.0.33" + checksum: 10c0/c98f1ba3efdfa3c561db4447ff366a6adb5c1e2581462522c56a18bf90dfe4da382f9cd1feee3e330108c3595a854b218272539f311ba1b3298f841eb0fbf339 + languageName: node + linkType: hard + +"figures@npm:^3.2.0": + version: 3.2.0 + resolution: "figures@npm:3.2.0" + dependencies: + escape-string-regexp: "npm:^1.0.5" + checksum: 10c0/9c421646ede432829a50bc4e55c7a4eb4bcb7cc07b5bab2f471ef1ab9a344595bbebb6c5c21470093fbb730cd81bbca119624c40473a125293f656f49cb47629 + languageName: node + linkType: hard + +"function-bind@npm:^1.1.2": + version: 1.1.2 + resolution: "function-bind@npm:1.1.2" + checksum: 10c0/d8680ee1e5fcd4c197e4ac33b2b4dce03c71f4d91717292785703db200f5c21f977c568d28061226f9b5900cbcd2c84463646134fd5337e7925e0942bc3f46d5 + languageName: node + linkType: hard + +"get-intrinsic@npm:^1.1.3, get-intrinsic@npm:^1.2.2, get-intrinsic@npm:^1.2.3": + version: 1.2.4 + resolution: "get-intrinsic@npm:1.2.4" + dependencies: + es-errors: "npm:^1.3.0" + function-bind: "npm:^1.1.2" + has-proto: "npm:^1.0.1" + has-symbols: "npm:^1.0.3" + hasown: "npm:^2.0.0" + checksum: 10c0/0a9b82c16696ed6da5e39b1267104475c47e3a9bdbe8b509dfe1710946e38a87be70d759f4bb3cda042d76a41ef47fe769660f3b7c0d1f68750299344ffb15b7 + languageName: node + linkType: hard + +"gopd@npm:^1.0.1": + version: 1.0.1 + resolution: "gopd@npm:1.0.1" + dependencies: + get-intrinsic: "npm:^1.1.3" + checksum: 10c0/505c05487f7944c552cee72087bf1567debb470d4355b1335f2c262d218ebbff805cd3715448fe29b4b380bae6912561d0467233e4165830efd28da241418c63 + languageName: node + linkType: hard + +"has-flag@npm:^4.0.0": + version: 4.0.0 + resolution: "has-flag@npm:4.0.0" + checksum: 10c0/2e789c61b7888d66993e14e8331449e525ef42aac53c627cc53d1c3334e768bcb6abdc4f5f0de1478a25beec6f0bd62c7549058b7ac53e924040d4f301f02fd1 + languageName: node + linkType: hard + +"has-property-descriptors@npm:^1.0.1": + version: 1.0.1 + resolution: "has-property-descriptors@npm:1.0.1" + dependencies: + get-intrinsic: "npm:^1.2.2" + checksum: 10c0/d62ba94b40150b00d621bc64a6aedb5bf0ee495308b4b7ed6bac856043db3cdfb1db553ae81cec91c9d2bd82057ff0e94145e7fa25d5aa5985ed32e0921927f6 + languageName: node + linkType: hard + +"has-proto@npm:^1.0.1": + version: 1.0.1 + resolution: "has-proto@npm:1.0.1" + checksum: 10c0/c8a8fe411f810b23a564bd5546a8f3f0fff6f1b692740eb7a2fdc9df716ef870040806891e2f23ff4653f1083e3895bf12088703dd1a0eac3d9202d3a4768cd0 + languageName: node + linkType: hard + +"has-symbols@npm:^1.0.3": + version: 1.0.3 + resolution: "has-symbols@npm:1.0.3" + checksum: 10c0/e6922b4345a3f37069cdfe8600febbca791c94988c01af3394d86ca3360b4b93928bbf395859158f88099cb10b19d98e3bbab7c9ff2c1bd09cf665ee90afa2c3 + languageName: node + linkType: hard + +"hasown@npm:^2.0.0": + version: 2.0.0 + resolution: "hasown@npm:2.0.0" + dependencies: + function-bind: "npm:^1.1.2" + checksum: 10c0/5d415b114f410661208c95e7ab4879f1cc2765b8daceff4dc8718317d1cb7b9ffa7c5d1eafd9a4389c9aab7445d6ea88e05f3096cb1e529618b55304956b87fc + languageName: node + linkType: hard + +"iconv-lite@npm:^0.4.24": + version: 0.4.24 + resolution: "iconv-lite@npm:0.4.24" + dependencies: + safer-buffer: "npm:>= 2.1.2 < 3" + checksum: 10c0/c6886a24cc00f2a059767440ec1bc00d334a89f250db8e0f7feb4961c8727118457e27c495ba94d082e51d3baca378726cd110aaf7ded8b9bbfd6a44760cf1d4 + languageName: node + linkType: hard + +"ieee754@npm:^1.1.13": + version: 1.2.1 + resolution: "ieee754@npm:1.2.1" + checksum: 10c0/b0782ef5e0935b9f12883a2e2aa37baa75da6e66ce6515c168697b42160807d9330de9a32ec1ed73149aea02e0d822e572bca6f1e22bdcbd2149e13b050b17bb + languageName: node + linkType: hard + +"inherits@npm:^2.0.3, inherits@npm:^2.0.4": + version: 2.0.4 + resolution: "inherits@npm:2.0.4" + checksum: 10c0/4e531f648b29039fb7426fb94075e6545faa1eb9fe83c29f0b6d9e7263aceb4289d2d4557db0d428188eeb449cc7c5e77b0a0b2c4e248ff2a65933a0dee49ef2 + languageName: node + linkType: hard + +"inquirer@npm:^9.2.14": + version: 9.2.14 + resolution: "inquirer@npm:9.2.14" + dependencies: + "@ljharb/through": "npm:^2.3.12" + ansi-escapes: "npm:^4.3.2" + chalk: "npm:^5.3.0" + cli-cursor: "npm:^3.1.0" + cli-width: "npm:^4.1.0" + external-editor: "npm:^3.1.0" + figures: "npm:^3.2.0" + lodash: "npm:^4.17.21" + mute-stream: "npm:1.0.0" + ora: "npm:^5.4.1" + run-async: "npm:^3.0.0" + rxjs: "npm:^7.8.1" + string-width: "npm:^4.2.3" + strip-ansi: "npm:^6.0.1" + wrap-ansi: "npm:^6.2.0" + checksum: 10c0/de4fc9054e4816835bfc1cee1db254b0b8df816fb57fc13d694cd4e80c13e43230b01bde0526e74f620910a64e3ad0f99ec89869f88e1cf50aa70d4958ef62cb + languageName: node + linkType: hard + +"is-fullwidth-code-point@npm:^3.0.0": + version: 3.0.0 + resolution: "is-fullwidth-code-point@npm:3.0.0" + checksum: 10c0/bb11d825e049f38e04c06373a8d72782eee0205bda9d908cc550ccb3c59b99d750ff9537982e01733c1c94a58e35400661f57042158ff5e8f3e90cf936daf0fc + languageName: node + linkType: hard + +"is-interactive@npm:^1.0.0": + version: 1.0.0 + resolution: "is-interactive@npm:1.0.0" + checksum: 10c0/dd47904dbf286cd20aa58c5192161be1a67138485b9836d5a70433b21a45442e9611b8498b8ab1f839fc962c7620667a50535fdfb4a6bc7989b8858645c06b4d + languageName: node + linkType: hard + +"is-unicode-supported@npm:^0.1.0": + version: 0.1.0 + resolution: "is-unicode-supported@npm:0.1.0" + checksum: 10c0/00cbe3455c3756be68d2542c416cab888aebd5012781d6819749fefb15162ff23e38501fe681b3d751c73e8ff561ac09a5293eba6f58fdf0178462ce6dcb3453 + languageName: node + linkType: hard + +"lodash@npm:^4.17.21": + version: 4.17.21 + resolution: "lodash@npm:4.17.21" + checksum: 10c0/d8cbea072bb08655bb4c989da418994b073a608dffa608b09ac04b43a791b12aeae7cd7ad919aa4c925f33b48490b5cfe6c1f71d827956071dae2e7bb3a6b74c + languageName: node + linkType: hard + +"log-symbols@npm:^4.1.0": + version: 4.1.0 + resolution: "log-symbols@npm:4.1.0" + dependencies: + chalk: "npm:^4.1.0" + is-unicode-supported: "npm:^0.1.0" + checksum: 10c0/67f445a9ffa76db1989d0fa98586e5bc2fd5247260dafb8ad93d9f0ccd5896d53fb830b0e54dade5ad838b9de2006c826831a3c528913093af20dff8bd24aca6 + languageName: node + linkType: hard + +"lru-cache@npm:^6.0.0": + version: 6.0.0 + resolution: "lru-cache@npm:6.0.0" + dependencies: + yallist: "npm:^4.0.0" + checksum: 10c0/cb53e582785c48187d7a188d3379c181b5ca2a9c78d2bce3e7dee36f32761d1c42983da3fe12b55cb74e1779fa94cdc2e5367c028a9b35317184ede0c07a30a9 + languageName: node + linkType: hard + +"mimic-fn@npm:^2.1.0": + version: 2.1.0 + resolution: "mimic-fn@npm:2.1.0" + checksum: 10c0/b26f5479d7ec6cc2bce275a08f146cf78f5e7b661b18114e2506dd91ec7ec47e7a25bf4360e5438094db0560bcc868079fb3b1fb3892b833c1ecbf63f80c95a4 + languageName: node + linkType: hard + +"mute-stream@npm:1.0.0": + version: 1.0.0 + resolution: "mute-stream@npm:1.0.0" + checksum: 10c0/dce2a9ccda171ec979a3b4f869a102b1343dee35e920146776780de182f16eae459644d187e38d59a3d37adf85685e1c17c38cf7bfda7e39a9880f7a1d10a74c + languageName: node + linkType: hard + +"onetime@npm:^5.1.0": + version: 5.1.2 + resolution: "onetime@npm:5.1.2" + dependencies: + mimic-fn: "npm:^2.1.0" + checksum: 10c0/ffcef6fbb2692c3c40749f31ea2e22677a876daea92959b8a80b521d95cca7a668c884d8b2045d1d8ee7d56796aa405c405462af112a1477594cc63531baeb8f + languageName: node + linkType: hard + +"ora@npm:^5.4.1": + version: 5.4.1 + resolution: "ora@npm:5.4.1" + dependencies: + bl: "npm:^4.1.0" + chalk: "npm:^4.1.0" + cli-cursor: "npm:^3.1.0" + cli-spinners: "npm:^2.5.0" + is-interactive: "npm:^1.0.0" + is-unicode-supported: "npm:^0.1.0" + log-symbols: "npm:^4.1.0" + strip-ansi: "npm:^6.0.0" + wcwidth: "npm:^1.0.1" + checksum: 10c0/10ff14aace236d0e2f044193362b22edce4784add08b779eccc8f8ef97195cae1248db8ec1ec5f5ff076f91acbe573f5f42a98c19b78dba8c54eefff983cae85 + languageName: node + linkType: hard + +"os-tmpdir@npm:~1.0.2": + version: 1.0.2 + resolution: "os-tmpdir@npm:1.0.2" + checksum: 10c0/f438450224f8e2687605a8dd318f0db694b6293c5d835ae509a69e97c8de38b6994645337e5577f5001115470414638978cc49da1cdcc25106dad8738dc69990 + languageName: node + linkType: hard + +"readable-stream@npm:^3.4.0": + version: 3.6.2 + resolution: "readable-stream@npm:3.6.2" + dependencies: + inherits: "npm:^2.0.3" + string_decoder: "npm:^1.1.1" + util-deprecate: "npm:^1.0.1" + checksum: 10c0/e37be5c79c376fdd088a45fa31ea2e423e5d48854be7a22a58869b4e84d25047b193f6acb54f1012331e1bcd667ffb569c01b99d36b0bd59658fb33f513511b7 + languageName: node + linkType: hard + +"restore-cursor@npm:^3.1.0": + version: 3.1.0 + resolution: "restore-cursor@npm:3.1.0" + dependencies: + onetime: "npm:^5.1.0" + signal-exit: "npm:^3.0.2" + checksum: 10c0/8051a371d6aa67ff21625fa94e2357bd81ffdc96267f3fb0fc4aaf4534028343836548ef34c240ffa8c25b280ca35eb36be00b3cb2133fa4f51896d7e73c6b4f + languageName: node + linkType: hard + +"run-async@npm:^3.0.0": + version: 3.0.0 + resolution: "run-async@npm:3.0.0" + checksum: 10c0/b18b562ae37c3020083dcaae29642e4cc360c824fbfb6b7d50d809a9d5227bb986152d09310255842c8dce40526e82ca768f02f00806c91ba92a8dfa6159cb85 + languageName: node + linkType: hard + +"rxjs@npm:^7.8.1": + version: 7.8.1 + resolution: "rxjs@npm:7.8.1" + dependencies: + tslib: "npm:^2.1.0" + checksum: 10c0/3c49c1ecd66170b175c9cacf5cef67f8914dcbc7cd0162855538d365c83fea631167cacb644b3ce533b2ea0e9a4d0b12175186985f89d75abe73dbd8f7f06f68 + languageName: node + linkType: hard + +"safe-buffer@npm:~5.2.0": + version: 5.2.1 + resolution: "safe-buffer@npm:5.2.1" + checksum: 10c0/6501914237c0a86e9675d4e51d89ca3c21ffd6a31642efeba25ad65720bce6921c9e7e974e5be91a786b25aa058b5303285d3c15dbabf983a919f5f630d349f3 + languageName: node + linkType: hard + +"safer-buffer@npm:>= 2.1.2 < 3": + version: 2.1.2 + resolution: "safer-buffer@npm:2.1.2" + checksum: 10c0/7e3c8b2e88a1841c9671094bbaeebd94448111dd90a81a1f606f3f67708a6ec57763b3b47f06da09fc6054193e0e6709e77325415dc8422b04497a8070fa02d4 + languageName: node + linkType: hard + +"semver@npm:^7.6.0": + version: 7.6.0 + resolution: "semver@npm:7.6.0" + dependencies: + lru-cache: "npm:^6.0.0" + bin: + semver: bin/semver.js + checksum: 10c0/fbfe717094ace0aa8d6332d7ef5ce727259815bd8d8815700853f4faf23aacbd7192522f0dc5af6df52ef4fa85a355ebd2f5d39f554bd028200d6cf481ab9b53 + languageName: node + linkType: hard + +"set-function-length@npm:^1.2.0": + version: 1.2.0 + resolution: "set-function-length@npm:1.2.0" + dependencies: + define-data-property: "npm:^1.1.1" + function-bind: "npm:^1.1.2" + get-intrinsic: "npm:^1.2.2" + gopd: "npm:^1.0.1" + has-property-descriptors: "npm:^1.0.1" + checksum: 10c0/b4fdf68bbfa9944284a9469c04e0d9cdb7924942fab75cd11fb61e8a7518f0d40bbbbc1b46871f648a93b97d170d8047fe3492cdadff066a8a8ae4ce68d0564a + languageName: node + linkType: hard + +"signal-exit@npm:^3.0.2": + version: 3.0.7 + resolution: "signal-exit@npm:3.0.7" + checksum: 10c0/25d272fa73e146048565e08f3309d5b942c1979a6f4a58a8c59d5fa299728e9c2fcd1a759ec870863b1fd38653670240cd420dad2ad9330c71f36608a6a1c912 + languageName: node + linkType: hard + +"string-width@npm:^4.1.0, string-width@npm:^4.2.3": + version: 4.2.3 + resolution: "string-width@npm:4.2.3" + dependencies: + emoji-regex: "npm:^8.0.0" + is-fullwidth-code-point: "npm:^3.0.0" + strip-ansi: "npm:^6.0.1" + checksum: 10c0/1e525e92e5eae0afd7454086eed9c818ee84374bb80328fc41217ae72ff5f065ef1c9d7f72da41de40c75fa8bb3dee63d92373fd492c84260a552c636392a47b + languageName: node + linkType: hard + +"string_decoder@npm:^1.1.1": + version: 1.3.0 + resolution: "string_decoder@npm:1.3.0" + dependencies: + safe-buffer: "npm:~5.2.0" + checksum: 10c0/810614ddb030e271cd591935dcd5956b2410dd079d64ff92a1844d6b7588bf992b3e1b69b0f4d34a3e06e0bd73046ac646b5264c1987b20d0601f81ef35d731d + languageName: node + linkType: hard + +"strip-ansi@npm:^6.0.0, strip-ansi@npm:^6.0.1": + version: 6.0.1 + resolution: "strip-ansi@npm:6.0.1" + dependencies: + ansi-regex: "npm:^5.0.1" + checksum: 10c0/1ae5f212a126fe5b167707f716942490e3933085a5ff6c008ab97ab2f272c8025d3aa218b7bd6ab25729ca20cc81cddb252102f8751e13482a5199e873680952 + languageName: node + linkType: hard + +"supports-color@npm:^7.1.0": + version: 7.2.0 + resolution: "supports-color@npm:7.2.0" + dependencies: + has-flag: "npm:^4.0.0" + checksum: 10c0/afb4c88521b8b136b5f5f95160c98dee7243dc79d5432db7efc27efb219385bbc7d9427398e43dd6cc730a0f87d5085ce1652af7efbe391327bc0a7d0f7fc124 + languageName: node + linkType: hard + +"tmp@npm:^0.0.33": + version: 0.0.33 + resolution: "tmp@npm:0.0.33" + dependencies: + os-tmpdir: "npm:~1.0.2" + checksum: 10c0/69863947b8c29cabad43fe0ce65cec5bb4b481d15d4b4b21e036b060b3edbf3bc7a5541de1bacb437bb3f7c4538f669752627fdf9b4aaf034cebd172ba373408 + languageName: node + linkType: hard + +"tslib@npm:^2.1.0": + version: 2.6.2 + resolution: "tslib@npm:2.6.2" + checksum: 10c0/e03a8a4271152c8b26604ed45535954c0a45296e32445b4b87f8a5abdb2421f40b59b4ca437c4346af0f28179780d604094eb64546bee2019d903d01c6c19bdb + languageName: node + linkType: hard + +"type-fest@npm:^0.21.3": + version: 0.21.3 + resolution: "type-fest@npm:0.21.3" + checksum: 10c0/902bd57bfa30d51d4779b641c2bc403cdf1371fb9c91d3c058b0133694fcfdb817aef07a47f40faf79039eecbaa39ee9d3c532deff244f3a19ce68cea71a61e8 + languageName: node + linkType: hard + +"update-prompt@workspace:.": + version: 0.0.0-use.local + resolution: "update-prompt@workspace:." + dependencies: + inquirer: "npm:^9.2.14" + semver: "npm:^7.6.0" + languageName: unknown + linkType: soft + +"util-deprecate@npm:^1.0.1": + version: 1.0.2 + resolution: "util-deprecate@npm:1.0.2" + checksum: 10c0/41a5bdd214df2f6c3ecf8622745e4a366c4adced864bc3c833739791aeeeb1838119af7daed4ba36428114b5c67dcda034a79c882e97e43c03e66a4dd7389942 + languageName: node + linkType: hard + +"wcwidth@npm:^1.0.1": + version: 1.0.1 + resolution: "wcwidth@npm:1.0.1" + dependencies: + defaults: "npm:^1.0.3" + checksum: 10c0/5b61ca583a95e2dd85d7078400190efd452e05751a64accb8c06ce4db65d7e0b0cde9917d705e826a2e05cc2548f61efde115ffa374c3e436d04be45c889e5b4 + languageName: node + linkType: hard + +"wrap-ansi@npm:^6.2.0": + version: 6.2.0 + resolution: "wrap-ansi@npm:6.2.0" + dependencies: + ansi-styles: "npm:^4.0.0" + string-width: "npm:^4.1.0" + strip-ansi: "npm:^6.0.0" + checksum: 10c0/baad244e6e33335ea24e86e51868fe6823626e3a3c88d9a6674642afff1d34d9a154c917e74af8d845fd25d170c4ea9cf69a47133c3f3656e1252b3d462d9f6c + languageName: node + linkType: hard + +"yallist@npm:^4.0.0": + version: 4.0.0 + resolution: "yallist@npm:4.0.0" + checksum: 10c0/2286b5e8dbfe22204ab66e2ef5cc9bbb1e55dfc873bbe0d568aa943eb255d131890dfd5bf243637273d31119b870f49c18fcde2c6ffbb7a7a092b870dc90625a + languageName: node + linkType: hard diff --git a/pi-image/update.sh b/pi-image/update.sh index e197fff..e3f0fdc 100755 --- a/pi-image/update.sh +++ b/pi-image/update.sh @@ -3,6 +3,14 @@ # this is the bulk of the update script # It is a separate file, so that the freshly cloned copy is invoked, not the old copy +# TODO: fail if this happens, to avoid breaking existing arm installations +# CURRENT_ARCH=$(dpkg --print-architecture) +# if [[ "$CURRENT_ARCH" != "x64" && "$CURRENT_ARCH" != "amd64" && "$CURRENT_ARCH" != "arm64" ]]; then +# echo "$CURRENT_ARCH is not a supported cpu architecture for running Companion Satellite." +# echo "If you are running on an arm device (such as a Raspberry Pi), make sure to use an arm64 image." +# exit 1 +# fi + # imitiate the fnm setup done in .bashrc export FNM_DIR=/opt/fnm export PATH=/opt/fnm:$PATH @@ -15,20 +23,62 @@ fnm use --install-if-missing fnm default $(fnm current) corepack enable -# install dependencies -yarn config set httpTimeout 100000 -yarn +# Run interactive version picker +yarn --cwd "update-prompt" --silent install +node "update-prompt/main.js" $1 $2 + +# Get result +if [ -f /tmp/satellite-version-selection ]; then + SELECTED_URL=$(cat /tmp/satellite-version-selection) + SELECTED_NAME=$(cat /tmp/satellite-version-selection-name) + rm -f /tmp/satellite-version-selection + rm -f /tmp/satellite-version-selection-name +fi + +if [ -n "$SELECTED_URL" ]; then + echo "Installing from $SELECTED_URL" + + # download it + wget "$SELECTED_URL" -O /tmp/satellite-update.tar.gz -q --show-progress + + # extract download + echo "Extracting..." + rm -R -f /tmp/satellite-update + mkdir /tmp/satellite-update + tar -xzf /tmp/satellite-update.tar.gz --strip-components=1 -C /tmp/satellite-update + rm /tmp/satellite-update.tar.gz + + # copy across the useful files + rm -R -f /opt/companion-satellite + # mv /tmp/satellite-update/resources /opt/companion-satellite + # mv /tmp/satellite-update/*.rules /opt/companion-satellite/ + # rm -R /tmp/satellite-update + # TODO: this copying! + + # remove the old dependencies + rm -R -f node_modules || true + rm -R -f webui/node_modules || true + + echo "Finishing" +else + echo "Skipping update" +fi + + +# # install dependencies +# yarn config set httpTimeout 100000 +# yarn -# build typescript -yarn build +# # build typescript +# yarn build -# build webui -cd webui -yarn -yarn build +# # build webui +# cd webui +# yarn +# yarn build -# back to the main part -cd .. +# # back to the main part +# cd .. # update some tooling cp assets/linux/50-satellite.rules /etc/udev/rules.d/