Skip to content

Commit 4d69183

Browse files
committed
docs: improve "Getting Started"
* also works on the 64-bit Raspberry OS * state importance of the pathces in no uncertain terms * rephrase assumptions in a more concise way * extract small essay about sudo into its own "What is sudo?"-page * move "updating from gcgarner"-link to the Home page
1 parent 3f9bcea commit 4d69183

File tree

3 files changed

+62
-73
lines changed

3 files changed

+62
-73
lines changed

docs/Basic_setup/What-is-sudo.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# What is sudo?
2+
3+
Many first-time users of IOTstack get into difficulty by misusing the `sudo` command. The problem is best understood by example. In the following, you would expect `~` (tilde) to expand to `/home/pi`. It does:
4+
5+
```bash
6+
$ echo ~/IOTstack
7+
/home/pi/IOTstack
8+
```
9+
10+
The command below sends the same `echo` command to `bash` for execution. This is what happens when you type the name of a shell script. You get a new instance of `bash` to run the script:
11+
12+
```bash
13+
$ bash -c 'echo ~/IOTstack'
14+
/home/pi/IOTstack
15+
```
16+
17+
Same answer. Again, this is what you expect. But now try it with `sudo` on the front:
18+
19+
```bash
20+
$ sudo bash -c 'echo ~/IOTstack'
21+
/root/IOTstack
22+
```
23+
24+
Different answer. It is different because `sudo` means "become root, and then run the command". The process of becoming root changes the home directory, and that changes the definition of `~`.
25+
26+
Any script designed for working with IOTstack assumes `~` (or the equivalent `$HOME` variable) expands to `/home/pi`. That assumption is invalidated if the script is run by `sudo`.
27+
28+
Of necessity, any script designed for working with IOTstack will have to invoke `sudo` **inside** the script **when it is required**. You do not need to second-guess the script's designer.
29+
30+
Please try to minimise your use of `sudo` when you are working with IOTstack. Here are some rules of thumb:
31+
32+
1. Is what you are about to run a script? If yes, check whether the script already contains `sudo` commands. Using `menu.sh` as the example:
33+
34+
```bash
35+
$ grep -c 'sudo' ~/IOTstack/menu.sh
36+
28
37+
```
38+
39+
There are numerous uses of `sudo` within `menu.sh`. That means the designer thought about when `sudo` was needed.
40+
41+
2. Did the command you **just executed** work without `sudo`? Note the emphasis on the past tense. If yes, then your work is done. If no, and the error suggests elevated privileges are necessary, then re-execute the last command like this:
42+
43+
```bash
44+
$ sudo !!
45+
```
46+
47+
It takes time, patience and practice to learn when `sudo` is **actually** needed. Over-using `sudo` out of habit, or because you were following a bad example you found on the web, is a very good way to find that you have created so many problems for yourself that will need to reinstall your IOTstack. *Please* err on the side of caution!

docs/Basic_setup/index.md

Lines changed: 14 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,25 @@ Andreas Spiess Video #352: Raspberry Pi4 Home Automation Server (incl. Docker, O
1010

1111
[![#352 Raspberry Pi4 Home Automation Server (incl. Docker, OpenHAB, HASSIO, NextCloud)](http://img.youtube.com/vi/KJRMjUzlHI8/0.jpg)](https://www.youtube.com/watch?v=KJRMjUzlHI8)
1212

13-
## assumptions
13+
## Assumptions
1414

1515
IOTstack makes the following assumptions:
1616

1717
1. Your hardware is a Raspberry Pi (typically a 3B+ or 4B).
1818

19-
Note:
20-
2119
* The Raspberry Pi Zero W2 has been tested with IOTstack. It works but the 512MB RAM means you should not try to run too many containers concurrently.
20+
* Users have also [reported success
21+
](https://github.com/SensorsIot/IOTstack/issues/375) on Orange Pi
22+
Win/Plus.
2223

23-
2. Your Raspberry Pi has a reasonably-recent version of 32-bit Raspberry Pi OS (aka "Raspbian") installed. You can download operating-system images:
24+
2. Your Raspberry Pi has a reasonably-recent version of 32-bit or 64-bit Raspberry Pi OS (aka "Raspbian") installed. You can download operating-system images:
2425

2526
* [Current release](https://www.raspberrypi.com/software/operating-systems/)
27+
: "Raspberry Pi OS with desktop" is recommended.
2628
* [Prior releases](http://downloads.raspberrypi.org/raspios_armhf/images/)
29+
: This offers only "Raspberry Pi OS with desktop" images.
2730

28-
Note:
29-
30-
* If you use the first link, "Raspberry Pi OS with desktop" is recommended.
31-
* The second link only offers "Raspberry Pi OS with desktop" images.
32-
33-
3. Your operating system has been kept up-to-date with:
31+
3. Your operating system has been updated:
3432

3533
```bash
3634
$ sudo apt update
@@ -46,13 +44,7 @@ If the first three assumptions hold, assumptions four through six are Raspberry
4644

4745
Please don't read these assumptions as saying that IOTstack will not run on other hardware, other operating systems, or as a different user. It is just that IOTstack gets most of its testing under these conditions. The further you get from these implicit assumptions, the more your mileage may vary.
4846

49-
### other platforms
50-
51-
Users have reported success on other platforms, including:
52-
53-
* [Orange Pi WinPlus](https://github.com/SensorsIot/IOTstack/issues/375)
54-
55-
## new installation
47+
## New installation
5648

5749
### automatic (recommended)
5850

@@ -128,13 +120,9 @@ If you prefer to automate your installations using scripts, see:
128120

129121
* [Installing Docker for IOTstack](https://gist.github.com/Paraphraser/d119ae81f9e60a94e1209986d8c9e42f#scripting-iotstack-installations).
130122

131-
## migrating from the old repo (gcgarner)?
132-
133-
If you are still running on gcgarner/IOTstack and need to migrate to SensorsIot/IOTstack, see:
123+
## Required system patches
134124

135-
* [Migrating IOTstack from gcgarner to SensorsIot](../Updates/gcgarner-migration.md).
136-
137-
## recommended system patches
125+
Unless you know what you are doing, assume these are needed.
138126

139127
### patch 1 – restrict DHCP
140128

@@ -162,9 +150,9 @@ PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
162150

163151
If you see the word "buster", proceed to step 2. Otherwise, skip this patch.
164152

165-
#### step 2: if you are running "buster"
153+
#### step 2: if you are indeed running "buster"
166154

167-
You need this patch if you are running Raspbian Buster. Without this patch, Docker images will fail if:
155+
Without this patch on Buster, Docker images will fail if:
168156

169157
* the image is based on Alpine and the image's maintainer updates to [Alpine 3.13](https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.13.0#time64_requirement); and/or
170158
* an image's maintainer updates to a library that depends on 64-bit values for *Unix epoch time* (the so-called Y2038 problem).
@@ -189,53 +177,6 @@ Enable by running (takes effect after reboot):
189177
echo $(cat /boot/cmdline.txt) cgroup_memory=1 cgroup_enable=memory | sudo tee /boot/cmdline.txt
190178
```
191179

192-
## a word about the `sudo` command
193-
194-
Many first-time users of IOTstack get into difficulty by misusing the `sudo` command. The problem is best understood by example. In the following, you would expect `~` (tilde) to expand to `/home/pi`. It does:
195-
196-
```bash
197-
$ echo ~/IOTstack
198-
/home/pi/IOTstack
199-
```
200-
201-
The command below sends the same `echo` command to `bash` for execution. This is what happens when you type the name of a shell script. You get a new instance of `bash` to run the script:
202-
203-
```bash
204-
$ bash -c 'echo ~/IOTstack'
205-
/home/pi/IOTstack
206-
```
207-
208-
Same answer. Again, this is what you expect. But now try it with `sudo` on the front:
209-
210-
```bash
211-
$ sudo bash -c 'echo ~/IOTstack'
212-
/root/IOTstack
213-
```
214-
215-
Different answer. It is different because `sudo` means "become root, and then run the command". The process of becoming root changes the home directory, and that changes the definition of `~`.
216-
217-
Any script designed for working with IOTstack assumes `~` (or the equivalent `$HOME` variable) expands to `/home/pi`. That assumption is invalidated if the script is run by `sudo`.
218-
219-
Of necessity, any script designed for working with IOTstack will have to invoke `sudo` **inside** the script **when it is required**. You do not need to second-guess the script's designer.
220-
221-
Please try to minimise your use of `sudo` when you are working with IOTstack. Here are some rules of thumb:
222-
223-
1. Is what you are about to run a script? If yes, check whether the script already contains `sudo` commands. Using `menu.sh` as the example:
224-
225-
```bash
226-
$ grep -c 'sudo' ~/IOTstack/menu.sh
227-
28
228-
```
229-
230-
There are numerous uses of `sudo` within `menu.sh`. That means the designer thought about when `sudo` was needed.
231-
232-
2. Did the command you **just executed** work without `sudo`? Note the emphasis on the past tense. If yes, then your work is done. If no, and the error suggests elevated privileges are necessary, then re-execute the last command like this:
233-
234-
```bash
235-
$ sudo !!
236-
```
237-
238-
It takes time, patience and practice to learn when `sudo` is **actually** needed. Over-using `sudo` out of habit, or because you were following a bad example you found on the web, is a very good way to find that you have created so many problems for yourself that will need to reinstall your IOTstack. *Please* err on the side of caution!
239180

240181
## the IOTstack menu
241182

@@ -343,7 +284,7 @@ $ git checkout master
343284
$ ./menu.sh
344285
```
345286

346-
### <a name="menuOldMenuBranch"> old menu (old-menu branch)</a>
287+
### old menu (old-menu branch)
347288

348289
```bash
349290
$ cd ~/IOTstack/

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Welcome to the IOTstack Wiki:
1919
</label>
2020

2121
* If you are just getting started with IOTstack, see [Getting Started](Basic_setup/).
22+
* If you're running gcgarner/IOTstack see [Migrating to SensorsIot](Updates/gcgarner-migration.md).
2223

2324
* You're always welcome to ask questions on the [IOTStack Discord](https://discord.gg/ZpKHnks).
2425

0 commit comments

Comments
 (0)