Open rjcorwin opened 9 years ago
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
autorun.sh
that starts everything in the run
folder and pipes to corresponding log files.pipe1.sh
that runs install on all dependent drivers and then sets up the pipe to run at an interval.Other thoughts...
install
for drivers should be self aware if they have been installed on a system to save on that load timeLastly, this is a lot to do. We all need to be thinking MVP here.
... 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?
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.
@treehouse-su What are your thoughts on the difficulty level of getting autorun to work on Debian?
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
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
.
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
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
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'
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
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
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@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 https://github.com/open-eio/Open-Pipe-Kit-Project/issues/27#issuecomment-96811968 .
Blink cli for reference: http://blink1.thingm.com/blink1-tool/
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
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
^ 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.
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
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
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 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...
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.