diff --git a/build/initialization.sh b/build/initialization.sh index e231b4291..3899d3985 100755 --- a/build/initialization.sh +++ b/build/initialization.sh @@ -58,9 +58,9 @@ ControlPort 9051 CookieAuthentication 1 EOF -passwd -l ubuntu echo 'overlayroot="tmpfs":swap=1,recurse=0' > /etc/overlayroot.local.conf systemctl disable initialization.service sudo systemctl restart NetworkManager sync -reboot + +cloud-init clean --reboot diff --git a/build/user-data b/build/user-data new file mode 100755 index 000000000..2d5018b25 --- /dev/null +++ b/build/user-data @@ -0,0 +1,86 @@ +#cloud-config + +# This is the user-data configuration file for cloud-init. By default this sets +# up an initial user called "ubuntu" with password "ubuntu", which must be +# changed at first login. However, many additional actions can be initiated on +# first boot from this file. The cloud-init documentation has more details: +# +# https://cloudinit.readthedocs.io/ +# +# Please note that the YAML format employed by this file is sensitive to +# differences in whitespace; if you are editing this file in an editor (like +# Notepad) which uses literal tabs, take care to only use spaces for +# indentation. See the following link for more details: +# +# https://en.wikipedia.org/wiki/YAML +# +# Some additional examples are provided in comments below the default +# configuration. + +# On first boot, set the (default) ubuntu user's password to "ubuntu" and +# expire user passwords +#chpasswd: +# expire: true +# list: +# - ubuntu:ubuntu + +# Enable password authentication with the SSH daemon +#ssh_pwauth: true + +## On first boot, use ssh-import-id to give the specific users SSH access to +## the default user +#ssh_import_id: +#- lp:my_launchpad_username +#- gh:my_github_username + +## Add users and groups to the system, and import keys with the ssh-import-id +## utility +#groups: +#- robot: [robot] +#- robotics: [robot] +#- pi +# +#users: +#- default +#- name: robot +# gecos: Mr. Robot +# primary_group: robot +# groups: users +# ssh_import_id: foobar +# lock_passwd: false +# passwd: $5$hkui88$nvZgIle31cNpryjRfO9uArF7DYiBcWEnjqq7L1AQNN3 + +## Update apt database and upgrade packages on first boot +#package_update: true +#package_upgrade: true + +## Install additional packages on first boot +#packages: +#- pwgen +#- pastebinit +#- [libpython2.7, 2.7.3-0ubuntu3.1] + +## Write arbitrary files to the file-system (including binaries!) +#write_files: +#- path: /etc/default/keyboard +# content: | +# # KEYBOARD configuration file +# # Consult the keyboard(5) manual page. +# XKBMODEL="pc105" +# XKBLAYOUT="gb" +# XKBVARIANT="" +# XKBOPTIONS="ctrl: nocaps" +# permissions: '0644' +# owner: root:root +#- encoding: gzip +# path: /usr/bin/hello +# content: !!binary | +# H4sIAIDb/U8C/1NW1E/KzNMvzuBKTc7IV8hIzcnJVyjPL8pJ4QIA6N+MVxsAAAA= +# owner: root:root +# permissions: '0755' + +## Run arbitrary commands at rc.local like time +#runcmd: +#- [ ls, -l, / ] +#- [ sh, -xc, "echo $(date) ': hello world!'" ] +#- [ wget, "http://ubuntu.com", -O, /run/mydir/index.html ] diff --git a/build/user-data-dev b/build/user-data-dev new file mode 100755 index 000000000..828f39ee3 --- /dev/null +++ b/build/user-data-dev @@ -0,0 +1,86 @@ +#cloud-config + +# This is the user-data configuration file for cloud-init. By default this sets +# up an initial user called "ubuntu" with password "ubuntu", which must be +# changed at first login. However, many additional actions can be initiated on +# first boot from this file. The cloud-init documentation has more details: +# +# https://cloudinit.readthedocs.io/ +# +# Please note that the YAML format employed by this file is sensitive to +# differences in whitespace; if you are editing this file in an editor (like +# Notepad) which uses literal tabs, take care to only use spaces for +# indentation. See the following link for more details: +# +# https://en.wikipedia.org/wiki/YAML +# +# Some additional examples are provided in comments below the default +# configuration. + +# On first boot, set the (default) ubuntu user's password to "ubuntu" and +# expire user passwords +chpasswd: + expire: true + list: + - ubuntu:ubuntu + +# Enable password authentication with the SSH daemon +ssh_pwauth: true + +## On first boot, use ssh-import-id to give the specific users SSH access to +## the default user +#ssh_import_id: +#- lp:my_launchpad_username +#- gh:my_github_username + +## Add users and groups to the system, and import keys with the ssh-import-id +## utility +#groups: +#- robot: [robot] +#- robotics: [robot] +#- pi +# +#users: +#- default +#- name: robot +# gecos: Mr. Robot +# primary_group: robot +# groups: users +# ssh_import_id: foobar +# lock_passwd: false +# passwd: $5$hkui88$nvZgIle31cNpryjRfO9uArF7DYiBcWEnjqq7L1AQNN3 + +## Update apt database and upgrade packages on first boot +#package_update: true +#package_upgrade: true + +## Install additional packages on first boot +#packages: +#- pwgen +#- pastebinit +#- [libpython2.7, 2.7.3-0ubuntu3.1] + +## Write arbitrary files to the file-system (including binaries!) +#write_files: +#- path: /etc/default/keyboard +# content: | +# # KEYBOARD configuration file +# # Consult the keyboard(5) manual page. +# XKBMODEL="pc105" +# XKBLAYOUT="gb" +# XKBVARIANT="" +# XKBOPTIONS="ctrl: nocaps" +# permissions: '0644' +# owner: root:root +#- encoding: gzip +# path: /usr/bin/hello +# content: !!binary | +# H4sIAIDb/U8C/1NW1E/KzNMvzuBKTc7IV8hIzcnJVyjPL8pJ4QIA6N+MVxsAAAA= +# owner: root:root +# permissions: '0755' + +## Run arbitrary commands at rc.local like time +#runcmd: +#- [ ls, -l, / ] +#- [ sh, -xc, "echo $(date) ': hello world!'" ] +#- [ wget, "http://ubuntu.com", -O, /run/mydir/index.html ] diff --git a/build/write-image.sh b/build/write-image.sh index bf88f84e1..8f12e1550 100755 --- a/build/write-image.sh +++ b/build/write-image.sh @@ -21,6 +21,12 @@ sudo e2label ${OUTPUT_DEVICE}p4 blue mkdir -p /tmp/eos-mnt sudo mount ${OUTPUT_DEVICE}p1 /tmp/eos-mnt +if [[ "$ENVIRONMENT" =~ (^|-)dev($|-) ]]; then + sudo cp build/user-data-dev /tmp/eos-mnt/user-data +else + sudo cp build/user-data /tmp/eos-mnt/user-data +fi + sudo sed -i 's/LABEL=writable/LABEL=green/g' /tmp/eos-mnt/cmdline.txt # create a copy of the cmdline *without* the quirk string, so that it can be easily amended sudo cp /tmp/eos-mnt/cmdline.txt /tmp/eos-mnt/cmdline.txt.orig @@ -64,12 +70,7 @@ sudo cp -R diagnostic-ui/www /tmp/eos-mnt/var/www/html/diagnostic # Make the .ssh directory sudo mkdir -p /tmp/eos-mnt/root/.ssh -if [[ "$ENVIRONMENT" =~ (^|-)dev($|-) ]]; then - cat ./build/initialization.sh | grep -v "passwd -l ubuntu" | sudo tee /tmp/eos-mnt/usr/local/bin/initialization.sh > /dev/null - sudo chmod +x /tmp/eos-mnt/usr/local/bin/initialization.sh -else - sudo cp ./build/initialization.sh /tmp/eos-mnt/usr/local/bin -fi +sudo cp ./build/initialization.sh /tmp/eos-mnt/usr/local/bin sudo cp ./build/initialization.service /tmp/eos-mnt/etc/systemd/system/initialization.service sudo ln -s /etc/systemd/system/initialization.service /tmp/eos-mnt/etc/systemd/system/multi-user.target.wants/initialization.service