GithubHelp home page GithubHelp logo

hypriot / device-init Goto Github PK

View Code? Open in Web Editor NEW
70.0 70.0 17.0 2.3 MB

Initialize a device on boot with user defined configuration

License: MIT License

Makefile 2.66% Go 60.43% Shell 4.48% Ruby 32.43%

device-init's Introduction

rpi-golang

Docker image containing GOLANG that is compatible to the Raspberry Pi.

Build the Docker Image

make build

Run the Docker Image and get version of installed GOLANG

make version

Push Docker Image to Docker Hub

  • First, use a docker login with username, password and email address
  • Second, push Docker Image to the official Docker Hub
make push

device-init's People

Contributors

cheld avatar govinda-fichtner avatar mathiasrenner avatar moncho avatar stefanscherer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

device-init's Issues

Setting hostname on boot doesn't affect avahi

I have added a /boot/device-init.yaml file on a running RPi2 with

hostname: "new"

Then I rebooted with sudo reboot.

After rebooting I couldn't ssh into the renamed machine with ssh [email protected], but still with ssh [email protected].

Investigating the /var/log/syslog after the reboot with sudo grep 'avahi\|device-init' /var/log/syslog shows that the device-init rename is too late:

Feb 11 18:21:59 black-pearl avahi-daemon[195]: Found user 'avahi' (UID 105) and group 'avahi' (GID 111).
Feb 11 18:21:59 black-pearl avahi-daemon[195]: Successfully dropped root privileges.
Feb 11 18:21:59 black-pearl avahi-daemon[195]: avahi-daemon 0.6.31 starting up.
Feb 11 18:21:59 black-pearl avahi-daemon[195]: WARNING: No NSS support for mDNS detected, consider installing nss-mdns!
Feb 11 18:21:59 black-pearl avahi-daemon[195]: Successfully called chroot().
Feb 11 18:21:59 black-pearl avahi-daemon[195]: Successfully dropped remaining capabilities.
Feb 11 18:21:59 black-pearl avahi-daemon[204]: chroot.c: open() failed: No such file or directory
Feb 11 18:21:59 black-pearl avahi-daemon[195]: Failed to open /etc/resolv.conf: Invalid argument
Feb 11 18:21:59 black-pearl avahi-daemon[195]: No service file found in /etc/avahi/services.
Feb 11 18:21:59 black-pearl avahi-daemon[195]: Network interface enumeration completed.
Feb 11 18:21:59 black-pearl avahi-daemon[195]: Registering HINFO record with values 'ARMV7L'/'LINUX'.
Feb 11 18:21:59 black-pearl avahi-daemon[195]: Server startup complete. Host name is black-pearl.local. Local service cookie is 1581608388.
Feb 11 18:21:59 black-pearl systemd[1]: Starting device-init...
Feb 11 18:22:00 black-pearl device-init[224]: Using config file: /boot/device-init.yaml
Feb 11 18:22:00 black-pearl device-init[224]: Set hostname: new
Feb 11 18:22:00 black-pearl systemd[1]: Started device-init.
Feb 11 18:22:00 black-pearl avahi-daemon[195]: Joining mDNS multicast group on interface eth0.IPv4 with address 192.168.1.203.
Feb 11 18:22:00 black-pearl avahi-daemon[195]: New relevant interface eth0.IPv4 for mDNS.
Feb 11 18:22:00 black-pearl avahi-daemon[195]: Registering new address record for 192.168.1.203 on eth0.IPv4.
Feb 11 18:22:02 black-pearl avahi-daemon[195]: Joining mDNS multicast group on interface eth0.IPv6 with address fe80::ba27:ebff:feed:7480.
Feb 11 18:22:02 black-pearl avahi-daemon[195]: New relevant interface eth0.IPv6 for mDNS.
Feb 11 18:22:02 black-pearl avahi-daemon[195]: Registering new address record for fe80::ba27:ebff:feed:7480 on eth0.*.
Feb 11 18:22:02 black-pearl avahi-daemon[195]: Joining mDNS multicast group on interface docker0.IPv4 with address 172.17.0.1.
Feb 11 18:22:02 black-pearl avahi-daemon[195]: New relevant interface docker0.IPv4 for mDNS.
Feb 11 18:22:02 black-pearl avahi-daemon[195]: Registering new address record for 172.17.0.1 on docker0.IPv4.

So we have to change service dependencies to change boot order.

Insert SSH pub keys

It would be super convenient for the flash script that it can add SSH pub keys while flashing that are inserted in the user's ~/.ssh/authorized_keys file.

Only a rough idea how that could look like in the device-init.yml file:

ssh:
  authorized_keys:
    root:
      - "sha-rsa AAA...NN"
    pirate:
      - "sha-rsa AAA...NN"

Error with hostname set servername

There is a problem with device-init

sudo device-init hostname set server1
sudo: unable to resolve host server1
panic: runtime error: index out of range

goroutine 1 [running]:
github.com/hypriot/device-init/cmd.activeInterfaces(0x0, 0x0, 0x0)
        /opt/gopath/src/github.com/hypriot/device-init/cmd/hostname_set.go:123 +0x31c
github.com/hypriot/device-init/cmd.setHostname(0x108abdfc, 0x1, 0x1)
        /opt/gopath/src/github.com/hypriot/device-init/cmd/hostname_set.go:86 +0x50c
github.com/hypriot/device-init/cmd.glob.func5(0x670c30, 0x108605c0, 0x1, 0x1)
        /opt/gopath/src/github.com/hypriot/device-init/cmd/hostname_set.go:39 +0xa4
github.com/spf13/cobra.(*Command).execute(0x670c30, 0x10860578, 0x1, 0x1, 0x0, 0x0)
        /opt/gopath/src/github.com/hypriot/device-init/Godeps/_workspace/src/github.com/spf13/cobra/command.go:569 +0x664
github.com/spf13/cobra.(*Command).ExecuteC(0x670d28, 0x670c30, 0x0, 0x0)
        /opt/gopath/src/github.com/hypriot/device-init/Godeps/_workspace/src/github.com/spf13/cobra/command.go:656 +0x440
github.com/spf13/cobra.(*Command).Execute(0x670d28, 0x0, 0x0)
        /opt/gopath/src/github.com/hypriot/device-init/Godeps/_workspace/src/github.com/spf13/cobra/command.go:615 +0x28
github.com/hypriot/device-init/cmd.Execute()
        /opt/gopath/src/github.com/hypriot/device-init/cmd/root.go:53 +0x20
main.main()
        /opt/gopath/src/github.com/hypriot/device-init/main.go:28 +0x14

hostname does not affect dhclient

I think device-init is running too late in the boot process.
After configuring the network stack and after starting avahi-daemon.service.

connects to #4

Refactor device-init to not use sub-commands any more

It turns out that device-inits main use case is to do stuff automatically at boot of a device.

Having commands that also allow to show the current individual settings make sense (if at all) just for a limited set of settings. Thus it would be consequent to just get rid of all of them.

Let's have only one command that sets different things at boot.
This gives device-init more focus and simplifies its architecture.

Question: tips on how to install docker image with debootstrap?

Hi folks,
similar to image-builder-rpi I use debootstrap to build debian images and as you may know, it isn't possible to pre-load a docker image with it.
I believe that is the reason you added the "docker" section to device-init.

Unfortunately, my image is too large and device-init takes too long to load, which kills the user's first time experience.
So, have you guys explored other alternatives? Any clues would be helpful...

I was wondering if it is possible to do a docker pull on a ARM server, zip the file system under the containers and export to the device itself.

Thanks in advance

Integrate BerryLan for easy WiFi activation

It is common for users to connect their Raspberry on a local WiFi. Currently its a relatively involved process.
The BerryLan project makes that much simpler for newbies.

Especially useful for projects that distribute RPI based images to end users who aren't very tech savvy. Ambianic is an example for such projects.

Would be helpful if hypriot solves two major problems simultaneously:

  1. Simplify distribution for developers shipping rpi docker packages. Done! Great work!
  2. Simplify install and setup for end users, by enabling quick wifi connectivity for new installs.

device-init shows usage in /var/log/syslog

After installing device-init DEB package 0.0.14 I see the usage in /var/log/syslog:
I don't have a /boot/device-init.yaml yet.

daemon.log:Jul  3 18:46:23 black-pearl systemd[1]: Starting device-init...
daemon.log:Jul  3 18:46:23 black-pearl device-init[238]: device-init allows you to configure various aspect of your devices.
daemon.log:Jul  3 18:46:23 black-pearl device-init[238]: This ranges from configuration as simple as setting a hostname to
daemon.log:Jul  3 18:46:23 black-pearl device-init[238]: more complex stuff as configuring WiFi access.
daemon.log:Jul  3 18:46:23 black-pearl device-init[238]: Usage:
daemon.log:Jul  3 18:46:23 black-pearl device-init[238]: device-init [flags]
daemon.log:Jul  3 18:46:23 black-pearl device-init[238]: device-init [command]
daemon.log:Jul  3 18:46:23 black-pearl device-init[238]: Available Commands:
daemon.log:Jul  3 18:46:23 black-pearl device-init[238]: hostname    Set or show hostname
daemon.log:Jul  3 18:46:23 black-pearl device-init[238]: Flags:
daemon.log:Jul  3 18:46:23 black-pearl device-init[238]: --config string   config file (default is /boot/device-init.yaml)
daemon.log:Jul  3 18:46:23 black-pearl device-init[238]: -h, --help            help for device-init
daemon.log:Jul  3 18:46:23 black-pearl device-init[238]: Use "device-init [command] --help" for more information about a command.
daemon.log:Jul  3 18:46:23 black-pearl systemd[1]: Started device-init.

Support multiple wifi alternatives

I don't know how this would be done, but here's the situation:

I have a device that I'm moving from place to place and I'd like the wifi setup to be as easy as possible.

Is it possible to support more than one wifi SSID and password in the device-init system? The examples provided only show a single setup.

Allow wifi connection to include optional identity

Would like to provide an identity when connecting to 802.1X network which requires authentication using a username.
Could be achieved possibly using wpa_supplicant -

hostname: black-pearl
wifi:
  interfaces:
    wlan0:
      ssid: "MyNetwork"
      scan-ssid: 1
      identity: "username"
      password: "secret_password"

Non functional Docker build

Currently the make build command produces an error, because the last version of pry-byebug requires ruby >= 2.2.0, and the default release with Debian Jessie is 2.1, so the build produces an error when trying to install the gem.

Static ip

Reopen of issue from flash-repo: Issue 25

Option for setting a static ip for eth0 would be a great addition. Thanks!

Run device-init in different phases of the boot process

Some of the actions that device-init have to happen in different phases of the boot-process.

For instance setting the hostname should happen as early as possible.
Others actions like for instance loading Docker images from the filesystem have to happen late in the boot process when Docker is already running.

Thus being able to configure different phase of the boot process when actions are run seems to make sense.

Remove show commands

As device-init's mission is to configure/set up a device at boot up the show commands are somewhat out of scope. On top of that a show command is only applicable for some areas of device-init.

Thus it makes sense to remove them completely and only focus on setting up device configuration.

Add hidden SSID support

Linking issue hypriot/flash#74 from @mrgnou:

Actually, the generated wifi configuration doesn't provide hidden ssid support.
It would be nice to manage hidden wifi networks by adding an optional param scan-ssid to device-init.yaml such as:

hostname: black-pearl
wifi:
  interfaces:
    wlan0:
      ssid: "MyNetwork"
      scan-ssid: 1
      password: "secret_password"

This way, generated wlan0 file would look like

allow-hotplug wlan0

auto wlan0
iface wlan0 inet dhcp
  wpa-ssid MyNetwork
  wpa-scan-ssid 1
  wpa-psk generated_psk

Add --version

Retrieve the version of the binary with device-init --version.

(feat) device-init.yaml schema documentation

As an DevOps engineer
I would like to verify my device-init with a yaml schema file via a tool like yamale
So that I can generate a few different configurations with cookiecutter
And so that I can pass these device configurations to flash as a CICD build asset

Estimated size of DEB package too big

It seems that the estimated size of some of our DEB packages are wrong: These few docker tools and device-init need 16.6 GB? ๐Ÿ˜ธ

+ apt-get install -y docker-hypriot=1.10.0-1 docker-compose=1.6.0-27 docker-machine=0.4.1-72 device-init=0.0.14
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  busybox cgroupfs-mount initramfs-tools klibc-utils libdrm2 libklibc
  libnih-dbus1 libnih1 libpng12-0 makedev mountall plymouth xz-utils
Suggested packages:
  desktop-base plymouth-themes
The following NEW packages will be installed:
  busybox cgroupfs-mount device-init docker-compose docker-hypriot
  docker-machine initramfs-tools klibc-utils libdrm2 libklibc libnih-dbus1
  libnih1 libpng12-0 makedev mountall plymouth xz-utils
0 upgraded, 17 newly installed, 0 to remove and 4 not upgraded.
Need to get 18.8 MB of archives.
After this operation, 16.6 GB of additional disk space will be used.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.