First Release

This commit is contained in:
BuildTools 2019-12-12 13:13:55 +13:00
commit 2626620ea5
27 changed files with 16224 additions and 0 deletions

9
.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
deploy/*
work/*
config
postrun.sh
SKIP
SKIP_IMAGES
.pc
*-pc
apt-cacher-ng/

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "pi-gen"]
path = pi-gen
url = https://github.com/RPi-Distro/pi-gen.git

13
README.md Normal file
View File

@ -0,0 +1,13 @@
# Kiwi Bot Raspberry Pi Image
## Downloading
```
git clone --recurse-submodules https://git.1248.nz/kiwibot/pi-image.git
```
## Building
```
cp config.sample config
./build
```

2
build.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
sudo CLEAN=1 pi-gen/build.sh -c config

12
config.sample Normal file
View File

@ -0,0 +1,12 @@
IMG_NAME='bot'
FIRST_USER_PASS='a'
ENABLE_SSH=1
#IMG_DATE=1
#APT_PROXY=http://172.17.0.1:3142
DEPLOY_ZIP=1
#WPA_ESSID=""
#WPA_PASSWORD=""
#WPA_COUNTRY=""
STAGE_LIST="pi-gen/stage0 pi-gen/stage1 pi-gen/stage2 avr deploy"
WORK_DIR="$PWD/work"
DEPLOY_DIR="$PWD/deploy"

4
custom/EXPORT_IMAGE Normal file
View File

@ -0,0 +1,4 @@
IMG_SUFFIX="-lite"
if [ "${USE_QEMU}" = "1" ]; then
export IMG_SUFFIX="${IMG_SUFFIX}-qemu"
fi

1
custom/avr/00-packages Normal file
View File

@ -0,0 +1 @@
avrdude gcc-avr binutils-avr avr-libc

3
custom/avr/00-run.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash -e
install files/avrdude.conf ${ROOTFS_DIR}/etc/avrdude.conf

15858
custom/avr/files/avrdude.conf Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
#dnsmasq dhcpcd hostapd

View File

@ -0,0 +1,6 @@
--- a/rootfs/boot/cmdline.txt 2019-07-25 08:58:33.178998588 +1200
+++ b/rootfs/boot/cmdline.txt 2019-07-27 21:48:44.709707517 +1200
@@ -1 +1 @@
-console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh
+console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether quiet init=/usr/lib/raspi-config/init_resize.sh

View File

@ -0,0 +1,19 @@
--- /rootfs/boot/config.txt
+++ /rootfs/boot/config.txt
@@ -56,6 +56,14 @@
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
+#usb ethernet
+[pi0]
+dtoverlay=dwc2
+
+#usb ethernet
+[pi3]
+dtoverlay=dwc2,dr_mode=peripheral
+
[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d

View File

@ -0,0 +1,73 @@
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details
# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1
# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1
# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16
# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720
# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1
# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1
# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2
# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4
# uncomment for composite PAL
#sdtv_mode=2
#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800
# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on
# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18
# Additional overlays and parameters are documented /boot/overlays/README
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
#usb ethernet
[pi0]
dtoverlay=dwc2
#usb ethernet
[pi3]
dtoverlay=dwc2,dr_mode=peripheral
[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
[all]
#dtoverlay=vc4-fkms-v3d

View File

@ -0,0 +1,2 @@
00-cmdline.txt.diff
01-config.txt.diff

6
custom/net-tweaks/00-run.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash -e
#install files/wpa_supplicant.conf ${ROOTFS_DIR}/boot/wpa_supplicant.conf
install files/wifi ${ROOTFS_DIR}/usr/local/bin/wifi
chmod +x ${ROOTFS_DIR}/usr/local/bin/wifi
echo 'bot' > ${ROOTFS_DIR}/etc/hostname

View File

@ -0,0 +1,109 @@
#!/bin/sh
# The script configures simultaneous AP and Managed Mode Wifi on Raspberry Pi Zero W (should also work on Raspberry Pi 3)
# Usage: curl https://gist.githubusercontent.com/lukicdarkoo/6b92d182d37d0a10400060d8344f86e4/raw | sh -s WifiSSID WifiPass APSSID APPass
# Licence: GPLv3
# Author: Darko Lukic <lukicdarkoo@gmail.com>
# Special thanks to: https://albeec13.github.io/2017/09/26/raspberry-pi-zero-w-simultaneous-ap-and-managed-mode-wifi/
MAC_ADDRESS="$(cat /sys/class/net/wlan0/address)"
CLIENT_SSID="${1}"
CLIENT_PASSPHRASE="${2}"
AP_SSID="${3}"
AP_PASSPHRASE="${4}"
# Install dependencies
sudo apt -y update
sudo apt -y upgrade
sudo apt -y install dnsmasq dhcpcd hostapd
# Populate `/etc/udev/rules.d/70-persistent-net.rules`
sudo bash -c 'cat > /etc/udev/rules.d/70-persistent-net.rules' << EOF
SUBSYSTEM=="ieee80211", ACTION=="add|change", ATTR{macaddress}=="${MAC_ADDRESS}", KERNEL=="phy0", \
RUN+="/sbin/iw phy phy0 interface add ap0 type __ap", \
RUN+="/bin/ip link set ap0 address ${MAC_ADDRESS}
EOF
# Populate `/etc/dnsmasq.conf`
sudo bash -c 'cat > /etc/dnsmasq.conf' << EOF
interface=lo,ap0
no-dhcp-interface=lo,wlan0
bind-interfaces
server=8.8.8.8
domain-needed
bogus-priv
dhcp-range=192.168.10.50,192.168.10.150,12h
EOF
# Populate `/etc/hostapd/hostapd.conf`
sudo bash -c 'cat > /etc/hostapd/hostapd.conf' << EOF
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
interface=ap0
driver=nl80211
ssid=${AP_SSID}
hw_mode=g
channel=11
wmm_enabled=0
macaddr_acl=0
auth_algs=1
wpa=2PASSPHRASE
wpa_passphrase=${AP_PASSPHRASE}
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
rsn_pairwise=CCMP
EOF
# Populate `/etc/default/hostapd`
sudo bash -c 'cat > /etc/default/hostapd' << EOF
DAEMON_CONF="/etc/hostapd/hostapd.conf"
EOF
# Populate `/etc/wpa_supplicant/wpa_supplicant.conf`
sudo bash -c 'cat > /etc/wpa_supplicant/wpa_supplicant.conf' << EOF
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="${CLIENT_SSID}"
psk="${CLIENT_PASSPHRASE}"
id_str="AP1"
}
EOF
# Populate `/etc/network/interfaces`
sudo bash -c 'cat > /etc/network/interfaces' << EOF
source-directory /etc/network/interfaces.d
auto lo
auto ap0
auto wlan0
iface lo inet loopback
allow-hotplug ap0
iface ap0 inet static
address 192.168.10.1
netmask 255.255.255.0
hostapd /etc/hostapd/hostapd.conf
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface AP1 inet dhcp
EOF
# Populate `/bin/start_wifi.sh`
sudo bash -c 'cat > /bin/start_wifi.sh' << EOF
echo 'Starting Wifi AP and client...'
sleep 30
sudo ifdown --force wlan0
sudo ifdown --force ap0
sudo ifup ap0
sudo ifup wlan0
sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables -t nat -A POSTROUTING -s 192.168.10.0/24 ! -d 192.168.10.0/24 -j MASQUERADE
sudo systemctl restart dnsmasq
EOF
sudo chmod +x /bin/start_wifi.sh
crontab -l | { cat; echo "@reboot /bin/start_wifi.sh"; } | crontab -
echo "Wifi configuration is finished! Please reboot your Raspberry Pi to apply changes..."

View File

@ -0,0 +1,8 @@
country=NZ
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="Infected"
psk="(m0unt@1n5)"
key_mgmt=WPA-PSK
}

5
custom/prerun.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash -e
if [ ! -d "${ROOTFS_DIR}" ]; then
copy_previous
fi

View File

@ -0,0 +1,3 @@
python3-picamera python3-pip python-pip python3-smbus
i2c-tools pigpio libjpeg-dev zlib1g-dev libfreetype6-dev
liblcms1-dev libopenjp2-7 libtiff5

View File

@ -0,0 +1,13 @@
#!/bin/bash -e
on_chroot << EOF
/usr/bin/python3 -m pip install pip --upgrade
/usr/bin/python3 -m pip install \
aiohttp \
pigpio \
gpiozero \
jupyter \
opencv-contrib-python-headless
systemctl enable pigpiod
systemctl daemon-reload
EOF

View File

@ -0,0 +1,2 @@
git fish

7
custom/sys-tweaks/00-run.sh Executable file
View File

@ -0,0 +1,7 @@
#/bin/bash -e
on_chroot << EOF
chsh -s /usr/bin/fish pi
EOF

1
custom/theia/00-packages Normal file
View File

@ -0,0 +1 @@
git

20
custom/theia/00-run.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash -e
install -d ${ROOTFS_DIR}/opt/theia
install files/package.json ${ROOTFS_DIR}/opt/theia
install -d -o 1000 -g 1000 ${ROOTFS_DIR}/home/pi/projects
install -D -m 644 files/theia.service ${ROOTFS_DIR}/etc/systemd/system/theia.service
curl -SL https://nodejs.org/dist/latest-v8.x/node-v8.16.2-linux-armv6l.tar.gz | \
tar xzC ${ROOTFS_DIR}/usr/local/ --strip-components=1
curl -SL https://yarnpkg.com/latest.tar.gz | \
tar xzC ${ROOTFS_DIR}/usr/local/ --strip-components=1
on_chroot << EOF
cd /opt/theia
/usr/local/bin/yarn
/usr/local/bin/yarn theia build
systemctl enable theia.service
systemctl daemon-reload
EOF

View File

@ -0,0 +1,27 @@
{
"private": true,
"dependencies": {
"typescript": "latest",
"@theia/typescript": "next",
"@theia/navigator": "next",
"@theia/terminal": "next",
"@theia/outline-view": "next",
"@theia/preferences": "next",
"@theia/messages": "next",
"@theia/git": "next",
"@theia/file-search": "next",
"@theia/markers": "next",
"@theia/preview": "next",
"@theia/callhierarchy": "next",
"@theia/merge-conflicts": "next",
"@theia/search-in-workspace": "next",
"@theia/json": "next",
"@theia/textmate-grammars": "next",
"@theia/mini-browser": "next",
"@theia/python": "next",
"@theia/cpp": "next"
},
"devDependencies": {
"@theia/cli": "next"
}
}

View File

@ -0,0 +1,16 @@
[Unit]
Description=Theia Ide
[Service]
Type=simple
PIDFile=/run/theia.pid
ExecStart=/usr/local/bin/yarn theia start --hostname 0.0.0.0 /home/pi/projects
User=pi
Group=pi
WorkingDirectory=/opt/theia
Restart=always
RestartSec=10
#KillMode=mixed
[Install]
WantedBy=multi-user.target

1
pi-gen Submodule

@ -0,0 +1 @@
Subproject commit a449c75facc8b373eab7cf4f884f5a3d45028478