mirror of
https://github.com/cimryan/teslausb.git
synced 2026-03-01 04:30:33 +00:00
Adding pi-gen sources as of v9-beta3
This commit is contained in:
1
pi-gen-sources/00-packages
Normal file
1
pi-gen-sources/00-packages
Normal file
@@ -0,0 +1 @@
|
|||||||
|
dos2unix
|
||||||
5
pi-gen-sources/00-patches/01-cmdline-update.diff
Normal file
5
pi-gen-sources/00-patches/01-cmdline-update.diff
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
--- stage7/rootfs/boot/cmdline.txt
|
||||||
|
+++ stage7/rootfs/boot/cmdline.txt
|
||||||
|
@@ -1 +1 @@
|
||||||
|
-dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh
|
||||||
|
+dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether quiet
|
||||||
7
pi-gen-sources/00-patches/02-config-update.diff
Normal file
7
pi-gen-sources/00-patches/02-config-update.diff
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
--- stage7/rootfs/boot/config.txt
|
||||||
|
+++ stage7/rootfs/boot/config.txt
|
||||||
|
@@ -54,3 +54,4 @@
|
||||||
|
|
||||||
|
# Enable audio (loads snd_bcm2835)
|
||||||
|
dtparam=audio=on
|
||||||
|
+dtoverlay=dwc2
|
||||||
9
pi-gen-sources/00-patches/03-hosts-update.diff
Normal file
9
pi-gen-sources/00-patches/03-hosts-update.diff
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
--- stage7/rootfs/etc/hosts
|
||||||
|
+++ stage7/rootfs/etc/hosts
|
||||||
|
@@ -3,4 +3,5 @@
|
||||||
|
ff02::1 ip6-allnodes
|
||||||
|
ff02::2 ip6-allrouters
|
||||||
|
|
||||||
|
-127.0.1.1 raspberrypi
|
||||||
|
+127.0.0.1 teslausb
|
||||||
|
+
|
||||||
5
pi-gen-sources/00-patches/04-hostname-update.diff
Normal file
5
pi-gen-sources/00-patches/04-hostname-update.diff
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
--- stage7/rootfs/etc/hostname
|
||||||
|
+++ stage7/rootfs/etc/hostname
|
||||||
|
@@ -1 +1 @@
|
||||||
|
-raspberrypi
|
||||||
|
+teslausb
|
||||||
4
pi-gen-sources/00-patches/series
Normal file
4
pi-gen-sources/00-patches/series
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
01-cmdline-update.diff
|
||||||
|
02-config-update.diff
|
||||||
|
03-hosts-update.diff
|
||||||
|
04-hostname-update.diff
|
||||||
52
pi-gen-sources/00-run.sh
Executable file
52
pi-gen-sources/00-run.sh
Executable file
@@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/bash -e
|
||||||
|
touch "${ROOTFS_DIR}/boot/ssh"
|
||||||
|
install -m 755 files/rc.local "${ROOTFS_DIR}/etc/"
|
||||||
|
install -m 755 files/stage_flash "${ROOTFS_DIR}/etc/"
|
||||||
|
install -m 666 files/teslausb_setup_variables.conf.sample "${ROOTFS_DIR}/boot/"
|
||||||
|
install -m 666 files/wpa_supplicant.conf.sample "${ROOTFS_DIR}/boot/"
|
||||||
|
install -d "${ROOTFS_DIR}/root/bin"
|
||||||
|
install -m 755 files/enable_wifi.sh "${ROOTFS_DIR}/root/bin"
|
||||||
|
|
||||||
|
# install -m 755 files/teslausb_setup_scripts/bin/* "${ROOTFS_DIR}/root/bin/"
|
||||||
|
# install -d "${ROOTFS_DIR}/root/bin/tmp"
|
||||||
|
# install -m 755 files/teslausb_setup_scripts/tmp/* "${ROOTFS_DIR}/root/bin/tmp/"
|
||||||
|
|
||||||
|
# on_chroot << EOF
|
||||||
|
# systemctl disable hwclock.sh
|
||||||
|
# systemctl disable nfs-common
|
||||||
|
# systemctl disable rpcbind
|
||||||
|
# systemctl disable ssh
|
||||||
|
# systemctl enable regenerate_ssh_host_keys
|
||||||
|
# EOF
|
||||||
|
|
||||||
|
# if [ "${USE_QEMU}" = "1" ]; then
|
||||||
|
# echo "enter QEMU mode"
|
||||||
|
# install -m 644 files/90-qemu.rules "${ROOTFS_DIR}/etc/udev/rules.d/"
|
||||||
|
# on_chroot << EOF
|
||||||
|
# systemctl disable resize2fs_once
|
||||||
|
# EOF
|
||||||
|
# echo "leaving QEMU mode"
|
||||||
|
# else
|
||||||
|
# on_chroot << EOF
|
||||||
|
# systemctl enable resize2fs_once
|
||||||
|
# EOF
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# on_chroot << \EOF
|
||||||
|
# for GRP in input spi i2c gpio; do
|
||||||
|
# groupadd -f -r "$GRP"
|
||||||
|
# done
|
||||||
|
# for GRP in adm dialout cdrom audio users sudo video games plugdev input gpio spi i2c netdev; do
|
||||||
|
# adduser pi $GRP
|
||||||
|
# done
|
||||||
|
# EOF
|
||||||
|
|
||||||
|
# on_chroot << EOF
|
||||||
|
# setupcon --force --save-only -v
|
||||||
|
# EOF
|
||||||
|
|
||||||
|
# on_chroot << EOF
|
||||||
|
# usermod --pass='*' root
|
||||||
|
# EOF
|
||||||
|
|
||||||
|
# rm -f "${ROOTFS_DIR}/etc/ssh/"ssh_host_*_key*
|
||||||
49
pi-gen-sources/files/enable_wifi.sh
Normal file
49
pi-gen-sources/files/enable_wifi.sh
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
#! /bin/bash -eu
|
||||||
|
|
||||||
|
HEADLESS_SETUP=false
|
||||||
|
|
||||||
|
if [ -e "/boot/teslausb-headless-setup.log" ]
|
||||||
|
then
|
||||||
|
HEADLESS_SETUP=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
function setup_progress () {
|
||||||
|
if [ $HEADLESS_SETUP = "true" ]
|
||||||
|
then
|
||||||
|
SETUP_LOGFILE=/boot/teslausb-headless-setup.log
|
||||||
|
echo "$( date ) : $1" >> "$SETUP_LOGFILE"
|
||||||
|
fi
|
||||||
|
echo $1
|
||||||
|
}
|
||||||
|
|
||||||
|
function enable_wifi () {
|
||||||
|
setup_progress "Detecting whether to update wpa_supplicant.conf"
|
||||||
|
if [ ! -z ${SSID+x} ] && [ ! -z ${WIFIPASS+x} ]
|
||||||
|
then
|
||||||
|
if [ ! -e /boot/WIFI_ENABLED ]
|
||||||
|
then
|
||||||
|
if [ -e /root/bin/remountfs_rw ]
|
||||||
|
then
|
||||||
|
/root/bin/remountfs_rw
|
||||||
|
fi
|
||||||
|
setup_progress "Wifi variables specified, and no /boot/WIFI_ENABLED. Building wpa_supplicant.conf."
|
||||||
|
cp /boot/wpa_supplicant.conf.sample /boot/wpa_supplicant.conf
|
||||||
|
sed -i'.bak' -e "s/TEMPSSID/${SSID}/g" /boot/wpa_supplicant.conf
|
||||||
|
sed -i'.bak' -e "s/TEMPPASS/${WIFIPASS}/g" /boot/wpa_supplicant.conf
|
||||||
|
cp /boot/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf
|
||||||
|
touch /boot/WIFI_ENABLED
|
||||||
|
setup_progress "Rebooting..."
|
||||||
|
reboot
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "You need to export your desired SSID and WIFI pass like:"
|
||||||
|
echo " export SSID=your_ssid"
|
||||||
|
echo " export WIFIPASS=your_wifi_pass"
|
||||||
|
echo ""
|
||||||
|
echo "Then re-run enable_wifi.sh"
|
||||||
|
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
enable_wifi
|
||||||
6
pi-gen-sources/files/hosts
Normal file
6
pi-gen-sources/files/hosts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
127.0.0.1 localhost
|
||||||
|
::1 localhost ip6-localhost ip6-loopback
|
||||||
|
ff02::1 ip6-allnodes
|
||||||
|
ff02::2 ip6-allrouters
|
||||||
|
|
||||||
|
127.0.0.1 raspberrypi
|
||||||
153
pi-gen-sources/files/rc.local
Executable file
153
pi-gen-sources/files/rc.local
Executable file
@@ -0,0 +1,153 @@
|
|||||||
|
#!/bin/bash -e
|
||||||
|
#
|
||||||
|
# rc.local
|
||||||
|
#
|
||||||
|
# This script is executed at the end of each multiuser runlevel.
|
||||||
|
# Make sure that the script will "exit 0" on success or any other
|
||||||
|
# value on error.
|
||||||
|
#
|
||||||
|
# In order to enable or disable this script just change the execution
|
||||||
|
# bits.
|
||||||
|
#
|
||||||
|
# By default this script does nothing.
|
||||||
|
|
||||||
|
# Print the IP address
|
||||||
|
_IP=$(hostname -I) || true
|
||||||
|
if [ "$_IP" ]; then
|
||||||
|
printf "My IP address is %s\n" "$_IP"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
SETUP_LOGFILE=/boot/teslausb-headless-setup.log
|
||||||
|
|
||||||
|
function setup_progress () {
|
||||||
|
echo "$( date ) : $1" >> "$SETUP_LOGFILE"
|
||||||
|
echo $1
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_script () {
|
||||||
|
local local_path="$1"
|
||||||
|
local name="$2"
|
||||||
|
local remote_path="${3:-}"
|
||||||
|
|
||||||
|
curl -o "$local_path/$name" https://raw.githubusercontent.com/"$REPO"/teslausb/"$BRANCH"/"$remote_path"/"$name"
|
||||||
|
# wget -O "$local_path/$name" https://raw.githubusercontent.com/"$REPO"/teslausb/"$BRANCH"/"$remote_path"/"$name"
|
||||||
|
chmod +x "$local_path/$name"
|
||||||
|
}
|
||||||
|
|
||||||
|
function enable_wifi () {
|
||||||
|
setup_progress "Detecting whether to update wpa_supplicant.conf"
|
||||||
|
if [[ ! -z $SSID ]] && [[ ! -z $WIFIPASS ]]
|
||||||
|
then
|
||||||
|
if [ ! -e /boot/WIFI_ENABLED ]
|
||||||
|
then
|
||||||
|
if [ -e /root/bin/remountfs_rw ]
|
||||||
|
then
|
||||||
|
/root/bin/remountfs_rw
|
||||||
|
fi
|
||||||
|
setup_progress "Wifi variables specified, and no /boot/WIFI_ENABLED. Building wpa_supplicant.conf."
|
||||||
|
cp /boot/wpa_supplicant.conf.sample /boot/wpa_supplicant.conf
|
||||||
|
sed -i'.bak' -e "s/TEMPSSID/${SSID}/g" /boot/wpa_supplicant.conf
|
||||||
|
sed -i'.bak' -e "s/TEMPPASS/${WIFIPASS}/g" /boot/wpa_supplicant.conf
|
||||||
|
cp /boot/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf
|
||||||
|
touch /boot/WIFI_ENABLED
|
||||||
|
setup_progress "Rebooting..."
|
||||||
|
reboot
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if [ -e "/boot/teslausb_setup_variables.conf" ]
|
||||||
|
then
|
||||||
|
if [ -e /root/bin/remountfs_rw ]
|
||||||
|
then
|
||||||
|
/root/bin/remountfs_rw
|
||||||
|
fi
|
||||||
|
cp /boot/teslausb_setup_variables.conf /root/
|
||||||
|
dos2unix /root/teslausb_setup_variables.conf
|
||||||
|
source "/root/teslausb_setup_variables.conf"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for headless setup
|
||||||
|
if [ -z "${HEADLESS_SETUP+x}" ]
|
||||||
|
then
|
||||||
|
HEADLESS_SETUP=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# check if we previously marked wifi as enabled
|
||||||
|
enable_wifi
|
||||||
|
# Good to start setup at this point
|
||||||
|
|
||||||
|
# This begins the Headless Setup loop
|
||||||
|
# If the FINISHED file does not exist then we start setup. Otherwise passes on to normal loop
|
||||||
|
if [ ! -e "/boot/TESLAUSB_SETUP_FINISHED" ] && [ $HEADLESS_SETUP = "true" ]
|
||||||
|
then
|
||||||
|
if [ -e /root/bin/remountfs_rw ]
|
||||||
|
then
|
||||||
|
/root/bin/remountfs_rw
|
||||||
|
fi
|
||||||
|
touch "/boot/TESLAUSB_SETUP_STARTED"
|
||||||
|
|
||||||
|
# Grab the setup variables. Should still be there since setup isn't finished.
|
||||||
|
# This is a double check to cover various scenarios of mixed headless/not headless setup attempts
|
||||||
|
if [ -e "/boot/teslausb_setup_variables.conf" ]
|
||||||
|
then
|
||||||
|
cp /boot/teslausb_setup_variables.conf /root/
|
||||||
|
dos2unix /root/teslausb_setup_variables.conf
|
||||||
|
source "/root/teslausb_setup_variables.conf"
|
||||||
|
else
|
||||||
|
# No conf file found, can't complete setup
|
||||||
|
setup_progress "Setup appears not to have completed, but you didn't provide a teslausb_setup_variables.conf."
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Make the bin dir if needed to grab the setup script into it and persist
|
||||||
|
if [ ! -d "/root/bin" ]
|
||||||
|
then
|
||||||
|
mkdir "/root/bin"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e "/root/bin/setup-teslausb" ]
|
||||||
|
then
|
||||||
|
REPO=${REPO:-cimryan}
|
||||||
|
BRANCH=${BRANCH:-master}
|
||||||
|
# Script doesn't exist, grab it.
|
||||||
|
setup_progress "Grabbing main setup file."
|
||||||
|
get_script /root/bin setup-teslausb setup/pi
|
||||||
|
fi
|
||||||
|
|
||||||
|
setup_progress "Starting setup."
|
||||||
|
|
||||||
|
# Update the archiveserver value if needed in script on disk
|
||||||
|
sed -i'.bak' -e "s/TEMPARCHIVESERVER/$archiveserver/g" /etc/rc.local
|
||||||
|
|
||||||
|
# Start setup. This should take us all the way through to reboot
|
||||||
|
/root/bin/setup-teslausb
|
||||||
|
|
||||||
|
# reboot for good measure, also restarts the rc.local script
|
||||||
|
reboot
|
||||||
|
fi
|
||||||
|
|
||||||
|
LOGFILE=/tmp/rc.local.log
|
||||||
|
|
||||||
|
function log () {
|
||||||
|
echo "$( date ) ${1}" >> "$LOGFILE"
|
||||||
|
}
|
||||||
|
if [ -e "/root/bin/archiveloop" ]
|
||||||
|
then
|
||||||
|
log "Launching archival script..."
|
||||||
|
/root/bin/archiveloop TEMPARCHIVESERVER &
|
||||||
|
log "All done"
|
||||||
|
else
|
||||||
|
echo "Setup doesn't seem to have completed, there is no /root/bin/archiveloop."
|
||||||
|
echo "Try re-running /root/bin/setup-teslausb (re-downloading if needed),"
|
||||||
|
echo "or export HEADLESS=true and run /etc/rc.local if you want to run automatic setup."
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
0
pi-gen-sources/files/ssh
Normal file
0
pi-gen-sources/files/ssh
Normal file
34
pi-gen-sources/files/stage_flash
Normal file
34
pi-gen-sources/files/stage_flash
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
i=$1
|
||||||
|
flash_count=0
|
||||||
|
flash_count=$((i + 1 ))
|
||||||
|
|
||||||
|
function led_off () {
|
||||||
|
echo 1 | sudo tee /sys/class/leds/led0/brightness > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
function led_on () {
|
||||||
|
echo 0 | sudo tee /sys/class/leds/led0/brightness > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
function led_flash () {
|
||||||
|
led_on
|
||||||
|
sleep .2
|
||||||
|
led_off
|
||||||
|
}
|
||||||
|
|
||||||
|
function flash () {
|
||||||
|
local COUNTER=0
|
||||||
|
sleep 2
|
||||||
|
while [ ${COUNTER} -lt ${flash_count} ]
|
||||||
|
do
|
||||||
|
led_flash
|
||||||
|
let COUNTER=COUNTER+1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
flash
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
exit 0
|
||||||
43
pi-gen-sources/files/teslausb_setup_variables.conf.sample
Normal file
43
pi-gen-sources/files/teslausb_setup_variables.conf.sample
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#####################################################################
|
||||||
|
# SAMPLE CONFIGURATION FILE FOR TESLAUSB Pi Setup
|
||||||
|
#
|
||||||
|
# Example config file for teslausb_setup. Lines with "#" are comments/ignored.
|
||||||
|
# Remove the "#" before "export" to activate a line. Be sure to rename this file
|
||||||
|
# to "teslausb_setup_variables.conf" and place it in the "boot" folder of your
|
||||||
|
# SD card.
|
||||||
|
#
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
# Default variables for CIFS (Windows/Mac file sharing) setup
|
||||||
|
export archiveserver=your_archive_name_or_ip
|
||||||
|
export sharename=your_archive_share_name
|
||||||
|
export shareuser=username
|
||||||
|
export sharepassword=password
|
||||||
|
export campercent=100
|
||||||
|
|
||||||
|
# Wifi setup information
|
||||||
|
export SSID=your_ssid
|
||||||
|
export WIFIPASS=your_pass
|
||||||
|
|
||||||
|
# If doing a headless (i.e. automatic) setup
|
||||||
|
export HEADLESS_SETUP=true
|
||||||
|
|
||||||
|
# Uncomment if setting up Pushover push notifications
|
||||||
|
# export pushover_enabled=false
|
||||||
|
# export pushover_user_key=user_key
|
||||||
|
# export pushover_app_key=app_key
|
||||||
|
|
||||||
|
# Uncomment and change if you want setup scripts to be pulled
|
||||||
|
# from a different repo than the "main" github.com/cimryan/teslausb
|
||||||
|
# export REPO=cimryan
|
||||||
|
|
||||||
|
# Uncomment and change if you want a different branch than master
|
||||||
|
# export BRANCH=master
|
||||||
|
|
||||||
|
# Uncomment if you're using rsync/ssh for the archive.
|
||||||
|
# Note: RSYNC_ENABLE=true is going to disable the default archive server.
|
||||||
|
#
|
||||||
|
# export RSYNC_ENABLE=true
|
||||||
|
# export RSYNC_USER=<ftp username>
|
||||||
|
# export RSYNC_SERVER=<ftp IP/host>
|
||||||
|
# export RSYNC_PATH=<destination path to save in>
|
||||||
8
pi-gen-sources/files/wpa_supplicant.conf.sample
Normal file
8
pi-gen-sources/files/wpa_supplicant.conf.sample
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
|
||||||
|
update_config=1
|
||||||
|
|
||||||
|
network={
|
||||||
|
ssid="TEMPSSID"
|
||||||
|
psk="TEMPPASS"
|
||||||
|
key_mgmt=WPA-PSK
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user