@dotpi/tools 1.3.3 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorbackup/NOTES.md~ +974 -0
- package/.editorbackup/PIPEWIRE.md~ +42 -0
- package/.editorbackup/README.md~ +335 -0
- package/BACKUP-SANDO.command +61 -0
- package/BACKUP-SISIDO.command +61 -0
- package/NOTES.md +41 -1
- package/README.md +3 -13
- package/dotpi_root/bin/dotpi +1 -0
- package/dotpi_root/bin/dotpi_prepare_sd_card +34 -22
- package/dotpi_root/bin/dotpi_prepare_system +113 -68
- package/dotpi_root/bin/package.json +6 -0
- package/dotpi_root/{share/dotpi_avahi_monitor → dist/@dotpi/avahi_monitor}/dotpi_avahi_monitor.service +1 -5
- package/dotpi_root/dist/@dotpi/avahi_monitor/dotpi_install +21 -0
- package/dotpi_root/dist/@dotpi/avahi_monitor/dotpi_uninstall +17 -0
- package/dotpi_root/dist/@dotpi/avahi_monitor/package.json +10 -0
- package/dotpi_root/dist/@dotpi/javascript/bash.js +103 -0
- package/dotpi_root/dist/@dotpi/javascript/echo.js +13 -0
- package/dotpi_root/dist/@dotpi/javascript/filesystem.js +25 -0
- package/dotpi_root/dist/@dotpi/javascript/package.json +12 -0
- package/dotpi_root/dist/@dotpi/javascript/service.js +49 -0
- package/dotpi_root/dist/@dotpi/javascript/system.js +36 -0
- package/dotpi_root/dist/@dotpi/javascript/template.js +13 -0
- package/dotpi_root/dist/@dotpi/javascript/user.js +32 -0
- package/dotpi_root/dist/@dotpi/module/LICENSE +28 -0
- package/dotpi_root/dist/@dotpi/module/bin/dotpi_module +13 -0
- package/dotpi_root/dist/@dotpi/module/dotpi_install +52 -0
- package/dotpi_root/dist/@dotpi/module/dotpi_uninstall +50 -0
- package/dotpi_root/dist/@dotpi/module/package.json +22 -0
- package/dotpi_root/dist/@dotpi/module/src/configuration.js +43 -0
- package/dotpi_root/dist/@dotpi/module/src/createConfig.js +108 -0
- package/dotpi_root/dist/@dotpi/module/src/definition.js +7 -0
- package/dotpi_root/dist/@dotpi/module/src/index.js +0 -0
- package/dotpi_root/dist/@dotpi/module/src/install.js +145 -0
- package/dotpi_root/dist/@dotpi/module/src/uninstall.js +180 -0
- package/dotpi_root/etc/dotpi_environment_default.bash +16 -0
- package/dotpi_root/etc/dotpi_init.d/.gitkeep +0 -0
- package/dotpi_root/etc/dotpi_modules.json +8 -0
- package/dotpi_root/lib/package.json +6 -0
- package/dotpi_root/share/dotpi_audio_bluetooth/dotpi_audio_pipewire_relink +7 -6
- package/dotpi_root/share/dotpi_audio_bluetooth/package.json +6 -0
- package/dotpi_root/share/dotpi_functions/dotpi_functions_audio_device.bash +12 -26
- package/dotpi_root/share/dotpi_functions/dotpi_functions_configuration.bash +2 -2
- package/dotpi_root/share/dotpi_functions/dotpi_functions_service.bash +6 -2
- package/dotpi_root/share/dotpi_functions/dotpi_functions_system.bash +11 -0
- package/dotpi_root/share/dotpi_functions/dotpi_functions_user.bash +28 -0
- package/dotpi_root/share/dotpi_functions.bash +4 -4
- package/dotpi_root/share/dotpi_init.bash +10 -1
- package/dotpi_root/share/dotpi_pipewire/bin/dotpi_pipewire_relink +86 -0
- package/dotpi_root/share/dotpi_pipewire/dotpi_install +24 -0
- package/dotpi_root/share/dotpi_pipewire/package.json +9 -0
- package/dotpi_root/share/dotpi_pipewire/systemd/dotpi_pipewire.service +22 -0
- package/dotpi_root/share/dotpi_pipewire/systemd/dotpi_pipewire_command +29 -0
- package/dotpi_root/share/limits/zzz_dotpi_audio.conf +2 -6
- package/dotpi_root/share/wireplumber/wireplumber.conf.d/dotpi-wireplumber-config.conf +8 -0
- package/lerna.json +4 -0
- package/package.json +12 -2
- package/projects/asterismes.tgz +0 -0
- package/projects/example-bluetooth/configuration/.editorbackup/dotpi_instance_001.bash~ +4 -0
- package/projects/example-bluetooth/configuration/.editorbackup/dotpi_instance_002.bash~ +3 -0
- package/projects/example-bluetooth/configuration/.editorbackup/dotpi_project.bash~ +46 -0
- package/projects/example-bluetooth/configuration/dotpi_instance_001.bash +3 -0
- package/projects/example-bluetooth/configuration/dotpi_instance_002.bash +3 -0
- package/projects/example-bluetooth/configuration/dotpi_project.bash +48 -0
- package/projects/example-development/configuration/.editorbackup/dotpi_project.bash~ +59 -0
- package/projects/example-development/configuration/dotpi_instance_114.bash +4 -0
- package/projects/example-headphones/configuration/.editorbackup/dotpi_project.bash~ +18 -0
- package/projects/example-hifiberry/configuration/.editorbackup/dotpi_instance_012.bash~ +4 -0
- package/projects/example-hifiberry/configuration/.editorbackup/dotpi_project.bash~ +18 -0
- package/projects/example-network/configuration/.editorbackup/dotpi_project.bash~ +21 -0
- package/projects/led-test/.dotpi +3 -0
- package/projects/led-test/README.md +16 -0
- package/projects/led-test/dotpi_project.bash +29 -0
- package/projects/old/bad/.editorbackup/dotpi_environment_instance.bash~ +1 -0
- package/projects/old/bad/.editorbackup/dotpi_environment_project.bash~ +26 -0
- package/projects/old/bad/.editorbackup/dotpi_project.bash~ +33 -0
- package/projects/old/bad/.editorbackup/dotpi_tmp.bash~ +3 -0
- package/projects/old/bad/.editorbackup/wpa_supplicant.conf~ +37 -0
- package/projects/old/bad/dotpi_project.bash +20 -0
- package/projects/old/bluetooth/.editorbackup/dotpi_environment_instance.bash~ +1 -0
- package/projects/old/bluetooth/.editorbackup/dotpi_environment_project.bash~ +26 -0
- package/projects/old/bluetooth/.editorbackup/dotpi_project.bash~ +21 -0
- package/projects/old/bluetooth/.editorbackup/dotpi_tmp.bash~ +3 -0
- package/projects/old/bluetooth/.editorbackup/wpa_supplicant.conf~ +37 -0
- package/projects/old/bluetooth/dotpi_project.bash +29 -0
- package/projects/old/dev.zip +0 -0
- package/projects/old/example/.editorbackup/dotpi_environment_instance.bash~ +1 -0
- package/projects/old/example/.editorbackup/dotpi_environment_project.bash~ +26 -0
- package/projects/old/example/.editorbackup/dotpi_project.bash~ +21 -0
- package/projects/old/example/.editorbackup/dotpi_tmp.bash~ +3 -0
- package/projects/old/example/.editorbackup/wpa_supplicant.conf~ +37 -0
- package/projects/old/example/configuration/.editorbackup/dotpi_project.bash~ +21 -0
- package/projects/old/example/configuration/dotpi_project.bash +21 -0
- package/projects/qsddsqsd/.dotpi +3 -0
- package/projects/qsddsqsd/README.md +16 -0
- package/projects/qsddsqsd/dotpi_project.bash +29 -0
- package/src/constants.js +4 -4
- package/src/create-project.js +124 -56
- package/src/templates/dotpi_project.bash +5 -7
- package/src/utils.js +2 -2
- package/test/create-project.test.js +0 -1
- package/dotpi_root/share/jackd/dotpi_jackd_bluetooth.bash +0 -18
- package/dotpi_root/share/jackd/dotpi_jackd_command +0 -26
- package/dotpi_root/share/jackd/dotpi_jackd_headphones.bash +0 -21
- package/dotpi_root/share/jackd/dotpi_jackd_hifiberry.bash +0 -17
- package/dotpi_root/share/jackd/jackd.service +0 -22
- /package/dotpi_root/{share/dotpi_avahi_monitor → dist/@dotpi/avahi_monitor}/dotpi_avahi_monitor_command +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
trl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
|
|
2
|
+
country=FR
|
|
3
|
+
ap_scan=1
|
|
4
|
+
|
|
5
|
+
update_config=1
|
|
6
|
+
|
|
7
|
+
# higher priority number is higher precedence
|
|
8
|
+
|
|
9
|
+
# Generate psk with wpa_passphrase
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# local
|
|
13
|
+
network={
|
|
14
|
+
ssid="DOTP-A114"
|
|
15
|
+
scan_ssid=1
|
|
16
|
+
psk=de5ad6f1dd5b049933080e5113c8cdc8da75220cb97596f0b15e36c488eaa79c
|
|
17
|
+
key_mgmt=WPA-PSK
|
|
18
|
+
priority=90
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
# main
|
|
22
|
+
network={
|
|
23
|
+
ssid="DOTPI"
|
|
24
|
+
scan_ssid=1
|
|
25
|
+
psk=8cd8790e1ebc24e8f4f759aaadf4df7252e7eb653482839d9c4ba0a572d9abfd
|
|
26
|
+
key_mgmt=WPA-PSK
|
|
27
|
+
priority=100
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
# public internet
|
|
31
|
+
network={
|
|
32
|
+
ssid="welcome"
|
|
33
|
+
scan_ssid=1
|
|
34
|
+
psk=5ad3015eda5405c146e6bb4b3c11ac8a6e547a3a83e0fcc9dad1a4c9047d43c6
|
|
35
|
+
key_mgmt=WPA-PSK
|
|
36
|
+
priority=1000
|
|
37
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
dotpi_project_name="example"
|
|
4
|
+
|
|
5
|
+
dotpi_ssh_allow_password_authentication='yes'
|
|
6
|
+
|
|
7
|
+
dotpi_timezone='Europe/Paris'
|
|
8
|
+
dotpi_keymap='fr'
|
|
9
|
+
|
|
10
|
+
dotpi_soundcard='HiFiBerry DAC+ ADC Pro'
|
|
11
|
+
|
|
12
|
+
# add packages
|
|
13
|
+
# be sure to keep the parentheses, even for a single line
|
|
14
|
+
dotpi_apt_install+=(
|
|
15
|
+
# 'dnsutils' # dig
|
|
16
|
+
'jackmeter'
|
|
17
|
+
# 'locate'
|
|
18
|
+
# 'nmap' # test clients in network
|
|
19
|
+
# 'screen' # detach sessions
|
|
20
|
+
# 'sox' # sound prcessing
|
|
21
|
+
)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
dotpi_project_name="example"
|
|
4
|
+
|
|
5
|
+
dotpi_ssh_allow_password_authentication='yes'
|
|
6
|
+
|
|
7
|
+
dotpi_timezone='Europe/Paris'
|
|
8
|
+
dotpi_keymap='fr'
|
|
9
|
+
|
|
10
|
+
dotpi_soundcard='HiFiBerry DAC+ ADC Pro'
|
|
11
|
+
|
|
12
|
+
# add packages
|
|
13
|
+
# be sure to keep the parentheses, even for a single line
|
|
14
|
+
dotpi_apt_install+=(
|
|
15
|
+
# 'dnsutils' # dig
|
|
16
|
+
'jackmeter' # monitor sound activity in console
|
|
17
|
+
# 'locate'
|
|
18
|
+
# 'nmap' # test clients in network
|
|
19
|
+
# 'screen' # detach sessions
|
|
20
|
+
# 'mpv' # play soundfiles via jackd
|
|
21
|
+
)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# dotpi project - qsddsqsd
|
|
2
|
+
|
|
3
|
+
This directory contains the necessary configuration files to install a Raspberry Pi
|
|
4
|
+
that belongs to a given dotpi project.
|
|
5
|
+
|
|
6
|
+
## Warning
|
|
7
|
+
|
|
8
|
+
This directory contains sensitive informations that SHOULD NOT be shared on a
|
|
9
|
+
public repository.
|
|
10
|
+
|
|
11
|
+
In particular, the following files are ignored by default:
|
|
12
|
+
- dotpi_secrets.bash
|
|
13
|
+
- ssh
|
|
14
|
+
- network
|
|
15
|
+
|
|
16
|
+
You should thus share these files with people you trust through secure means.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# @dotpi/tools version
|
|
4
|
+
dotpi_tools_version='2.2.0'
|
|
5
|
+
|
|
6
|
+
# Project name
|
|
7
|
+
dotpi_project_name='qsddsqsd'
|
|
8
|
+
|
|
9
|
+
# Define soundcard
|
|
10
|
+
dotpi_audio_device='default'
|
|
11
|
+
|
|
12
|
+
# Node.js version
|
|
13
|
+
dotpi_node_version='lts'
|
|
14
|
+
|
|
15
|
+
# User-defined dotpi modules to install
|
|
16
|
+
dotpi_module_install+=(
|
|
17
|
+
'@dotpi/manager'
|
|
18
|
+
'@dotpi/led'
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
# Misc
|
|
22
|
+
dotpi_timezone='Europe/Paris'
|
|
23
|
+
dotpi_wifi_country_code='FR'
|
|
24
|
+
dotpi_keymap='fr'
|
|
25
|
+
|
|
26
|
+
# If you want to have some packages to be automatically installed
|
|
27
|
+
# or removed by default, you can list them in the arrays below
|
|
28
|
+
dotpi_apt_install+=()
|
|
29
|
+
dotpi_apt_uninstall+=()
|
package/src/constants.js
CHANGED
|
@@ -5,11 +5,12 @@ import { fileURLToPath } from 'node:url';
|
|
|
5
5
|
export const LIB_ROOT = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
6
6
|
export const CWD = process.cwd();
|
|
7
7
|
export const HOME = os.homedir();
|
|
8
|
+
export const DOTPI_ROOT = path.join(LIB_ROOT, 'dotpi_root');
|
|
8
9
|
|
|
9
10
|
// shell scripts that we need to execute
|
|
10
|
-
export const PATH_DOTPI_INIT_BASH = path.join(
|
|
11
|
-
export const PATH_DOTPI_PREPARE_SD_CARD_BASH = path.join(
|
|
12
|
-
// directories to read from and write to,
|
|
11
|
+
export const PATH_DOTPI_INIT_BASH = path.join(DOTPI_ROOT, 'share/dotpi_init.bash');
|
|
12
|
+
export const PATH_DOTPI_PREPARE_SD_CARD_BASH = path.join(DOTPI_ROOT, 'bin/dotpi_prepare_sd_card');
|
|
13
|
+
// directories to read from and write to, respectively
|
|
13
14
|
export const PATH_TEMPLATE_DIRECTORY = path.join(LIB_ROOT, 'src/templates');
|
|
14
15
|
|
|
15
16
|
// the files / directories that define a project
|
|
@@ -27,4 +28,3 @@ export const PATH_DOTPI_TMP_BASH = path.join(PATH_DOTPI_TMP_DIRECTORY, 'dotpi_tm
|
|
|
27
28
|
// misc
|
|
28
29
|
export const DOTPI_SSH_KEYS_PREFIX = 'id_rsa';
|
|
29
30
|
export const PROJECT_NAME_REGEXP = /^[a-z0-9\-_]+$/;
|
|
30
|
-
export const WIFI_ID_REGEXP = PROJECT_NAME_REGEXP;
|
package/src/create-project.js
CHANGED
|
@@ -6,6 +6,12 @@ import { execSync } from 'node:child_process';
|
|
|
6
6
|
import prompts from 'prompts';
|
|
7
7
|
import chalk from 'chalk';
|
|
8
8
|
|
|
9
|
+
import * as echo from '@dotpi/javascript/echo.js';
|
|
10
|
+
import * as bash from '@dotpi/javascript/bash.js';
|
|
11
|
+
import { install as moduleInstall } from '@dotpi/module/install.js';
|
|
12
|
+
import { createConfig as moduleCreateConfig } from '@dotpi/module/createConfig.js';
|
|
13
|
+
import { definitionGet as moduleDefinitionGet } from '@dotpi/module/definition.js';
|
|
14
|
+
|
|
9
15
|
import {
|
|
10
16
|
title,
|
|
11
17
|
renderTemplate,
|
|
@@ -19,6 +25,7 @@ import {
|
|
|
19
25
|
isDotpiProject,
|
|
20
26
|
} from './utils.js';
|
|
21
27
|
import {
|
|
28
|
+
DOTPI_ROOT,
|
|
22
29
|
// path of the files inside the final project
|
|
23
30
|
PATH_DOTPI_PROJECT_BASH,
|
|
24
31
|
PATH_DOTPI_SECRETS_BASH,
|
|
@@ -30,7 +37,6 @@ import {
|
|
|
30
37
|
// utilities
|
|
31
38
|
DOTPI_SSH_KEYS_PREFIX,
|
|
32
39
|
PROJECT_NAME_REGEXP,
|
|
33
|
-
WIFI_ID_REGEXP,
|
|
34
40
|
// this must be put in gitignore
|
|
35
41
|
PATH_DOTPI_TMP_DIRECTORY,
|
|
36
42
|
// where the command is executed
|
|
@@ -139,13 +145,6 @@ export async function configureProject(data, mocks = null) {
|
|
|
139
145
|
active: 'yes',
|
|
140
146
|
inactive: 'no'
|
|
141
147
|
},
|
|
142
|
-
{
|
|
143
|
-
type: prev => prev === true ? 'text' : false,
|
|
144
|
-
name: 'dotpiLedConfigFile',
|
|
145
|
-
message: 'Choose the dotpi-led configuration file:',
|
|
146
|
-
initial: './configuration/default.json',
|
|
147
|
-
format: val => val.trim(),
|
|
148
|
-
},
|
|
149
148
|
], { onCancel });
|
|
150
149
|
|
|
151
150
|
data.files[PATH_DOTPI_PROJECT_BASH] = renderTemplate('dotpi_project.bash', {
|
|
@@ -253,23 +252,9 @@ export async function configureWiFi(data, mocks = null) {
|
|
|
253
252
|
// https://people.freedesktop.org/~lkundrak/nm-dbus-api/nm-settings.html
|
|
254
253
|
// @note - let's consider we always use wpa-psk for now
|
|
255
254
|
|
|
255
|
+
const computedValues = {};
|
|
256
256
|
const answers = await prompts([
|
|
257
257
|
{
|
|
258
|
-
type: 'text',
|
|
259
|
-
name: 'wifiId',
|
|
260
|
-
message: 'Id of the WiFi connection:',
|
|
261
|
-
validate: value => {
|
|
262
|
-
const configPath = path.join(PATH_NETWORK_DIRECTORY, value);
|
|
263
|
-
|
|
264
|
-
if (!WIFI_ID_REGEXP.test(value)) {
|
|
265
|
-
return 'Invalid WiFi configuration id: use only lower case letters, digits, - and _';
|
|
266
|
-
} else if (fs.existsSync(configPath)) {
|
|
267
|
-
return `A WiFi configuration named "${value}" already exists`;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
return true;
|
|
271
|
-
},
|
|
272
|
-
}, {
|
|
273
258
|
type: 'select',
|
|
274
259
|
name: 'wifiMode',
|
|
275
260
|
message: 'Select WiFi mode:',
|
|
@@ -282,16 +267,48 @@ export async function configureWiFi(data, mocks = null) {
|
|
|
282
267
|
{
|
|
283
268
|
type: 'text',
|
|
284
269
|
name: 'wifiSsid',
|
|
285
|
-
message: 'Wifi SSID:',
|
|
270
|
+
message: 'Wifi name (SSID):',
|
|
271
|
+
validate: value => {
|
|
272
|
+
|
|
273
|
+
const ssidSize = new Blob([value]).size;
|
|
274
|
+
if (ssidSize === 0) {
|
|
275
|
+
return 'Please provide a non-empty SSID';
|
|
276
|
+
} else if(ssidSize > 32) {
|
|
277
|
+
return `'${value}' is too long (more than 32 bytes)`;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const wifiId = value.toLowerCase().replace(/[^a-z0-9\-_]/g, '_');
|
|
281
|
+
const configPath = path.join(PATH_NETWORK_DIRECTORY, value);
|
|
282
|
+
|
|
283
|
+
// @TODO: file is created later, this test is bypassed
|
|
284
|
+
if (fs.existsSync(configPath)) {
|
|
285
|
+
return `A WiFi configuration named "${value}" already exists`;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
Object.assign(computedValues, { wifiId });
|
|
289
|
+
return true;
|
|
290
|
+
},
|
|
286
291
|
},
|
|
287
292
|
{
|
|
288
293
|
type: 'text',
|
|
289
294
|
name: 'wifiPsk',
|
|
290
295
|
message: 'Wifi password:',
|
|
291
|
-
validate: value =>
|
|
296
|
+
validate: value => {
|
|
297
|
+
if (new Blob([value]).size < 8) {
|
|
298
|
+
return `'${value}' is too short (less than 8 bytes)`;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if (new Blob([value]).size > 63) {
|
|
302
|
+
return `'${value}' is too long (more than 63 bytes)`;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return true;
|
|
306
|
+
},
|
|
292
307
|
},
|
|
293
308
|
], { onCancel });
|
|
294
309
|
|
|
310
|
+
Object.assign(answers, computedValues);
|
|
311
|
+
|
|
295
312
|
const { wifiId, wifiMode } = answers;
|
|
296
313
|
const connectionPath = path.join(PATH_NETWORK_DIRECTORY, `${wifiId}.nmconnection`);
|
|
297
314
|
let connectionConfig = null;
|
|
@@ -346,7 +363,7 @@ export async function configureWiFi(data, mocks = null) {
|
|
|
346
363
|
|
|
347
364
|
|
|
348
365
|
export async function injectUtilityFiles(data) {
|
|
349
|
-
const {
|
|
366
|
+
const { projectName } = data;
|
|
350
367
|
|
|
351
368
|
data.files[PATH_DOTPI_FILE] = JSON.stringify({ dotpiToolsVersion: packageVersion() }, null, 2);
|
|
352
369
|
|
|
@@ -392,47 +409,98 @@ export async function persistProject(data, mocks = null) {
|
|
|
392
409
|
title(`Project ${projectName} successfully created!`);
|
|
393
410
|
}
|
|
394
411
|
|
|
412
|
+
export async function installModulesInProject(data) {
|
|
413
|
+
title('Install modules in project');
|
|
414
|
+
|
|
415
|
+
const dotpiRoot = DOTPI_ROOT;
|
|
416
|
+
const dotpiInit = await bash.dotpiInitSourceFileGet({ dotpiRoot });
|
|
417
|
+
|
|
418
|
+
const { projectName } = data;
|
|
419
|
+
const projectPath = path.join(CWD, projectName);
|
|
420
|
+
const projectDotpiInit = path.join(projectPath, PATH_DOTPI_PROJECT_BASH);
|
|
421
|
+
|
|
422
|
+
const modules = await bash.variableRead({
|
|
423
|
+
sourceFiles: [
|
|
424
|
+
dotpiInit,
|
|
425
|
+
projectDotpiInit,
|
|
426
|
+
],
|
|
427
|
+
variable: 'dotpi_module_install',
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
await moduleInstall(modules, {
|
|
431
|
+
dotpiRoot,
|
|
432
|
+
prefix: projectPath,
|
|
433
|
+
verbose: 'short',
|
|
434
|
+
})
|
|
435
|
+
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
export async function generateConfigFilesInProject(data) {
|
|
439
|
+
title('Generate config files for modules in project');
|
|
440
|
+
|
|
441
|
+
const dotpiRoot = DOTPI_ROOT;
|
|
442
|
+
const { projectName } = data;
|
|
443
|
+
const projectPath = path.join(CWD, projectName);
|
|
444
|
+
|
|
445
|
+
await moduleCreateConfig({
|
|
446
|
+
dotpiRoot,
|
|
447
|
+
prefix: projectPath,
|
|
448
|
+
verbose: 'short',
|
|
449
|
+
})
|
|
450
|
+
|
|
451
|
+
}
|
|
452
|
+
|
|
395
453
|
// Wrap it all
|
|
396
454
|
export default async function createProject() {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
455
|
+
try {
|
|
456
|
+
if (isDotpiProject()) {
|
|
457
|
+
console.log('');
|
|
458
|
+
console.log(chalk.yellow(`> Cannot create a dotpi project in this directory, it already contains a dotpi project`));
|
|
459
|
+
console.log('Aborting...');
|
|
460
|
+
process.exit(0);
|
|
461
|
+
}
|
|
403
462
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
463
|
+
const data = {
|
|
464
|
+
projectName: null,
|
|
465
|
+
files: {},
|
|
466
|
+
};
|
|
408
467
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
468
|
+
await prepareProject(data);
|
|
469
|
+
await configureProject(data);
|
|
470
|
+
await configureSSH(data);
|
|
471
|
+
await configureWiFi(data);
|
|
472
|
+
await injectUtilityFiles(data);
|
|
473
|
+
await persistProject(data);
|
|
415
474
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
name: 'configure',
|
|
419
|
-
message: 'Do you want to configure your local machine for this project?',
|
|
420
|
-
initial: true,
|
|
421
|
-
active: 'yes',
|
|
422
|
-
inactive: 'no'
|
|
423
|
-
}, { onCancel });
|
|
475
|
+
await installModulesInProject(data);
|
|
476
|
+
await generateConfigFilesInProject(data);
|
|
424
477
|
|
|
425
|
-
|
|
478
|
+
title('Configure local machine for project');
|
|
426
479
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
480
|
+
const { configure } = await prompts({
|
|
481
|
+
type: 'toggle',
|
|
482
|
+
name: 'configure',
|
|
483
|
+
message: 'Do you want to configure your local machine for this project?',
|
|
484
|
+
initial: true,
|
|
485
|
+
active: 'yes',
|
|
486
|
+
inactive: 'no'
|
|
487
|
+
}, { onCancel });
|
|
431
488
|
|
|
432
|
-
|
|
489
|
+
const { projectName } = data;
|
|
490
|
+
|
|
491
|
+
if (configure) {
|
|
492
|
+
const projectPath = path.join(CWD, projectName);
|
|
493
|
+
await configureHost(projectPath);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
console.log(`\
|
|
433
497
|
> The dotpi project "${projectName}" is ready to be installed on some Raspberry Pi
|
|
434
498
|
>
|
|
435
499
|
> Next Step: plug-in a SD Card with a Raspberry Pi OS (Lite) installed and run:
|
|
436
500
|
> ${chalk.yellow('dotpi-tools --install-rpi')}
|
|
437
501
|
`);
|
|
502
|
+
} catch (error) {
|
|
503
|
+
echo.error(`Error while creating dotpi project: ${error.message}`, error);
|
|
504
|
+
process.exit(1);
|
|
505
|
+
}
|
|
438
506
|
}
|
|
@@ -12,13 +12,11 @@ dotpi_audio_device='${d.soundCard}'
|
|
|
12
12
|
# Node.js version
|
|
13
13
|
dotpi_node_version='${d.nodeVersion}'
|
|
14
14
|
|
|
15
|
-
#
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
#
|
|
19
|
-
|
|
20
|
-
${d.installDotpiLed ? `\
|
|
21
|
-
dotpi_led_strip_configuration='${d.dotPiLedConfigFile}'` : ``}
|
|
15
|
+
# User-defined dotpi modules to install
|
|
16
|
+
dotpi_module_install+=(
|
|
17
|
+
${!d.installDotpiManager ? '# ' : ''}'@dotpi/manager'
|
|
18
|
+
${!d.installDotpiLed ? '# ' : ''}'@dotpi/led'
|
|
19
|
+
)
|
|
22
20
|
|
|
23
21
|
# Misc
|
|
24
22
|
dotpi_timezone='${d.timeZone}'
|
package/src/utils.js
CHANGED
|
@@ -89,7 +89,7 @@ export function isPrivateSshKey(pathname) {
|
|
|
89
89
|
export function isWindowsWsl() {
|
|
90
90
|
const buffer = execSync('uname -a', { shell: '/bin/bash' });
|
|
91
91
|
const unameString = buffer.toString();
|
|
92
|
-
return /
|
|
92
|
+
return /[Mm]icrosoft/.test(unameString);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/**
|
|
@@ -172,4 +172,4 @@ export async function chooseProject(basePathname, mocks = null) {
|
|
|
172
172
|
}, { onCancel });
|
|
173
173
|
|
|
174
174
|
return projectPath;
|
|
175
|
-
}
|
|
175
|
+
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# keep this
|
|
2
|
-
DOTPI_JACKD_ENVIRONMENT=(
|
|
3
|
-
JACK_NO_AUDIO_RESERVATION=1
|
|
4
|
-
)
|
|
5
|
-
|
|
6
|
-
# warning: long option for -d (--driver) seems broken
|
|
7
|
-
|
|
8
|
-
# explicit outchannels (default is 0)
|
|
9
|
-
|
|
10
|
-
DOTPI_JACKD_ARGUMENTS=(
|
|
11
|
-
--realtime
|
|
12
|
-
--realtime-priority 95
|
|
13
|
-
-d alsa
|
|
14
|
-
--device -d bluealsa
|
|
15
|
-
--period 1024
|
|
16
|
-
--nperiods 2
|
|
17
|
-
--rate 48000
|
|
18
|
-
)
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
local_file="$(dotpi readlink_follow "$0")"
|
|
4
|
-
local_path="$(dirname -- "$local_file")"
|
|
5
|
-
|
|
6
|
-
source "${local_path}/dotpi_jackd.bash"
|
|
7
|
-
|
|
8
|
-
echo "dotpi_jackd_command"
|
|
9
|
-
|
|
10
|
-
echo "ENV: ${DOTPI_JACKD_ENVIRONMENT[@]}"
|
|
11
|
-
echo "ARGS: ${DOTPI_JACKD_ARGUMENTS[@]}"
|
|
12
|
-
|
|
13
|
-
for e in "${DOTPI_JACKD_ENVIRONMENT[@]}" ; do
|
|
14
|
-
export "$e"
|
|
15
|
-
done
|
|
16
|
-
|
|
17
|
-
while IFS= read -r output ; do
|
|
18
|
-
jackd_pid="$!"
|
|
19
|
-
# forward output
|
|
20
|
-
echo "$output"
|
|
21
|
-
if [[ "$output" =~ JackAudioDriver.*stopping ]] ; then
|
|
22
|
-
dotpi echo_error "jackd stopped, it will be killed."
|
|
23
|
-
kill "$jackd_pid"
|
|
24
|
-
fi
|
|
25
|
-
done < <( jackd "${DOTPI_JACKD_ARGUMENTS[@]}" 2>&1)
|
|
26
|
-
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# keep this
|
|
2
|
-
DOTPI_JACKD_ENVIRONMENT=(
|
|
3
|
-
JACK_NO_AUDIO_RESERVATION=1
|
|
4
|
-
)
|
|
5
|
-
|
|
6
|
-
# warning: long option for -d (--driver) seems broken
|
|
7
|
-
|
|
8
|
-
# explicit outchannels (default is 0)
|
|
9
|
-
|
|
10
|
-
DOTPI_JACKD_ARGUMENTS=(
|
|
11
|
-
--realtime
|
|
12
|
-
--realtime-priority 95
|
|
13
|
-
-d alsa
|
|
14
|
-
--device hw:0
|
|
15
|
-
--playback
|
|
16
|
-
--period 1024
|
|
17
|
-
--nperiods 2
|
|
18
|
-
--rate 48000
|
|
19
|
-
--inchannels 0
|
|
20
|
-
--outchannels 2
|
|
21
|
-
)
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# keep this
|
|
2
|
-
DOTPI_JACKD_ENVIRONMENT=(
|
|
3
|
-
JACK_NO_AUDIO_RESERVATION=1
|
|
4
|
-
)
|
|
5
|
-
|
|
6
|
-
# warning: long option for -d (--driver) seems broken
|
|
7
|
-
|
|
8
|
-
DOTPI_JACKD_ARGUMENTS=(
|
|
9
|
-
--realtime
|
|
10
|
-
--realtime-priority 95
|
|
11
|
-
-d alsa
|
|
12
|
-
--device hw:0,0
|
|
13
|
-
--duplex
|
|
14
|
-
--period 128
|
|
15
|
-
--nperiods 2
|
|
16
|
-
--rate 48000
|
|
17
|
-
)
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
[Unit]
|
|
2
|
-
Description=Jack service
|
|
3
|
-
After=sound.target
|
|
4
|
-
|
|
5
|
-
[Service]
|
|
6
|
-
Type=exec
|
|
7
|
-
LimitRTPRIO=infinity
|
|
8
|
-
LimitMEMLOCK=infinity
|
|
9
|
-
User=pi
|
|
10
|
-
Group=audio
|
|
11
|
-
ExecStart=/opt/dotpi/share/jackd/dotpi_jackd_command
|
|
12
|
-
Restart=always
|
|
13
|
-
|
|
14
|
-
# wait before restarting
|
|
15
|
-
RestartSec=1s
|
|
16
|
-
|
|
17
|
-
# Do not stop to try restarting service
|
|
18
|
-
StartLimitBurst=0
|
|
19
|
-
|
|
20
|
-
[Install]
|
|
21
|
-
WantedBy=multi-user.target
|
|
22
|
-
|
|
File without changes
|