@dotpi/tools 2.11.5 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,13 @@
2
2
 
3
3
  set +e
4
4
 
5
+ #############################################################################
6
+ # Notes
7
+ #
8
+ # - this script is ran with admin privileges
9
+ # - log files are located in `/opt/dotpi/var/log/`
10
+ #############################################################################
11
+
5
12
  local_file="$(readlink -f -- "$0")"
6
13
  local_path="$(dirname -- "$local_file")"
7
14
 
@@ -57,12 +64,16 @@ if [ -f "$user_data_file" ] ; then
57
64
  mv "$user_data_file" "${user_data_file}.disabled"
58
65
  fi
59
66
 
60
- ####### hostname
67
+ #############################################################################
68
+ ####### HOSTNAME
69
+ #############################################################################
61
70
 
62
71
  dotpi echo_info "Set hostname to ${dotpi_instance_hostname}"
63
72
  dotpi system_set_hostname "$dotpi_instance_hostname"
64
73
 
65
- ####### ssh
74
+ #############################################################################
75
+ ####### SSH
76
+ #############################################################################
66
77
 
67
78
  dotpi echo_info "Configure SSH"
68
79
 
@@ -94,9 +105,11 @@ sed -i -e '/^PasswordAuthentication/d' /etc/ssh/sshd_config
94
105
 
95
106
  # allow for password authentication
96
107
  # (after exclusive imager_custom enable_ssh -k)
97
- echo "PasswordAuthentication ${dotpi_ssh_allow_password_authentication}" >>/etc/ssh/sshd_config
108
+ echo "PasswordAuthentication ${dotpi_ssh_allow_password_authentication}" >> /etc/ssh/sshd_config
98
109
 
99
- ####### user
110
+ #############################################################################
111
+ ####### USER
112
+ #############################################################################
100
113
 
101
114
  dotpi echo_info "Configure first user login"
102
115
 
@@ -114,6 +127,7 @@ else
114
127
  usermod -l "$dotpi_user" "$FIRSTUSER"
115
128
  usermod -m -d "/home/${dotpi_user}" "$dotpi_user"
116
129
  groupmod -n "$dotpi_user" "$FIRSTUSER"
130
+
117
131
  if grep -q "^autologin-user=" /etc/lightdm/lightdm.conf ; then
118
132
  sed /etc/lightdm/lightdm.conf -i -e "s/^autologin-user=.*/autologin-user=PI-USER/"
119
133
  fi
@@ -126,7 +140,18 @@ else
126
140
  fi
127
141
  fi
128
142
 
129
- ####### wifi
143
+ # From Raspberry Pi OS version 6.2, `sudo` without password is disabled by default
144
+ # cf. https://www.raspberrypi.com/news/a-security-update-for-raspberry-pi-os/
145
+ dotpi echo_info "Enable sudo without password for ${dotpi_user}"
146
+ # add dotpi user to sudoers
147
+ sudoers_directory='/etc/sudoers.d'
148
+ sudoers_file='zzz_dotpi_nopasswd'
149
+ mkdir -p -- "$sudoers_directory"
150
+ echo "${dotpi_user} ALL=(ALL) NOPASSWD: ALL" > "${sudoers_directory}/${sudoers_file}"
151
+
152
+ #############################################################################
153
+ ####### WIFI
154
+ #############################################################################
130
155
 
131
156
  dotpi echo_info "Configure wifi"
132
157
 
@@ -154,7 +179,9 @@ fi
154
179
  nmcli radio wifi on
155
180
  rfkill unblock wifi
156
181
 
157
- ####### limits (real-time audio)
182
+ #############################################################################
183
+ ####### LIMITS (real-time audio)
184
+ #############################################################################
158
185
 
159
186
  dotpi echo_info "Configure limits"
160
187
 
@@ -165,7 +192,9 @@ if [ -r "$source_path" ] ; then
165
192
  tar c -C "$source_path" '.' | tar x -C "$destination_path"
166
193
  fi
167
194
 
168
- ###### keymap and timezone
195
+ #############################################################################
196
+ ###### Keymap and timezone
197
+ #############################################################################
169
198
 
170
199
  dotpi echo_info "Configure keymap and timezone"
171
200
 
@@ -0,0 +1,28 @@
1
+ Copyright (c) 2023-present IRCAM – Centre Pompidou (France, Paris)
2
+
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without modification,
6
+ are permitted provided that the following conditions are met:
7
+
8
+ * Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ * Redistributions in binary form must reproduce the above copyright notice, this
12
+ list of conditions and the following disclaimer in the documentation and/or
13
+ other materials provided with the distribution.
14
+
15
+ * Neither the name of the IRCAM nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotpi/module",
3
- "version": "1.10.1",
3
+ "version": "1.11.0",
4
4
  "description": "dotpi module management",
5
5
  "type": "module",
6
6
  "exports": {
@@ -10,6 +10,8 @@
10
10
  "dependencies": {
11
11
  "@dotpi/javascript": "^1.6.3",
12
12
  "execa": "^9.5.2",
13
- "globby": "^14.0.2"
14
- }
13
+ "globby": "^14.0.2",
14
+ "pnpm": "^12.18.0"
15
+ },
16
+ "gitHead": "5e9245f39f6461239a7082bd749229a598474c92"
15
17
  }
@@ -0,0 +1,28 @@
1
+ Copyright (c) 2023-present IRCAM – Centre Pompidou (France, Paris)
2
+
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without modification,
6
+ are permitted provided that the following conditions are met:
7
+
8
+ * Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ * Redistributions in binary form must reproduce the above copyright notice, this
12
+ list of conditions and the following disclaimer in the documentation and/or
13
+ other materials provided with the distribution.
14
+
15
+ * Neither the name of the IRCAM nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotpi/module-module",
3
- "version": "1.10.1",
3
+ "version": "1.11.0",
4
4
  "description": "dotpi module management",
5
5
  "type": "module",
6
6
  "bin": "./bin/dotpi_module",
@@ -11,7 +11,8 @@
11
11
  "license": "BSD-3-clause",
12
12
  "dependencies": {
13
13
  "@dotpi/javascript": "^1.6.3",
14
- "@dotpi/module": "^1.10.1",
14
+ "@dotpi/module": "^1.11.0",
15
15
  "commander": "^12.1.0"
16
- }
16
+ },
17
+ "gitHead": "5e9245f39f6461239a7082bd749229a598474c92"
17
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotpi/tools",
3
- "version": "2.11.5",
3
+ "version": "2.12.0",
4
4
  "description": "Set of scripts for managing dotpi fleets of Raspberry Pi",
5
5
  "author": "Jean-Philippe Lambert",
6
6
  "contributors": [
@@ -32,12 +32,12 @@
32
32
  "./dotpi_root/**/*"
33
33
  ],
34
34
  "scripts": {
35
- "test": "node --test"
35
+ "test": "node --test test/*.spec.js"
36
36
  },
37
37
  "license": "BSD-3-Clause",
38
38
  "dependencies": {
39
39
  "@dotpi/javascript": "^1.6.3",
40
- "@dotpi/module": "^1.10.1",
40
+ "@dotpi/module": "^1.11.0",
41
41
  "chalk": "^5.3.0",
42
42
  "commander": "^12.1.0",
43
43
  "prompts": "^2.4.2",
@@ -46,5 +46,5 @@
46
46
  "devDependencies": {
47
47
  "lerna": "^8.2.4"
48
48
  },
49
- "gitHead": "6861c092464092495b95248b677943961eec5ebc"
49
+ "gitHead": "5e9245f39f6461239a7082bd749229a598474c92"
50
50
  }
@@ -101,7 +101,23 @@ You will be able to find all the relevant files in: ${formatPath(projectSshPath)
101
101
  const distPrivateKey = path.join(targetSshPath, path.basename(srcPrivateKey));
102
102
  const distPublicKey = path.join(targetSshPath, path.basename(srcPublicKey));
103
103
 
104
- if (!fs.existsSync(distPrivateKey) && !fs.existsSync(distPublicKey)) {
104
+ let installKeys = true;
105
+
106
+ // if keys already exists, let the user decide if they should be overridden ot not
107
+ if (fs.existsSync(distPrivateKey) || fs.existsSync(distPublicKey)) {
108
+ const answers = await prompts([
109
+ {
110
+ type: 'confirm',
111
+ name: 'installKeys',
112
+ message: `Existing SSH keys "${srcPrivateKey}" found, override?`,
113
+ initial: true
114
+ }
115
+ ], { onCancel });
116
+
117
+ installKeys = answers.installKeys;
118
+ }
119
+
120
+ if (installKeys) {
105
121
  // copy ssh keys
106
122
  console.log(chalk.grey(`> Copy private key "${path.basename(srcPrivateKey)}" into "${formatPath(targetSshPath)}" with 600 permissions`));
107
123
  fs.copyFileSync(srcPrivateKey, distPrivateKey);
@@ -112,7 +128,7 @@ You will be able to find all the relevant files in: ${formatPath(projectSshPath)
112
128
  fs.copyFileSync(srcPublicKey, distPublicKey);
113
129
  fs.chmodSync(distPublicKey, 0o644);
114
130
  } else {
115
- console.log(chalk.grey(`> SSH keys with same name found in "${formatPath(targetSshPath)}", skip...`));
131
+ console.log(chalk.grey(`> SSH keys not installed`));
116
132
  }
117
133
 
118
134