hypriot / flash

Command line script to flash SD card images of any kind
MIT License
1k stars 176 forks source link

User scripts not firing #134

Closed Jacobh2 closed 5 years ago

Jacobh2 commented 6 years ago

According to the cloud init documentation it should be possible to run user scripts, however, I am unable to make this work.

The documentation says

User scripts are not specified in the scripts directory in the datasource,
but rather are present in the scripts dir in the instance configuration

So I've added the following:

write_files:
  - path: /var/lib/cloud/instance/scripts/test.sh
    content: |
      #! /bin/sh
      touch /tmp/hi.txt
      echo "cool stuff!" > /tmp/derpatron.txt

in order to see if it actually fires. But after flashing the sdcard, I can see that the file has been written correctly:

$ ls /var/lib/cloud/instance/scripts/
runcmd  test.sh

but it hasn't been fired, since I don't have any data in tmp that corresponds to my files:

$ ls /tmp

What I noticed was that the 'instance' directory was named pirate001, but my user is set to client:

$ ls -lhsa /var/lib/cloud
total 32K
4.0K drwxr-xr-x  8 root root 4.0K Apr 28 20:57 .
4.0K drwxr-xr-x 26 root root 4.0K Apr 28 20:57 ..
4.0K drwxr-xr-x  2 root root 4.0K Apr 28 20:57 data
4.0K drwxr-xr-x  2 root root 4.0K Apr 28 20:56 handlers
   0 lrwxrwxrwx  1 root root   34 Apr 28 20:57 instance -> /var/lib/cloud/instances/pirate001
4.0K drwxr-xr-x  3 root root 4.0K Apr 28 20:57 instances
4.0K drwxr-xr-x  6 root root 4.0K Apr 28 20:56 scripts
4.0K drwxr-xr-x  3 root root 4.0K Apr 28 20:59 seed
4.0K drwxr-xr-x  2 root root 4.0K Apr 28 20:57 sem
StefanScherer commented 5 years ago

Don't know how to help. It's not really a flash error, maybe how cloud-init is symlinked into the image-builder-rpi repo or how that old version of cloud-init works.

Closing for now.