Skip to content

Commit

Permalink
update blocks to 2.0
Browse files Browse the repository at this point in the history
blocks 2.0 contain OTG modes, a fix to the run command block, and the
new block loading system
  • Loading branch information
davidferguson committed Aug 7, 2016
1 parent 90d9670 commit 034d2c0
Show file tree
Hide file tree
Showing 27 changed files with 326 additions and 4 deletions.
1 change: 1 addition & 0 deletions pibakery-blocks/bootbehaviour/bootbehaviour.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"network": false,
"continue": true,
"type": "setting",
"category":"setting",
"shortDescription":"Alter what happens when you power on your Raspberry Pi. Requires reboot to take effect",
"longDescription":"When you power on you Raspberry Pi, you can choose what you want to happen. You can either have it open the Desktop or just the text console, and in both of these cases you can choose whether you want to have the Raspberry Pi automatically log in for you or not."
}
29 changes: 29 additions & 0 deletions pibakery-blocks/categories.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"categories": [
{
"name": "software",
"display": "Programs",
"colour": "120"
},
{
"name": "network",
"display": "Network",
"colour": "260"
},
{
"name": "setting",
"display": "Settings",
"colour": "210"
},
{
"name": "otg",
"display": "Pi Zero OTG",
"colour": "80"
},
{
"name": "other",
"display": "Other",
"colour": "290"
}
]
}
1 change: 1 addition & 0 deletions pibakery-blocks/changepass/changepass.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"network": false,
"continue": true,
"type": "setting",
"category":"setting",
"shortDescription":"Change the password for the default pi user",
"longDescription":"Raspbian comes with a user account already setup, with the username 'pi' and the password 'raspberry'. For the sake of security, you can choose to change your password to anything you want. If you don't change it now, you'll still be able to change it later."
}
1 change: 1 addition & 0 deletions pibakery-blocks/deletefile/deletefile.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"network": false,
"continue": true,
"type": "other",
"category":"other",
"shortDescription":"Delete a file or folder",
"longDescription":"If you so desire, you can choose to delete a file or folder from your Raspberry Pi. This block will not send the data to the recycle bin, rather it will delete it permanently. Please be careful when using this block."
}
1 change: 1 addition & 0 deletions pibakery-blocks/downloadfile/downloadfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"network": true,
"continue": true,
"type": "network",
"category":"network",
"shortDescription":"Download a file from the internet to a location on your Raspberry Pi. This block requires an internet connection to work.",
"longDescription":"This block allows you to enter a remote URL of a file along with a save location, and it will download the file to that location. As this block will download the file from the internet, an internet connection is required to use this block."
}
11 changes: 8 additions & 3 deletions pibakery-blocks/info.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
{
"version": 1.0,
"compressedMD5": "ccd8a4084986dbbceda36a423d829702",
"downloadUrl": "https://github.com/davidferguson/pibakery-blocks/releases/download/v0.1.0/pibakery-blocks.zip",
"version": 2.0,
"compressedMD5": "9c741092e80e07a01ac8c32a5ecbfc79",
"downloadUrl": "https://github.com/davidferguson/pibakery-blocks/releases/download/v0.2.0/pibakery-blocks.zip",
"loadOrder": [
"packageinstall",
"lampinstall",
"vncserver",
"vncstart",
"wifisetup",
"downloadfile",
"otgether",
"otgmidi",
"otgserial",
"otgmassstorage",
"otgremove",
"bootbehaviour",
"changepass",
"sethostname",
Expand Down
1 change: 1 addition & 0 deletions pibakery-blocks/lampinstall/lampinstall.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"network": true,
"continue": true,
"type": "software",
"category":"software",
"shortDescription":"Install a full web server on your Raspberry Pi. Requires internet connection.",
"longDescription":"Apache is a web server, and combined with PHP and MySQL it makes for a great way for beginners to experiment with web development, and also experienced users to easily run their websites. This downloads packages from the Raspbian repository, and therefore requires an internet connection."
}
50 changes: 50 additions & 0 deletions pibakery-blocks/otgether/otgEther.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

# Add the line to /boot/config.txt if it's not already there
if ! grep -qxF "dtoverlay=dwc2" "/boot/config.txt"
then
echo "dtoverlay=dwc2" | tee -a /boot/config.txt
fi

# Add the line to /etc/modules if it's not already there
if ! grep -qxF "dwc2" "/etc/modules"
then
echo "dwc2" | tee -a /etc/modules
fi

# Remove any modules currently in /etc/modules
otg_modules=( "g_serial" "g_ether" "g_mass_storage" "g_midi" "g_audio" "g_hid" "g_acm_ms" "g_cdc" "g_multi" "g_webcam" "g_printer" "g_zero" )
for module in "${otg_modules[@]}"
do
if grep -qxF "$module" "/etc/modules"
then
grep -v "$module" "/etc/modules" > "/etc/modules2"; mv "/etc/modules2" "/etc/modules"
fi
done

# Disable the g_mass_storage startup script if it exists
if [ -f /etc/systemd/system/otgmassstorage.service ]
then
systemctl disable /etc/systemd/system/otgmassstorage.service
fi

# Add g_ether to /etc/modules
echo "g_ether" | tee -a /etc/modules

# Remove the static IP stuff from /etc/dhcpcd.conf if it exists
startLine=$(grep -n "interface usb0 " /etc/dhcpcd.conf | cut -d : -f 1)
if [ ! -z "$startLine" ]
then
matchLine=$((startLine+1))
grep -n "static " /etc/dhcpcd.conf | cut -d : -f 1 | while read line
do
if [ $line -eq $matchLine ]
then
endLine=$line
sed -i "${startLine}d;${endLine}d" /etc/dhcpcd.conf
fi
done
fi

# Add the static IP to /etc/dhcpcd.conf
echo -e "interface usb0 \nstatic ip_address=$1" | tee -a /etc/dhcpcd.conf
18 changes: 18 additions & 0 deletions pibakery-blocks/otgether/otgether.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "otgether",
"text": "Set Pi Zero OTG Mode to Ethernet\\nWith Static IP: %1",
"script": "otgEther.sh",
"args": [
{
"type": "text",
"default": "169.254.64.64",
"maxLength":16
}
],
"network": false,
"continue": true,
"type": "network",
"category":"otg",
"shortDescription":"Set the Pi Zero to use Ethernet over OTG, with a static IP address.",
"longDescription":"The Raspberry Pi Zero has the ability to support OTG gadget mode over it's DATA usb port. This block enables the Ethernet gadget, allowing your Raspberry Pi to be networked to a computer over USB. You need to specify an IP address for your Raspberr Pi, so that you'll be able to connect to it."
}
74 changes: 74 additions & 0 deletions pibakery-blocks/otgmassstorage/otgMassStorage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

#megabytes=$1
#kilobytes=$((megabytes * 1024))
#bytes=$((kilobytes * 1024))

# Add the line to /boot/config.txt if it's not already there
if ! grep -qxF "dtoverlay=dwc2" "/boot/config.txt"
then
echo "dtoverlay=dwc2" | tee -a /boot/config.txt
fi

# Add the line to /etc/modules if it's not already there
if ! grep -qxF "dwc2" "/etc/modules"
then
echo "dwc2" | tee -a /etc/modules
fi

# Remove any modules currently in /etc/modules
otg_modules=( "g_serial" "g_ether" "g_mass_storage" "g_midi" "g_audio" "g_hid" "g_acm_ms" "g_cdc" "g_multi" "g_webcam" "g_printer" "g_zero" )
for module in "${otg_modules[@]}"
do
if grep -qxF "$module" "/etc/modules"
then
grep -v "$module" "/etc/modules" > "/etc/modules2"; mv "/etc/modules2" "/etc/modules"
fi
done

# Add g_acm_ms to /etc/modules
echo "g_mass_storage" | tee -a /etc/modules

if [ ! -d /opt/otgmassstorage ]
then
mkdir /opt/otgmassstorage
fi

if [ ! -f /opt/otgmassstorage/filesystem.bin ]
then
dd if=/dev/zero of=/opt/otgmassstorage/filesystem.bin bs=512 count=2880
mkdosfs /opt/otgmassstorage/filesystem.bin
fi

if [ ! -f /etc/systemd/system/otgmassstorage.service ]
then
/bin/cat <<EOF >/etc/systemd/system/otgmassstorage.service
[Unit]
Description=Starts kernel modules for USB OTG
After=systemd-remount-fs.service
DefaultDependencies=false
[Service]
Type=simple
ExecStart=/opt/otgmassstorage/start.sh
WorkingDirectory=/opt/otgmassstorage/
[Install]
WantedBy=local-fs.target
EOF
fi

if [ ! -f /opt/otgmassstorage/start.sh ]
then
/bin/cat <<EOF >/opt/otgmassstorage/start.sh
#!/bin/sh -e
modprobe g_mass_storage file=/opt/otgmassstorage/filesystem.bin stall=0
exit 0
EOF
fi

chmod +x /etc/systemd/system/otgmassstorage.service
chmod +x /opt/otgmassstorage/start.sh

systemctl enable /etc/systemd/system/otgmassstorage.service
12 changes: 12 additions & 0 deletions pibakery-blocks/otgmassstorage/otgmassstorage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "otgmassstorage",
"text": "Set Pi Zero OTG Mode to Mass Storage",
"script": "otgMassStorage.sh",
"args": [],
"network": false,
"continue": true,
"type": "setting",
"category":"otg",
"shortDescription":"Set the Pi Zero to use Mass Storage over OTG.",
"longDescription":"The Raspberry Pi Zero has the ability to support OTG gadget mode over it's DATA usb port. This block enables the Mass Storage gadget, allowing your Raspberry Pi to appear as a USB flash drive to a connected computer. The files dropped onto this drive will be saved in the BIN file '/opt/otgmassstorage/filesystem.bin' allowing you to mount it, and retrieve the files you stored on it."
}
32 changes: 32 additions & 0 deletions pibakery-blocks/otgmidi/otgMidi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# Add the line to /boot/config.txt if it's not already there
if ! grep -qxF "dtoverlay=dwc2" "/boot/config.txt"
then
echo "dtoverlay=dwc2" | tee -a /boot/config.txt
fi

# Add the line to /etc/modules if it's not already there
if ! grep -qxF "dwc2" "/etc/modules"
then
echo "dwc2" | tee -a /etc/modules
fi

# Remove any modules currently in /etc/modules
otg_modules=( "g_serial" "g_ether" "g_mass_storage" "g_midi" "g_audio" "g_hid" "g_acm_ms" "g_cdc" "g_multi" "g_webcam" "g_printer" "g_zero" )
for module in "${otg_modules[@]}"
do
if grep -qxF "$module" "/etc/modules"
then
grep -v "$module" "/etc/modules" > "/etc/modules2"; mv "/etc/modules2" "/etc/modules"
fi
done

# Disable the g_mass_storage startup script if it exists
if [ -f /etc/systemd/system/otgmassstorage.service ]
then
systemctl disable /etc/systemd/system/otgmassstorage.service
fi

# Add g_midi to /etc/modules
echo "g_midi" | tee -a /etc/modules
12 changes: 12 additions & 0 deletions pibakery-blocks/otgmidi/otgmidi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "otgmidi",
"text": "Set Pi Zero OTG Mode to MIDI",
"script": "otgMidi.sh",
"args": [],
"network": false,
"continue": true,
"type": "setting",
"category":"otg",
"shortDescription":"Set the Pi Zero to use MIDI over OTG.",
"longDescription":"The Raspberry Pi Zero has the ability to support OTG gadget mode over it's DATA usb port. This block enables the MIDI gadget, allowing your Raspberry Pi to appear as a MIDI input and output to a connected computer. Use any standard MIDI program on the connected computer or Raspberry Pi Zero to play music between the Pi and computer."
}
17 changes: 17 additions & 0 deletions pibakery-blocks/otgremove/otgRemove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Remove any modules currently in /etc/modules
otg_modules=( "g_serial" "g_ether" "g_mass_storage" "g_midi" "g_audio" "g_hid" "g_acm_ms" "g_cdc" "g_multi" "g_webcam" "g_printer" "g_zero" )
for module in "${otg_modules[@]}"
do
if grep -qxF "$module" "/etc/modules"
then
grep -v "$module" "/etc/modules" > "/etc/modules2"; mv "/etc/modules2" "/etc/modules"
fi
done

# Disable the g_mass_storage startup script if it exists
if [ -f /etc/systemd/system/otgmassstorage.service ]
then
systemctl disable /etc/systemd/system/otgmassstorage.service
fi
12 changes: 12 additions & 0 deletions pibakery-blocks/otgremove/otgremove.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "otgremove",
"text": "Disable Pi Zero OTG",
"script": "otgRemove.sh",
"args": [],
"network": false,
"continue": true,
"type": "setting",
"category":"otg",
"shortDescription":"Disable the OTG mode on the Raspberry Pi Zero.",
"longDescription":"The Raspberry Pi Zero has the ability to support OTG gadget mode over it's DATA usb port. If you've enabled this feature using one of the OTG blocks, you can use this block to return the Pi Zero back to it's default behaviour of not having any gadget enabled."
}
35 changes: 35 additions & 0 deletions pibakery-blocks/otgserial/otgSerial.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# Add the line to /boot/config.txt if it's not already there
if ! grep -qxF "dtoverlay=dwc2" "/boot/config.txt"
then
echo "dtoverlay=dwc2" | tee -a /boot/config.txt
fi

# Add the line to /etc/modules if it's not already there
if ! grep -qxF "dwc2" "/etc/modules"
then
echo "dwc2" | tee -a /etc/modules
fi

# Remove any modules currently in /etc/modules
otg_modules=( "g_serial" "g_ether" "g_mass_storage" "g_midi" "g_audio" "g_hid" "g_acm_ms" "g_cdc" "g_multi" "g_webcam" "g_printer" "g_zero" )
for module in "${otg_modules[@]}"
do
if grep -qxF "$module" "/etc/modules"
then
grep -v "$module" "/etc/modules" > "/etc/modules2"; mv "/etc/modules2" "/etc/modules"
fi
done

# Disable the g_mass_storage startup script if it exists
if [ -f /etc/systemd/system/otgmassstorage.service ]
then
systemctl disable /etc/systemd/system/otgmassstorage.service
fi

# Add g_serial to /etc/modules
echo "g_serial" | tee -a /etc/modules

# Forward a console over the serial
systemctl enable getty@ttyGS0.service
12 changes: 12 additions & 0 deletions pibakery-blocks/otgserial/otgserial.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "otgserial",
"text": "Set Pi Zero OTG Mode to Serial",
"script": "otgSerial.sh",
"args": [],
"network": false,
"continue": true,
"type": "setting",
"category":"otg",
"shortDescription":"Set the Pi Zero to use Serial over OTG.",
"longDescription":"The Raspberry Pi Zero has the ability to support OTG gadget mode over it's DATA usb port. This block enables the Serial gadget, allowing your Raspberry Pi to appear as a USB serial device to a connected computer. Using Putty on Windows, or Terminal on Mac and Linux, you'll be able to connect and log in to the command line of your Pi, over USB."
}
1 change: 1 addition & 0 deletions pibakery-blocks/packageinstall/packageinstall.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"network": true,
"continue": true,
"type": "software",
"category":"software",
"shortDescription":"Install any package from the Raspbian repositories. Internet connection required.",
"longDescription":"This block is exactly the same as running apt-get install, and allows you to easily install any package from the Raspbian repositories. An internet connection will be required for this to work."
}
1 change: 1 addition & 0 deletions pibakery-blocks/reboot/reboot.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"network": false,
"continue": false,
"type": "other",
"category":"other",
"shortDescription":"Reboots your Raspberry Pi",
"longDescription":"Exactly what it says on the block, this will reboot your Raspberry Pi."
}
Loading

0 comments on commit 034d2c0

Please sign in to comment.