Skip to content

Commit

Permalink
Move automatic configuration into separate documentation (#497)
Browse files Browse the repository at this point in the history
* Move automatic configuration into separate documentation
* Small changes
  • Loading branch information
igorpecovnik authored Oct 22, 2024
1 parent 971eab1 commit c11dffc
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 48 deletions.
100 changes: 100 additions & 0 deletions docs/User-Guide_Autoconfig.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Automatic first boot configuration

## Reading presets from local config

It is possible to configure your device automatically at first boot. Settings like: root password, IP address, connecting to wireless.

After flashing an image to boot media, mount it and add a file containing your config to /root/.not_logged_in_yet

???+ info

This file will be read at your first login and configure system automatically.

Config example for reference:

```bash
# Set PRESET_NET_CHANGE_DEFAULTS to 1 to apply any network related
# settings below
PRESET_NET_CHANGE_DEFAULTS="1"

# Enable WiFi or Ethernet. # If both are enabled, WiFi will take priority
# and Ethernet will be disabled.
PRESET_NET_ETHERNET_ENABLED="1"
PRESET_NET_WIFI_ENABLED="1"

# Enter your WiFi credentials
# SECURITY WARN: Your wifi keys will be stored in plaintext, no encryption.
PRESET_NET_WIFI_SSID="MySSID"
PRESET_NET_WIFI_KEY="MyWiFiKEY"

# Country code to enable power ratings and channels for your country.
# eg: GB US DE | https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
PRESET_NET_WIFI_COUNTRYCODE="GB"

#If you want to use a static ip, set it here
PRESET_NET_USE_STATIC="1"
PRESET_NET_STATIC_IP="192.168.0.100"
PRESET_NET_STATIC_MASK="255.255.255.0"
PRESET_NET_STATIC_GATEWAY="192.168.0.1"
PRESET_NET_STATIC_DNS="8.8.8.8 8.8.4.4"

# Preset user default shell, you can choose bash or zsh
PRESET_USER_SHELL="bash"

# Set PRESET_CONNECT_WIRELESS=y if you want to connect wifi manually
# at first login
PRESET_CONNECT_WIRELESS="n"

# Set SET_LANG_BASED_ON_LOCATION=n if you want to choose
# "Set user language based on your location?" with "n" at first login
SET_LANG_BASED_ON_LOCATION="y"

# Preset default locale
PRESET_LOCALE="en_US.UTF-8"

# Preset timezone
PRESET_TIMEZONE="Etc/UTC"

# Preset root password
PRESET_ROOT_PASSWORD="RootPassword"

# Preset URL for root SSH key
# Use GitHub stored keys: https://github.com/<username>.keys
PRESET_ROOT_KEY=""

# Preset username
PRESET_USER_NAME="armbian"

# Preset user password
PRESET_USER_PASSWORD="UserPassword"

# Preset URL for user SSH key
# Use GitHub stored keys: https://github.com/<username>.keys
PRESET_USER_KEY=""

# Preset user default realname
PRESET_DEFAULT_REALNAME="Armbian user"

```

## Reading presets from a remote config

You can use the same config file for more images. In this case you create file that is accessible via HTTP with the same content and place only URL to this config

```bash
/root/.not_logged_in_yet
```

```
PRESET_CONFIGURATION="http://URL_OF_THIS_CONFIG"
```

???+ tip

If you want to use first run automatic configuration at build time, [check this GitHub pull request](https://github.com/armbian/build/pull/6194).

tl;dr;

1. Copy the template with `cp extensions/preset-firstrun.sh userpatches/extensions/`
2. Edit the template `userpatches/extensions/preset-firstrun.sh` according to your situation
3. Build your Armbian image using the additional parameter `ENABLE_EXTENSIONS=preset-firstrun`
49 changes: 1 addition & 48 deletions docs/User-Guide_Networking.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,51 +192,4 @@ nmtui-connect SSID
??? note "Display screenshot"
![](images/wifi-connect.png)

Replace `SSID` with the name of your wireless network.

# Automatic configuration

It is possible to network configurations which are automatically applied when you first boot your device after flashing a fresh image by writing to the file `/root/.not_logged_in_yet` which is read at your first login.

Mount your live image _before your first boot_ and use this example for reference:

# Set PRESET_NET_CHANGE_DEFAULTS to 1 to apply any network related settings below.

PRESET_NET_CHANGE_DEFAULTS="1"

# Enable WiFi or Ethernet.
# NB: If both are enabled, WiFi will take priority and Ethernet will be disabled.

PRESET_NET_ETHERNET_ENABLED=1
PRESET_NET_WIFI_ENABLED=1

# Enter your WiFi credentials
# SECURITY WARNING: Your wifi keys will be stored in plaintext, no encryption.

PRESET_NET_WIFI_SSID='MySSID'
PRESET_NET_WIFI_KEY='MyWiFiKEY'

# Country code to properly adjust the WiFi for your country.

# E.g. 'GB', 'US' or 'DE' (see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
PRESET_NET_WIFI_COUNTRYCODE='GB'

# If you want to use a static IP, you may set it here

PRESET_NET_USE_STATIC=1
PRESET_NET_STATIC_IP='192.168.0.100'
PRESET_NET_STATIC_MASK='255.255.255.0'
PRESET_NET_STATIC_GATEWAY='192.168.0.1'
PRESET_NET_STATIC_DNS='9.9.9.9 1.1.1.1'

If you want to use first run automatic configuration at build time, [check this GitHub pull request](https://github.com/armbian/build/pull/6194).

In short:

1. Copy the template with `cp extensions/preset-firstrun.sh userpatches/extensions/`
2. Edit the template `userpatches/extensions/preset-firstrun.sh` according to your situation
3. Build your Armbian image using the additional parameter `ENABLE_EXTENSIONS=preset-firstrun`

???+ tip

This method also creates a new user, sets passwords and more!
Replace `SSID` with the name of your wireless network.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ nav:
- 'Basic Troubleshooting' : 'User-Guide_Basic-Troubleshooting.md'
- 'Recovery' : 'User-Guide_Recovery.md'
- 'Advanced Features' : 'User-Guide_Advanced-Features.md'
- 'Firstboot config': 'User-Guide_Autoconfig.md'
- 'Device tree overlays' : 'User-Guide_Armbian_overlays.md'
- 'FAQ' : 'User-Guide_FAQ.md'
- 'Release Model' : 'Process_Release-Model.md'
Expand Down

0 comments on commit c11dffc

Please sign in to comment.