Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open Pipe Kit as an autostart.sh file on a USB Drive #27

Open
rjcorwin opened this issue Apr 23, 2015 · 18 comments
Open

Open Pipe Kit as an autostart.sh file on a USB Drive #27

rjcorwin opened this issue Apr 23, 2015 · 18 comments
Assignees

Comments

@rjcorwin
Copy link
Contributor

We've talked a bit about what a standard directory structure might look like. We've also talked about how we need a way to start pipe commands automatically.

How about something like...

├── autorun.sh
├── drivers
│   ├── phant
│   │   ├── install
│   │   └── push
│   └── temper1
│       ├── install
│       └── pull
├── logs
│   ├── autorun.log
│   ├── pipe1.log
│   ├── pipe2.log
│   └── pipe3.log
└── run
    ├── pipe1.sh
    ├── pipe2.sh
    └── pipe3.sh

autorun.sh in the example above would, on execute, start every script in the run folder and pipe all output to a corresponding log file. This seems pretty neat and tidy to me.

But what if Debian treated autorun.sh like Windows treats autorun.inf? If we did, then we could put the above directory structure on a USB drive and as soon as you plugged it into a Debian system (R-Pi, BBB, etc.) the pipes would just start running!

What if we had a "Pipe Builder" app online that allowed people to graphically create the above structure and download it as a Zip file? Setting up a pipe might look something like...

  1. Go to http://build.openpipekit.org to configure and download your pipes
  2. Unzip download and place on a USB drive
  3. Plug USB drive and sensors into a Beagle Bone Black (has Debian on it already and looking for drives that have autorun.sh on them)
  4. Place your BBB somewhere because it's now collecting data!

With R-Pi it would be an extra step of having to download and burn Raspbian to an SD Card.

... In reality we're going to have to roll our own Debian distro with autorun.sh capability enabled by default so that folks can burn that to an SD Card to have an autorun capable distro running.

@rjcorwin
Copy link
Contributor Author

Here's an example that connects to wifi...

├── autorun.sh
├── drivers
│   ├── phant
│   │   ├── install
│   │   └── push
│   ├── temper1
│   │   ├── install
│   │   └── pull
│   └── wifi
│       ├── connect
│       └── install
├── logs
│   ├── autorun.log
│   ├── pipe1.log
│   ├── pipe2.log
│   ├── pipe3.log
│   └── wifi.log
└── run
    ├── pipe1.sh
    ├── pipe2.sh
    ├── pipe3.sh
    └── wifi.sh

@rjcorwin
Copy link
Contributor Author

  • Create the autorun daemon that checks for connected media and if they have an autorun.sh script, executes them if they do.
  • Publish Raspbian distro that has autorun daemon running.
  • Create autorun.sh that starts everything in the run folder and pipes to corresponding log files.
  • Create an example pipe script like pipe1.sh that runs install on all dependent drivers and then sets up the pipe to run at an interval.
  • Create http://builder.openpipekit.org UI.
  • Create the backend builder that generates the build according to a given configuration.
  • Polish http://hub.openpipekit.org so that it can aid the builder UI and build machine.

Other thoughts...

  • install for drivers should be self aware if they have been installed on a system to save on that load time

Lastly, this is a lot to do. We all need to be thinking MVP here.

@rjcorwin
Copy link
Contributor Author

... Maybe we don't have to "build" the whole thing on our servers. Perhaps just a UI that generates autorun.sh and the UI adds extra build commands to run on first launch given the input from the user. So you user would fill out the forms and in return receive an autorun.sh file that they then put on a USB stick. Then they plug everything into their BBB/Pi, including a direct connection over ethernet so the build can work. Then the build process runs thus building the directory structure above and downloading all the dependencies. What would be great is if while the build was happening, if there was some feedback as to what was going on... How about a USB blink that shows different colors depending on the status?
screen shot 2015-04-23 at 12 07 37 pm

http://blink1.thingm.com/

It's $30 for that thing which seems high given the cost of a Pi is $35. But... To have visual feedback, $30 might be worth it. You wouldn't even necessarily need to keep the blink on the Pi, it could be like the thermometer you stick into a Pi so see the status.

@rjcorwin
Copy link
Contributor Author

@treehouse-su What are your thoughts on the difficulty level of getting autorun to work on Debian?

@rjcorwin
Copy link
Contributor Author

How about an autorunonce.sh that would take precedence over autorun.sh? Here's an example of using autorunonce.sh to download and install drivers, reboot, and then run autorun.sh.

autorunonce.sh

blink red

wget --directory-prefix drivers https://github.com/openpipekit/opk-phant-cli/archive/0.3.0.zip
unzip drivers/0.3.0.zip
rm drivers/0.3.0.zip
./drivers/opk-phant-cli-0.3.0/install

wget --directory-prefix drivers https://github.com/openpipekit/opk-temper1-cli/archive/0.5.0.zip
unzip drivers/0.5.0.zip
rm drivers/0.5.0.zip
./drivers/opk-temper1-cli-0.5.0/install

pirate-sh --ssid hmk --wepkey password

mv ./autorunonce.sh ./autoranonce.sh

blink yellow

reboot

autorun.sh

blink yellow

blink red

watch -n60 "./drivers/opk-temper1-cli-0.5.0/pull --path USB1 | ./drivers/opk-phant-cli-0.3.0/push --url http://data.sparkfun.com/stream/E9fejd9efjfj --private_key IIF9efejfese83n" &
watch -n60 "./drivers/opk-temper1-cli-0.5.0/pull --path USB2 | ./drivers/opk-phant-cli-0.3.0/push --url http://data.sparkfun.com/stream/Ienv335bei7s --private_key iDejfNe9fejsnpl" &

blink green

@rjcorwin
Copy link
Contributor Author

I suppose we don't need an autorunonce.sh. We could start with autorun.sh as the install script that then replaces itself with another file next to it maybe called run.sh.

@rjcorwin
Copy link
Contributor Author

Here is an example of doing an install before making autorun.sh a pipe script. @treehouse-su This utilizes your prirate-sh script and then does the necessary reboot. This also has blink commands to indicate status to the outside which is a special frill.

autorun.sh

blink red

wget --directory-prefix drivers https://github.com/openpipekit/opk-phant-cli/archive/0.3.0.zip
unzip drivers/0.3.0.zip
rm drivers/0.3.0.zip
./drivers/opk-phant-cli-0.3.0/install

wget --directory-prefix drivers https://github.com/openpipekit/opk-temper1-cli/archive/0.5.0.zip
unzip drivers/0.5.0.zip
rm drivers/0.5.0.zip
./drivers/opk-temper1-cli-0.5.0/install

pirate-sh --ssid hmk --wepkey password

mv ./autorun.sh ./autoran.sh
mv ./run.sh autorun.sh

blink yellow

reboot

run.sh

blink yellow

blink red

watch -n60 "./drivers/opk-temper1-cli-0.5.0/pull --path USB1 | ./drivers/opk-phant-cli-0.3.0/push --url http://data.sparkfun.com/stream/E9fejd9efjfj --private_key IIF9efejfese83n" &
watch -n60 "./drivers/opk-temper1-cli-0.5.0/pull --path USB2 | ./drivers/opk-phant-cli-0.3.0/push --url http://data.sparkfun.com/stream/Ienv335bei7s --private_key iDejfNe9fejsnpl" &

blink green

@rjcorwin
Copy link
Contributor Author

Jack-in-a-Catapult approach... An autostart.sh file that downloads drivers, installs them, deletes itself, and then rewrites itself as pipe commands.

# Indicate we are installing.
blink red

# Get the drivers and install them
mkdir drivers

wget --directory-prefix drivers https://github.com/openpipekit/opk-phant-cli/archive/0.3.0.zip
unzip drivers/0.3.0.zip
rm drivers/0.3.0.zip
./drivers/opk-phant-cli-0.3.0/install

wget --directory-prefix drivers https://github.com/openpipekit/opk-temper1-cli/archive/0.5.0.zip
unzip drivers/0.5.0.zip
rm drivers/0.5.0.zip
./drivers/opk-temper1-cli-0.5.0/install

# Configure WiFi
pirate-sh --ssid hmk --wepkey password

# Reset the autorun.sh file.
rm ./autorun.sh
touch autorun.sh

# Build a new autorun.sh file.
echo 'blink yellow' >> autorun.sh

# Set up a pipe.
echo 'watch -n60 " \
  ./drivers/opk-temper1-cli-0.5.0/pull \
    --path USB1 | \
  ./drivers/opk-phant-cli-0.3.0/push \
  --url http://data.sparkfun.com/stream/E9fejd9efjfj \
  --private_key IIF9efejfese83n" &' \
>> autorun.sh

# Set up another pipe.
echo 'watch -n60 " \
  ./drivers/opk-temper1-cli-0.5.0/pull \
    --path USB1 | \
  ./drivers/opk-phant-cli-0.3.0/push \
  --url http://data.sparkfun.com/stream/E9fejd9efjfj \
  --private_key IIF9efejfese83n" &' \
>> autorun.sh

# Indicate that everything is cool.
echo 'blink green' >> autorun.sh

# Indicate that we are going to reboot
blink yellow

# All done, next reboot will use the autorun.sh we just built.
reboot

@dwblair
Copy link
Contributor

dwblair commented Apr 27, 2015

Awesome!

Q: At what point in the user install would this be done? Is it specific to the particular use-case and owner (i.e. are the credentials, drivers, and wifi details user-specific), or is this installing a "full basic general driver package" that people can use to get started? Or somethin'

@dwblair
Copy link
Contributor

dwblair commented Apr 27, 2015

Here's a nice listing of various approaches to starting a script on boot:

http://raspberrywebserver.com/serveradmin/run-a-script-on-start-up.html

@rjcorwin
Copy link
Contributor Author

Here's an idea for a script that set up Debian so that on boot it runs autostart.sh found on boot partition or USB.

sudo touch /etc/init.d/autorun
sudo echo "/boot/autorun.sh" >> /etc/init.d/autorun
sudo echo "mount /dev/sda1 /home/usb1" >> /etc/init.d/autorun
sudo echo "/home/usb1/autorun.sh" >> /etc/init.d/autorun
sudo echo "mount /dev/sda2 /home/usb2" >> /etc/init.d/autorun
sudo echo "/home/usb2/autorun.sh" >> /etc/init.d/autorun
sudo chmod 755 /etc/init.d/autorun
sudo update-rc.d autorun defaults

@rjcorwin
Copy link
Contributor Author

The steps would be...

Step 1: Identify the problem you want to solve.
Step 2: Peruse drivers on hub.openpipekit.org to discover what might solve
your problem.
Step 3: Order hardware, receive it, plug it all in.
Step 4: Burn OPK Distro on SD Card
Step 5: Use the Pipe Builder on hub.opk.org to generate an autostart.sh
script. You do this by filling out forms to explain the sensors you bought,
the wifi you need to connect to, and where the data will be sent.
Step 6: Plug your SD Card into a card reader in your computer and put the
autostart.sh file on it.
Step 7: Plug the SD Card into your Pi
Step 8: Plug an Ethernet chord into your Pi and then a power cable.
Step 9: Wait until light turns green.
Step 10: Unplug ethernet chord.
Step 11: Install Pi in desired location, power up, wait until light turns
green to confirm it worked.

  • RJ

rj@rjsteinert.com
http://rjsteinert.com
http://twitter.com/rjsteinert
http://github.com/rjsteinert

On Mon, Apr 27, 2015 at 4:35 PM, dwblair notifications@github.com wrote:

Here's a nice listing of various approaches to starting a script on boot:

http://raspberrywebserver.com/serveradmin/run-a-script-on-start-up.html


Reply to this email directly or view it on GitHub
#27 (comment)
.

@rjcorwin
Copy link
Contributor Author

Blink cli for reference: http://blink1.thingm.com/blink1-tool/

@treehouse-su
Copy link

Jack-in-a-Catapult approach... An autostart.sh file that downloads drivers, installs them, deletes itself, and then rewrites itself as pipe commands.

# Configure WiFi
pirate-sh --ssid hmk --wepkey password

# Wait until internet is reachable
blink blue
while ! ping -c 1 -W 1 1.2.3.4; do
    echo "Waiting for 1.2.3.4 - network interface might be down..."
    sleep 1
done

# Indicate we are installing.
blink red

# Get the drivers and install them
mkdir /boot/drivers
cd /boot/drivers
wget --directory-prefix drivers https://github.com/openpipekit/opk-phant-cli/archive/0.3.0.zip
unzip drivers/0.3.0.zip
rm drivers/0.3.0.zip
./drivers/opk-phant-cli-0.3.0/install

wget --directory-prefix drivers https://github.com/openpipekit/opk-temper1-cli/archive/0.5.0.zip
unzip drivers/0.5.0.zip
rm drivers/0.5.0.zip
./drivers/opk-temper1-cli-0.5.0/install

# Reset the autorun.sh file.
cd /boot
mv autorun.sh autoran.sh
touch autorun.sh

# Build a new autorun.sh file.
echo 'blink yellow' >> autorun.sh

# Set up a pipe.
echo 'watch -n60 " \
  ./drivers/opk-temper1-cli-0.5.0/pull \
    --path USB1 | \
  ./drivers/opk-phant-cli-0.3.0/push \
  --url http://data.sparkfun.com/stream/E9fejd9efjfj \
  --private_key IIF9efejfese83n" &' \
>> autorun.sh

# Set up another pipe.
echo 'watch -n60 " \
  ./drivers/opk-temper1-cli-0.5.0/pull \
    --path USB1 | \
  ./drivers/opk-phant-cli-0.3.0/push \
  --url http://data.sparkfun.com/stream/E9fejd9efjfj \
  --private_key IIF9efejfese83n" &' \
>> autorun.sh

# Indicate that everything is cool.
echo 'blink green' >> autorun.sh

# Indicate that we are going to reboot
blink yellow

# All done, next reboot will use the autorun.sh we just built.
reboot

@rjcorwin
Copy link
Contributor Author

I'm working on an Underscore based template that should evaluate given the data at the beginning to something like the Jack-in-a-Box script example we are working on. Very much not finished yet but figured I'd get it started.

gist here -> https://gist.github.com/rjsteinert/32c43313cf80e4ce6c10

@rjcorwin
Copy link
Contributor Author

^ the exercise is important in order for us to figure out what data we need to feed a template to get a JITB on the other end. This will help me figure out what data structure hub.openpipekit.org needs to deliver to the JITB script builder so it can present some forms to the user and then use the input from user + data from hub.openpipekit.org and feed it into the JITB template.

@rjcorwin rjcorwin assigned rjcorwin and treehouse-su and unassigned rjcorwin Apr 28, 2015
@rjcorwin rjcorwin changed the title Open Pipe Kit as a USB Drive and autorun.sh Open Pipe Kit as a file on a USB Drive Apr 30, 2015
@rjcorwin rjcorwin changed the title Open Pipe Kit as a file on a USB Drive Open Pipe Kit as an autostart.sh file on a USB Drive Apr 30, 2015
@rjcorwin
Copy link
Contributor Author

rjcorwin commented May 1, 2015

Super simple Jack-In-The-Box example that makes a light blink.

git clone https://github.com/todbot/blink1.git
cd blink1/commandline
make

cd ../../
mv autorun.sh autoran.sh
touch autorun.sh
chmod 755 autorun.sh

echo 'watch -n3 "./blink1/commandline/blink1-tool --blink 1"' > autorun.sh

reboot

@rjcorwin
Copy link
Contributor Author

rjcorwin commented May 1, 2015

for r-pi

apt-get install -y libusb-1.0-0-dev
cd /root
git clone https://github.com/todbot/blink1.git
cd blink1/commandline
make

cd /boot
mv autorun.sh autoran.sh
touch autorun.sh
chmod 755 autorun.sh

echo 'watch -n3 "/root/blink1/commandline/blink1-tool --blink 1"' > /boot/autorun.sh
#reboot
root@opkI5:/boot# vim autorun.sh
root@opkI5:/boot# cat autorun.sh
sudo apt-get install libusb-1.0-0-dev
cd /root
git clone https://github.com/todbot/blink1.git
cd blink1/commandline
make

cd /boot
mv autorun.sh autoran.sh
touch autorun.sh
chmod 755 autorun.sh

echo 'watch -n3 "/root/blink1/commandline/blink1-tool --blink 1"' > /boot/autorun.sh
reboot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants