• Reorganized the scripts into different categories
• Refactored the graphical boot screens to have separate boot and shutdown images • Changed the reboot and shutdown code to force the display of the splash images. • Added 'Team Onefinity.ngc' to the installer files
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
KERNEL!="sd[a-z]*", GOTO="automount_end"
|
||||
IMPORT{program}="/sbin/blkid -o udev -p %N"
|
||||
ENV{ID_FS_TYPE}=="", GOTO="automount_end"
|
||||
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
|
||||
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usb-%k"
|
||||
ACTION=="add", ENV{mount_options}="relatime"
|
||||
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002,sync"
|
||||
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}"
|
||||
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"
|
||||
LABEL="automount_end"
|
||||
@@ -1,2 +0,0 @@
|
||||
xterm*faceSize: 12
|
||||
xterm*faceName: DejaVu Sans Mono
|
||||
@@ -1,206 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import time
|
||||
import serial
|
||||
import binascii
|
||||
|
||||
|
||||
dev = '/dev/ttyAMA0'
|
||||
baud = 921600
|
||||
boot_id = 'bbctrl '
|
||||
verbose = False
|
||||
|
||||
|
||||
def crc16(data):
|
||||
crc = 0xffff
|
||||
|
||||
for x in data:
|
||||
crc = crc ^ int(x)
|
||||
for bit in range(8):
|
||||
if crc & 1: crc = (crc >> 1) ^ 0xa001
|
||||
else: crc = crc >> 1
|
||||
|
||||
return crc
|
||||
|
||||
|
||||
def avr_crc32(data, length):
|
||||
mem = [0xff] * length
|
||||
|
||||
for addr, chunk in data:
|
||||
for x in chunk:
|
||||
mem[addr] = x
|
||||
addr += 1
|
||||
|
||||
return binascii.crc32(bytes(mem))
|
||||
|
||||
|
||||
def read_intel_hex(f):
|
||||
base = 0
|
||||
pos = 0
|
||||
start = 0
|
||||
chunk = None
|
||||
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if not line or line[0] != ':': continue
|
||||
|
||||
count = int(line[1:3], 16)
|
||||
addr = int(line[3:7], 16)
|
||||
type = int(line[7:9], 16)
|
||||
data = line[9:-2]
|
||||
checksum = int(line[-2:], 16)
|
||||
|
||||
if type == 0:
|
||||
addr += base
|
||||
data = binascii.unhexlify(bytes(data, 'utf8'))
|
||||
|
||||
if chunk is None or pos != addr:
|
||||
if chunk is not None: yield (start, chunk)
|
||||
start = addr
|
||||
chunk = data
|
||||
|
||||
else: chunk += data
|
||||
|
||||
pos = addr + len(data)
|
||||
|
||||
if type == 2: base = int(data, 16) * 16
|
||||
|
||||
if chunk is not None: yield (start, chunk)
|
||||
|
||||
|
||||
def send(data):
|
||||
if verbose: print('Sending:', data)
|
||||
sp.write(bytes(data, 'utf8'))
|
||||
|
||||
|
||||
def send_int(x, size):
|
||||
if verbose: print('Sending: %d', x)
|
||||
sp.write((x).to_bytes(size, byteorder = 'big'))
|
||||
|
||||
|
||||
def recv(count):
|
||||
data = sp.read(count).decode('utf8')
|
||||
if count and verbose: print('Received:', data)
|
||||
return data
|
||||
|
||||
|
||||
def recv_int(size):
|
||||
x = int.from_bytes(sp.read(size), byteorder = 'big')
|
||||
if verbose: print('Received:', x)
|
||||
return x
|
||||
|
||||
|
||||
# Read firmware hex file
|
||||
data = list(read_intel_hex(open(sys.argv[1], 'r')))
|
||||
|
||||
# Open serial port
|
||||
sp = serial.Serial(dev, baud, timeout = 10)
|
||||
|
||||
# Reset AVR
|
||||
import RPi.GPIO as gpio
|
||||
gpio.setwarnings(False)
|
||||
gpio.setmode(gpio.BCM)
|
||||
gpio.setup(27, gpio.OUT)
|
||||
gpio.output(27, 0)
|
||||
gpio.output(27, 1)
|
||||
gpio.setup(27, gpio.IN, pull_up_down = gpio.PUD_UP)
|
||||
time.sleep(0.1)
|
||||
|
||||
# Sync
|
||||
for i in range(10): send('\x1b')
|
||||
|
||||
# Flush serial
|
||||
try:
|
||||
recv(sp.in_waiting)
|
||||
except: pass
|
||||
|
||||
# Get bootloader ID
|
||||
send('S')
|
||||
if boot_id != recv(len(boot_id)):
|
||||
raise Exception('Failed to communicate with bootloader')
|
||||
|
||||
# Get version
|
||||
send('V')
|
||||
major = int(recv(1))
|
||||
minor = int(recv(1))
|
||||
print('Bootloader version: %d.%d' % (major, minor))
|
||||
|
||||
# If bootloader is new enough compare checksums
|
||||
if 0 < major or 1 < minor:
|
||||
# Get flash length
|
||||
send('n')
|
||||
flash_len = recv_int(3)
|
||||
|
||||
# Get current flash CRC
|
||||
send('X')
|
||||
new_crc = avr_crc32(data, flash_len)
|
||||
old_crc = recv_int(4)
|
||||
if old_crc == new_crc:
|
||||
print('Flash already up to date')
|
||||
sys.exit(0)
|
||||
|
||||
print('CRC: old=0x%08x new=0x%08x' % (old_crc, new_crc))
|
||||
|
||||
# Erase
|
||||
send('e')
|
||||
if recv(1) != '\r': raise Exception('Flash erase failed')
|
||||
|
||||
# Get page size
|
||||
send('b')
|
||||
if recv(1) != 'Y': raise Exception('Cannot get page size')
|
||||
page_size = recv_int(2)
|
||||
print('Page size:', page_size)
|
||||
|
||||
|
||||
# Program
|
||||
print('Programming', end = '')
|
||||
count = 0
|
||||
retry = 0
|
||||
for addr, chunk in data:
|
||||
# Set address
|
||||
send('H')
|
||||
send_int(addr, 3)
|
||||
if recv(1) != '\r': raise Exception('Failed to set address')
|
||||
|
||||
while len(chunk):
|
||||
sys.stdout.flush()
|
||||
page = chunk[0:512]
|
||||
|
||||
# Block command
|
||||
send('B')
|
||||
|
||||
# Send block size
|
||||
send_int(len(page), 2)
|
||||
|
||||
# Send memory type
|
||||
send('F')
|
||||
|
||||
# Send block
|
||||
sp.write(page)
|
||||
|
||||
if recv(1) != '\r': raise Exception('Failed to write block')
|
||||
|
||||
# Get and check block CRC
|
||||
send('i')
|
||||
crc = recv_int(2)
|
||||
expect = crc16(page)
|
||||
if crc != expect:
|
||||
retry += 1
|
||||
if retry == 5:
|
||||
raise Exception('CRC mismatch %d != %d' % (crc, expect))
|
||||
|
||||
print('x', end = '')
|
||||
continue
|
||||
|
||||
count += len(page)
|
||||
chunk = chunk[512:]
|
||||
retry = 0
|
||||
print('.', end = '')
|
||||
|
||||
|
||||
print('done')
|
||||
print('Wrote %d bytes' % count)
|
||||
|
||||
# Exit bootloader
|
||||
send('E')
|
||||
@@ -1,8 +0,0 @@
|
||||
/var/log/bbctrl.log {
|
||||
rotate 4
|
||||
weekly
|
||||
compress
|
||||
missingok
|
||||
notifempty
|
||||
copytruncate
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
[Unit]
|
||||
Description=Buildbotics Controller
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=root
|
||||
ExecStart=/usr/local/bin/bbctrl -l /var/log/bbctrl.log
|
||||
WorkingDirectory=/var/lib/bbctrl
|
||||
Restart=always
|
||||
StandardOutput=null
|
||||
Nice=-10
|
||||
KillMode=process
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
|
||||
def enter_cgroup():
|
||||
with open('/sys/fs/cgroup/memory/chrome/tasks', 'w') as f:
|
||||
f.write(str(os.getpid()))
|
||||
|
||||
|
||||
# Start browser
|
||||
args = ['/usr/lib/chromium-browser/chromium-browser'] + sys.argv[1:]
|
||||
subprocess.Popen(args, preexec_fn = enter_cgroup).wait()
|
||||
@@ -1,262 +0,0 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
AP=false
|
||||
DISABLE=false
|
||||
SSID=
|
||||
PASS=
|
||||
CHANNEL=7
|
||||
REBOOT=false
|
||||
|
||||
WLAN0_CFG=/etc/network/interfaces.d/wlan0
|
||||
HOSTAPD_CFG=/etc/hostapd/hostapd.conf
|
||||
DNSMASQ_CFG=/etc/dnsmasq.conf
|
||||
DHCPCD_CFG=/etc/dhcpcd.conf
|
||||
WPA_CFG=/etc/wpa_supplicant/wpa_supplicant.conf
|
||||
|
||||
|
||||
function query_config() {
|
||||
if [ -e $WLAN0_CFG ]; then
|
||||
SSID=$(grep wpa-ssid $WLAN0_CFG |
|
||||
sed 's/^[[:space:]]*wpa-ssid "\([^"]*\)"/\1/')
|
||||
# echo "{\"ssid\": \"$SSID\", \"mode\": \"client\"}"
|
||||
echo "{\"ssid\": \"$SSID\"}"
|
||||
|
||||
else
|
||||
# if [ -e $HOSTAPD_CFG -a -e /etc/default/hostapd ]; then
|
||||
# SSID=$(grep ^ssid= $HOSTAPD_CFG | sed 's/^ssid=\(.*\)$/\1/')
|
||||
# CHANNEL=$(grep ^channel= $HOSTAPD_CFG |
|
||||
# sed 's/^channel=\(.*\)$/\1/')
|
||||
|
||||
# echo -n "{\"ssid\": \"$SSID\", "
|
||||
# echo "\"channel\": $CHANNEL, \"mode\": \"ap\"}"
|
||||
|
||||
# else
|
||||
# echo "{\"mode\": \"disabled\"}"
|
||||
# fi
|
||||
|
||||
echo "{}"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
function disable_wifi() {
|
||||
rm -f $WLAN0_CFG $HOSTAPD_CFG /etc/default/hostapd
|
||||
}
|
||||
|
||||
|
||||
function configure_wlan0() {
|
||||
echo "auto wlan0"
|
||||
echo "allow-hotplug wlan0"
|
||||
echo "iface wlan0 inet dhcp"
|
||||
echo " wpa-scan-ssid 1"
|
||||
echo " wpa-ap-scan 1"
|
||||
echo " wpa-key-mgmt WPA-PSK"
|
||||
echo " wpa-proto RSN WPA"
|
||||
echo " wpa-pairwise CCMP TKIP"
|
||||
echo " wpa-group CCMP TKIP"
|
||||
echo " wpa-ssid \"$SSID\""
|
||||
|
||||
if [ ${#PASS} -ne 0 ]; then
|
||||
echo " wpa-psk \"$PASS\""
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function configure_wpa() {
|
||||
echo "country=US"
|
||||
echo "ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev"
|
||||
echo "update_config=1"
|
||||
|
||||
if [ ${#PASS} -eq 0 ]; then
|
||||
echo "network={"
|
||||
echo " ssid=\"$SSID\""
|
||||
echo " key_mgmt=NONE"
|
||||
echo "}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function configure_dhcpcd() {
|
||||
echo "hostname"
|
||||
echo "clientid"
|
||||
echo "persistent"
|
||||
echo "option rapid_commit"
|
||||
echo "option domain_name_servers, domain_name, domain_search, host_name"
|
||||
echo "option classless_static_routes"
|
||||
echo "option ntp_servers"
|
||||
echo "option interface_mtu"
|
||||
echo "require dhcp_server_identifier"
|
||||
echo "slaac private"
|
||||
|
||||
if $AP; then
|
||||
echo
|
||||
echo "interface wlan0"
|
||||
echo " static ip_address=192.168.43.1/24"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function configure_wifi() {
|
||||
disable_wifi
|
||||
echo "source-directory /etc/network/interfaces.d" > /etc/network/interfaces
|
||||
configure_wlan0 > $WLAN0_CFG
|
||||
configure_wpa > $WPA_CFG
|
||||
configure_dhcpcd > $DHCPCD_CFG
|
||||
}
|
||||
|
||||
|
||||
function configure_dnsmasq() {
|
||||
echo "interface=wlan0"
|
||||
echo "domain-needed"
|
||||
echo "bogus-priv"
|
||||
echo "dhcp-range=192.168.43.2,192.168.43.20,255.255.255.0,12h"
|
||||
}
|
||||
|
||||
|
||||
function configure_hostapd() {
|
||||
echo "interface=wlan0"
|
||||
echo "driver=nl80211"
|
||||
echo "ssid=$SSID"
|
||||
echo "hw_mode=g"
|
||||
echo "channel=$CHANNEL"
|
||||
echo "wmm_enabled=0"
|
||||
echo "macaddr_acl=0"
|
||||
echo "auth_algs=1"
|
||||
echo "ignore_broadcast_ssid=0"
|
||||
echo "wpa=2"
|
||||
echo "wpa_passphrase=$PASS"
|
||||
echo "wpa_key_mgmt=WPA-PSK"
|
||||
echo "wpa_pairwise=TKIP"
|
||||
echo "rsn_pairwise=CCMP"
|
||||
}
|
||||
|
||||
|
||||
function is_installed() {
|
||||
dpkg-query -W --showformat='${Status}' $1 |
|
||||
grep "install ok installed" >/dev/null
|
||||
if [ $? -eq 0 ]; then echo true; else echo false; fi
|
||||
}
|
||||
|
||||
|
||||
function configure_ap() {
|
||||
disable_wifi
|
||||
|
||||
# Install packages
|
||||
(
|
||||
$(is_installed dnsmasq) &&
|
||||
$(is_installed hostapd) &&
|
||||
$(is_installed iptables-persistent)
|
||||
|
||||
) || (
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update
|
||||
apt-get install -yq dnsmasq hostapd iptables-persistent
|
||||
)
|
||||
|
||||
configure_dhcpcd > $DHCPCD_CFG
|
||||
configure_dnsmasq > $DNSMASQ_CFG
|
||||
configure_hostapd > $HOSTAPD_CFG
|
||||
|
||||
echo "DAEMON_CONF=\"/etc/hostapd/hostapd.conf\"" > /etc/default/hostapd
|
||||
|
||||
# Enable IP forwarding
|
||||
sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/' /etc/sysctl.conf
|
||||
echo 1 > /proc/sys/net/ipv4/ip_forward
|
||||
|
||||
# Enable IP masquerading
|
||||
iptables -t nat -F
|
||||
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
||||
iptables-save > /etc/iptables/rules.v4
|
||||
}
|
||||
|
||||
|
||||
function usage() {
|
||||
echo "Usage: config-wifi [OPTIONS]"
|
||||
echo
|
||||
echo "Configure wifi as either a client or access point."
|
||||
echo
|
||||
echo "OPTIONS:"
|
||||
echo
|
||||
echo " -a Configure access point."
|
||||
echo " -d Disable wifi."
|
||||
echo " -r Reboot when done."
|
||||
echo " -s <SSID> Set SSID."
|
||||
echo " -p <PASS> Set password."
|
||||
echo " -c <CHANNEL> Set wifi channel."
|
||||
echo " -j Report wifi config as JSON data."
|
||||
echo
|
||||
}
|
||||
|
||||
|
||||
# Parse args
|
||||
while [ $# -ne 0 ]; do
|
||||
case "$1" in
|
||||
-a) AP=true ;;
|
||||
-d) DISABLE=true ;;
|
||||
-r) REBOOT=true; ;;
|
||||
-s) SSID="$2"; shift ;;
|
||||
-p) PASS="$2"; shift ;;
|
||||
-c) CHANNEL="$2"; shift ;;
|
||||
-j) query_config; exit 0 ;;
|
||||
|
||||
-h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
|
||||
*)
|
||||
usage
|
||||
echo "Unknown argument '$1'"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
if $DISABLE; then
|
||||
disable_wifi
|
||||
|
||||
else
|
||||
# Check args
|
||||
function clean_str() {
|
||||
echo "$1" | tr -d '\n\r"'
|
||||
}
|
||||
|
||||
SSID=$(clean_str "$SSID")
|
||||
PASS=$(clean_str "$PASS")
|
||||
|
||||
LANG=C LC_ALL=C # For correct string byte length
|
||||
|
||||
if [ ${#SSID} -eq 0 -o 32 -lt ${#SSID} ]; then
|
||||
echo "Invalid or missing SSID '$SSID'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ${#PASS} -ne 0 ]; then
|
||||
if [ ${#PASS} -lt 8 -o 128 -lt ${#PASS} ]; then
|
||||
echo "Invalid passsword"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$CHANNEL" | grep '^[0-9]\{1,2\}' > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Invalid channel '$CHANNEL'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Execute
|
||||
if $AP; then
|
||||
echo "Configuring Wifi access point"
|
||||
configure_ap
|
||||
|
||||
else
|
||||
echo "Configuring Wifi"
|
||||
configure_wifi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if $REBOOT; then nohup reboot & fi
|
||||
@@ -1,259 +0,0 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
AP=false
|
||||
DISABLE=false
|
||||
SSID=
|
||||
PASS=
|
||||
CHANNEL=7
|
||||
REBOOT=false
|
||||
|
||||
WLAN0_CFG=/etc/network/interfaces.d/wlan0
|
||||
HOSTAPD_CFG=/etc/hostapd/hostapd.conf
|
||||
DNSMASQ_CFG=/etc/dnsmasq.conf
|
||||
DHCPCD_CFG=/etc/dhcpcd.conf
|
||||
WPA_CFG=/etc/wpa_supplicant/wpa_supplicant.conf
|
||||
|
||||
|
||||
function query_config() {
|
||||
if [ -e $WLAN0_CFG ]; then
|
||||
SSID=$(grep wpa-ssid $WLAN0_CFG |
|
||||
sed 's/^[[:space:]]*wpa-ssid "\([^"]*\)"/\1/')
|
||||
echo "{\"ssid\": \"$SSID\", \"mode\": \"client\"}"
|
||||
|
||||
else
|
||||
if [ -e $HOSTAPD_CFG -a -e /etc/default/hostapd ]; then
|
||||
SSID=$(grep ^ssid= $HOSTAPD_CFG | sed 's/^ssid=\(.*\)$/\1/')
|
||||
CHANNEL=$(grep ^channel= $HOSTAPD_CFG |
|
||||
sed 's/^channel=\(.*\)$/\1/')
|
||||
|
||||
echo -n "{\"ssid\": \"$SSID\", "
|
||||
echo "\"channel\": $CHANNEL, \"mode\": \"ap\"}"
|
||||
|
||||
else
|
||||
echo "{\"mode\": \"disabled\"}"
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
function disable_wifi() {
|
||||
rm -f $WLAN0_CFG $HOSTAPD_CFG /etc/default/hostapd
|
||||
}
|
||||
|
||||
|
||||
function configure_wlan0() {
|
||||
echo "auto wlan0"
|
||||
echo "allow-hotplug wlan0"
|
||||
echo "iface wlan0 inet dhcp"
|
||||
echo " wpa-scan-ssid 1"
|
||||
echo " wpa-ap-scan 1"
|
||||
echo " wpa-key-mgmt WPA-PSK"
|
||||
echo " wpa-proto RSN WPA"
|
||||
echo " wpa-pairwise CCMP TKIP"
|
||||
echo " wpa-group CCMP TKIP"
|
||||
echo " wpa-ssid \"$SSID\""
|
||||
|
||||
if [ ${#PASS} -ne 0 ]; then
|
||||
echo " wpa-psk \"$PASS\""
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function configure_wpa() {
|
||||
echo "country=US"
|
||||
echo "ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev"
|
||||
echo "update_config=1"
|
||||
|
||||
if [ ${#PASS} -eq 0 ]; then
|
||||
echo "network={"
|
||||
echo " ssid=\"$SSID\""
|
||||
echo " key_mgmt=NONE"
|
||||
echo "}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function configure_dhcpcd() {
|
||||
echo "hostname"
|
||||
echo "clientid"
|
||||
echo "persistent"
|
||||
echo "option rapid_commit"
|
||||
echo "option domain_name_servers, domain_name, domain_search, host_name"
|
||||
echo "option classless_static_routes"
|
||||
echo "option ntp_servers"
|
||||
echo "option interface_mtu"
|
||||
echo "require dhcp_server_identifier"
|
||||
echo "slaac private"
|
||||
|
||||
if $AP; then
|
||||
echo
|
||||
echo "interface wlan0"
|
||||
echo " static ip_address=192.168.43.1/24"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function configure_wifi() {
|
||||
disable_wifi
|
||||
echo "source-directory /etc/network/interfaces.d" > /etc/network/interfaces
|
||||
configure_wlan0 > $WLAN0_CFG
|
||||
configure_wpa > $WPA_CFG
|
||||
configure_dhcpcd > $DHCPCD_CFG
|
||||
}
|
||||
|
||||
|
||||
function configure_dnsmasq() {
|
||||
echo "interface=wlan0"
|
||||
echo "domain-needed"
|
||||
echo "bogus-priv"
|
||||
echo "dhcp-range=192.168.43.2,192.168.43.20,255.255.255.0,12h"
|
||||
}
|
||||
|
||||
|
||||
function configure_hostapd() {
|
||||
echo "interface=wlan0"
|
||||
echo "driver=nl80211"
|
||||
echo "ssid=$SSID"
|
||||
echo "hw_mode=g"
|
||||
echo "channel=$CHANNEL"
|
||||
echo "wmm_enabled=0"
|
||||
echo "macaddr_acl=0"
|
||||
echo "auth_algs=1"
|
||||
echo "ignore_broadcast_ssid=0"
|
||||
echo "wpa=2"
|
||||
echo "wpa_passphrase=$PASS"
|
||||
echo "wpa_key_mgmt=WPA-PSK"
|
||||
echo "wpa_pairwise=TKIP"
|
||||
echo "rsn_pairwise=CCMP"
|
||||
}
|
||||
|
||||
|
||||
function is_installed() {
|
||||
dpkg-query -W --showformat='${Status}' $1 |
|
||||
grep "install ok installed" >/dev/null
|
||||
if [ $? -eq 0 ]; then echo true; else echo false; fi
|
||||
}
|
||||
|
||||
|
||||
function configure_ap() {
|
||||
disable_wifi
|
||||
|
||||
# Install packages
|
||||
(
|
||||
$(is_installed dnsmasq) &&
|
||||
$(is_installed hostapd) &&
|
||||
$(is_installed iptables-persistent)
|
||||
|
||||
) || (
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update
|
||||
apt-get install -yq dnsmasq hostapd iptables-persistent
|
||||
)
|
||||
|
||||
configure_dhcpcd > $DHCPCD_CFG
|
||||
configure_dnsmasq > $DNSMASQ_CFG
|
||||
configure_hostapd > $HOSTAPD_CFG
|
||||
|
||||
echo "DAEMON_CONF=\"/etc/hostapd/hostapd.conf\"" > /etc/default/hostapd
|
||||
|
||||
# Enable IP forwarding
|
||||
sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/' /etc/sysctl.conf
|
||||
echo 1 > /proc/sys/net/ipv4/ip_forward
|
||||
|
||||
# Enable IP masquerading
|
||||
iptables -t nat -F
|
||||
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
||||
iptables-save > /etc/iptables/rules.v4
|
||||
}
|
||||
|
||||
|
||||
function usage() {
|
||||
echo "Usage: config-wifi [OPTIONS]"
|
||||
echo
|
||||
echo "Configure wifi as either a client or access point."
|
||||
echo
|
||||
echo "OPTIONS:"
|
||||
echo
|
||||
echo " -a Configure access point."
|
||||
echo " -d Disable wifi."
|
||||
echo " -r Reboot when done."
|
||||
echo " -s <SSID> Set SSID."
|
||||
echo " -p <PASS> Set password."
|
||||
echo " -c <CHANNEL> Set wifi channel."
|
||||
echo " -j Report wifi config as JSON data."
|
||||
echo
|
||||
}
|
||||
|
||||
|
||||
# Parse args
|
||||
while [ $# -ne 0 ]; do
|
||||
case "$1" in
|
||||
-a) AP=true ;;
|
||||
-d) DISABLE=true ;;
|
||||
-r) REBOOT=true; ;;
|
||||
-s) SSID="$2"; shift ;;
|
||||
-p) PASS="$2"; shift ;;
|
||||
-c) CHANNEL="$2"; shift ;;
|
||||
-j) query_config; exit 0 ;;
|
||||
|
||||
-h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
|
||||
*)
|
||||
usage
|
||||
echo "Unknown argument '$1'"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
if $DISABLE; then
|
||||
disable_wifi
|
||||
|
||||
else
|
||||
# Check args
|
||||
function clean_str() {
|
||||
echo "$1" | tr -d '\n\r"'
|
||||
}
|
||||
|
||||
SSID=$(clean_str "$SSID")
|
||||
PASS=$(clean_str "$PASS")
|
||||
|
||||
LANG=C LC_ALL=C # For correct string byte length
|
||||
|
||||
if [ ${#SSID} -eq 0 -o 32 -lt ${#SSID} ]; then
|
||||
echo "Invalid or missing SSID '$SSID'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ${#PASS} -ne 0 ]; then
|
||||
if [ ${#PASS} -lt 8 -o 128 -lt ${#PASS} ]; then
|
||||
echo "Invalid passsword"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$CHANNEL" | grep '^[0-9]\{1,2\}' > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Invalid channel '$CHANNEL'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Execute
|
||||
if $AP; then
|
||||
echo "Configuring Wifi access point"
|
||||
configure_ap
|
||||
|
||||
else
|
||||
echo "Configuring Wifi"
|
||||
configure_wifi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if $REBOOT; then nohup reboot & fi
|
||||
@@ -1 +0,0 @@
|
||||
@reboot root run-parts /etc/cron.reboot
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
test -x /usr/sbin/logrotate || exit 0
|
||||
/usr/sbin/logrotate /etc/logrotate.conf
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
import sqlite3
|
||||
|
||||
db = sqlite3.connect('/home/pi/.config/chromium/Default/Cookies')
|
||||
cur = db.cursor()
|
||||
cur.execute("DELETE FROM cookies WHERE creation_utc < 13240000000000000")
|
||||
db.commit()
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash -ex
|
||||
|
||||
pip3 download -d python-packages -r requirements.txt
|
||||
pip3 download -d installer/python-packages -r requirements.txt
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
cp /boot/config.txt /tmp/
|
||||
|
||||
edit-config /tmp/config.txt "$@"
|
||||
|
||||
diff /boot/config.txt /tmp/config.txt >/dev/null
|
||||
if [ $? -eq 1 ]; then
|
||||
mount -o remount,rw /boot
|
||||
mv /tmp/config.txt /boot/
|
||||
mount -o remount,ro /boot
|
||||
fi
|
||||
@@ -1,83 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
import re
|
||||
|
||||
|
||||
def option_type(s, pat = re.compile(r'\w+=.*')):
|
||||
if not pat.match(s): raise argparse.ArgumentTypeError
|
||||
return s
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description = 'Edit config file.')
|
||||
parser.add_argument('config', help = 'The configuration file to edit.')
|
||||
parser.add_argument('options', nargs = '*', type = option_type,
|
||||
metavar = '<name>=<value>', help = 'An option to set.')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
# Parse config lines and options
|
||||
lines = []
|
||||
options = {}
|
||||
optRE = re.compile(r'(\w+)\s*=\s*([^#]+)(#.*)?')
|
||||
|
||||
|
||||
class Line:
|
||||
def __init__(self, text, name = None, value = None, comment = None):
|
||||
self.text = text
|
||||
self.name = name
|
||||
self.value = value
|
||||
self.comment = comment
|
||||
|
||||
|
||||
def __str__(self):
|
||||
if self.name is not None:
|
||||
if self.value.strip():
|
||||
text = '%s=%s' % (self.name, self.value)
|
||||
if self.comment: text += ' # ' + self.comment
|
||||
text += '\n'
|
||||
return text
|
||||
|
||||
else: return ''
|
||||
|
||||
return self.text
|
||||
|
||||
|
||||
with open(args.config, 'r') as f:
|
||||
for line in f:
|
||||
m = optRE.match(line.strip())
|
||||
|
||||
if m: name, value, comment = m.groups()
|
||||
else: name, value, comment = None, None, None
|
||||
|
||||
l = Line(line, name, value, comment)
|
||||
lines.append(l)
|
||||
if name is not None: options[name] = l
|
||||
|
||||
|
||||
# Save original config
|
||||
config = ''.join(map(str, lines))
|
||||
|
||||
|
||||
# Set options
|
||||
first = True
|
||||
for opt in args.options:
|
||||
name, value = opt.split('=', 1)
|
||||
|
||||
if name in options: options[name].value = value
|
||||
else:
|
||||
if first and len(lines) and str(lines[:-1]).strip() != '':
|
||||
first = False
|
||||
lines.append(Line('\n'))
|
||||
|
||||
lines.append(Line(None, name, value, None))
|
||||
|
||||
|
||||
# Assemble new config
|
||||
new_config = ''.join(map(str, lines))
|
||||
|
||||
|
||||
if new_config != config:
|
||||
with open(args.config, 'w') as f:
|
||||
f.write(new_config)
|
||||
@@ -12,39 +12,41 @@ while [ $# -gt 0 ]; do
|
||||
shift 1
|
||||
done
|
||||
|
||||
|
||||
if $UPDATE_PY; then
|
||||
systemctl stop bbctrl
|
||||
|
||||
# Update service
|
||||
rm -f /etc/init.d/bbctrl
|
||||
cp scripts/bbctrl.service /etc/systemd/system/
|
||||
cp ./installer/config/bbctrl.service /etc/systemd/system/
|
||||
systemctl daemon-reload
|
||||
systemctl enable bbctrl
|
||||
fi
|
||||
|
||||
if $UPDATE_AVR; then
|
||||
chmod +x ./scripts/avr109-flash.py
|
||||
./scripts/avr109-flash.py src/avr/bbctrl-avr-firmware.hex
|
||||
chmod +x ./installer/scripts/avr109-flash.py
|
||||
./installer/scripts/avr109-flash.py src/avr/bbctrl-avr-firmware.hex
|
||||
fi
|
||||
|
||||
# Update config.txt
|
||||
./scripts/edit-boot-config max_usb_current=1 config_hdmi_boost=8 hdmi_force_hotplug=1 hdmi_group=2 hdmi_mode=82
|
||||
./installer/scripts/edit-boot-config \
|
||||
disable_overscan=1 \
|
||||
framebuffer_width=1280 \
|
||||
framebuffer_height=720 \
|
||||
nohz=on \
|
||||
dtparam=sd_overclock=100 \
|
||||
max_usb_current=1 \
|
||||
config_hdmi_boost=8 \
|
||||
disable_splash=1 \
|
||||
hdmi_force_hotplug=1 \
|
||||
hdmi_group=2 \
|
||||
hdmi_mode=82
|
||||
|
||||
# TODO Enable GPU
|
||||
#./scripts/edit-boot-config dtoverlay=vc4-kms-v3d
|
||||
#./scripts/edit-boot-config gpu_mem=16
|
||||
#./installer/scripts/edit-boot-config \
|
||||
# dtoverlay=vc4-kms-v3d \
|
||||
# gpu_mem=16
|
||||
#chmod ug+s /usr/lib/xorg/Xorg
|
||||
|
||||
# Use the full screen resolution
|
||||
# grep "^framebuffer_width=1280$" /boot/config.txt >/dev/null
|
||||
# if [ $? -eq 0 ]; then
|
||||
# mount -o remount,rw /boot &&
|
||||
# sed -i 's/^\(framebuffer_.*\)$/#\1/g' /boot/config.txt
|
||||
# mount -o remount,ro /boot
|
||||
# REBOOT=true
|
||||
# fi
|
||||
|
||||
# Fix camera
|
||||
grep dwc_otg.fiq_fsm_mask /boot/cmdline.txt >/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
@@ -73,14 +75,20 @@ sed -i 's/^TimeoutStartSec=.*$/TimeoutStartSec=1/' \
|
||||
/etc/systemd/system/network-online.target.wants/networking.service
|
||||
|
||||
# Change to US keyboard layout
|
||||
sed -i 's/^XKBLAYOUT="gb"$/XKBLAYOUT="us" # Comment stops change on upgrade/' \
|
||||
/etc/default/keyboard
|
||||
sed -i 's/^XKBLAYOUT="gb"$/XKBLAYOUT="us" # Comment stops change on upgrade/' /etc/default/keyboard
|
||||
|
||||
# Set the default locale to en_US
|
||||
grep '^en_US.UTF-8 UTF-8' /etc/locale.gen >/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
perl -pi -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen
|
||||
locale-gen en_US.UTF-8
|
||||
update-locale en_US.UTF-8
|
||||
fi
|
||||
|
||||
# Setup USB stick automount
|
||||
diff ./scripts/11-automount.rules /etc/udev/rules.d/11-automount.rules \
|
||||
>/dev/null
|
||||
diff ./installer/config/11-automount.rules /etc/udev/rules.d/11-automount.rules >/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
cp ./scripts/11-automount.rules /etc/udev/rules.d/
|
||||
cp ./installer/config/11-automount.rules /etc/udev/rules.d/
|
||||
sed -i 's/^\(MountFlags=slave\)/#\1/' \
|
||||
/lib/systemd/system/systemd-udevd.service
|
||||
REBOOT=true
|
||||
@@ -93,28 +101,31 @@ if [ $? -ne 0 ]; then
|
||||
REBOOT=true
|
||||
fi
|
||||
|
||||
# Set the default locale to en_US
|
||||
grep '^en_US.UTF-8 UTF-8' /etc/locale.gen >/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
perl -pi -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen
|
||||
locale-gen en_US.UTF-8
|
||||
update-locale en_US.UTF-8
|
||||
fi
|
||||
|
||||
# Install .Xresources & .xinitrc
|
||||
cp scripts/Xresources ~pi/.Xresources
|
||||
cp ./installer/config/Xresources ~pi/.Xresources
|
||||
chown pi:pi ~pi/.Xresources
|
||||
cp scripts/xinitrc ~pi/.xinitrc
|
||||
cp ./installer/config/xinitrc ~pi/.xinitrc
|
||||
chmod +x ~pi/.xinitrc
|
||||
chown pi:pi ~pi/.xinitrc
|
||||
|
||||
#Configure the "ratpoison" window manager
|
||||
# Configure the "ratpoison" window manager
|
||||
if [ ! -e ~pi/.ratpoisonrc ]; then
|
||||
cp scripts/ratpoisonrc ~pi/.ratpoisonrc
|
||||
cp ./installer/config/ratpoisonrc ~pi/.ratpoisonrc
|
||||
chmod 644 ~pi/.ratpoisonrc
|
||||
chown pi:pi ~pi/.ratpoisonrc
|
||||
fi
|
||||
|
||||
# Configure the Plymouth graphical bootloader with the Onefinity theme
|
||||
if [ ! -e /usr/share/plymouth/themes/onefinity/onefinity.plymouth ]; then
|
||||
mkdir -p /usr/share/plymouth/themes/onefinity/
|
||||
cp -av installer/splash/* /usr/share/plymouth/themes/onefinity/
|
||||
plymouth-set-default-theme -R onefinity
|
||||
fi
|
||||
grep 'quiet splash plymouth.ignore-serial-consoles logo.nologo' /boot/cmdline.txt >/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -n " quiet splash plymouth.ignore-serial-consoles logo.nologo" >> /boot/cmdline.txt
|
||||
fi
|
||||
|
||||
# Install bbserial
|
||||
MODSRC=src/bbserial/bbserial.ko
|
||||
MODDST=/lib/modules/$(uname -r)/kernel/drivers/tty/serial/bbserial.ko
|
||||
@@ -126,7 +137,7 @@ if [ $? -ne 0 ]; then
|
||||
fi
|
||||
|
||||
# Install rc.local
|
||||
cp scripts/rc.local /etc/
|
||||
cp ./installer/config/rc.local /etc/
|
||||
|
||||
# Install bbctrl
|
||||
if $UPDATE_PY; then
|
||||
@@ -135,7 +146,7 @@ if $UPDATE_PY; then
|
||||
rm -rf /usr/local/lib/python*/dist-packages/bbctrl-*
|
||||
|
||||
# Ensure python dependencies are installed
|
||||
pip3 install --no-index --find-links python-packages -r requirements.txt
|
||||
pip3 install --no-index --find-links installer/python-packages -r requirements.txt
|
||||
|
||||
./setup.py install --force
|
||||
|
||||
@@ -146,26 +157,26 @@ if $UPDATE_PY; then
|
||||
fi
|
||||
|
||||
# Expand the file system if necessary
|
||||
chmod +x ./scripts/resize_root_fs.sh
|
||||
./scripts/resize_root_fs.sh
|
||||
chmod +x ./installer/scripts/resize_root_fs.sh
|
||||
./installer/scripts/resize_root_fs.sh
|
||||
if [ $? -eq 0 ]; then
|
||||
REBOOT=true
|
||||
fi
|
||||
|
||||
# Install our logrotate config
|
||||
cp ./scripts/bbctrl-logrotate /etc/logrotate.d/bbctrl
|
||||
cp ./installer/config/bbctrl-logrotate /etc/logrotate.d/bbctrl
|
||||
chown root:root /etc/logrotate.d/bbctrl
|
||||
|
||||
# Ensure logrotate runs on every boot (for systems with no network, thus bad clock)
|
||||
if [ ! -e /etc/cron.d/reboot ]; then
|
||||
cp ./scripts/cron_d_reboot /etc/cron.d/reboot
|
||||
cp ./installer/config/cron_d_reboot /etc/cron.d/reboot
|
||||
mkdir -p /etc/cron.reboot
|
||||
cp ./scripts/cron_reboot_logrotate /etc/cron.reboot/logrotate
|
||||
cp ./installer/config/cron_reboot_logrotate /etc/cron.reboot/logrotate
|
||||
fi
|
||||
|
||||
# Delete some cookies that were left behind in older images
|
||||
chmod +x ./scripts/delete-cookies.py
|
||||
./scripts/delete-cookies.py
|
||||
chmod +x ./installer/scripts/delete-cookies.py
|
||||
./installer/scripts/delete-cookies.py
|
||||
pkill -HUP chromium # Force Chromium to restart, to see the cookie changes
|
||||
|
||||
# Get rid of some old files that were left behind in older images
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
startup_message off
|
||||
set bgcolor black
|
||||
set fgcolor white
|
||||
|
||||
unbind c
|
||||
bind c exec x-terminal-emulator -fg white -bg black
|
||||
bind C-c exec x-terminal-emulator -fg white -bg black
|
||||
@@ -1,31 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Mount /boot read only
|
||||
mount -o remount,ro /boot
|
||||
|
||||
# Load bbserial
|
||||
echo 3f201000.serial > /sys/bus/amba/drivers/uart-pl011/unbind
|
||||
modprobe -r bbserial
|
||||
modprobe bbserial
|
||||
|
||||
# Set SPI GPIO mode
|
||||
gpio mode 27 alt3
|
||||
|
||||
# Create browser memory limited cgroup
|
||||
if [ -d sys/fs/cgroup/memory ]; then
|
||||
CGROUP=/sys/fs/cgroup/memory/chrome
|
||||
mkdir $CGROUP
|
||||
chown -R pi:pi $CGROUP
|
||||
echo 650000000 > $CGROUP/memory.soft_limit_in_bytes
|
||||
echo 750000000 > $CGROUP/memory.limit_in_bytes
|
||||
fi
|
||||
|
||||
# Reload udev
|
||||
/etc/init.d/udev restart
|
||||
|
||||
# Stop boot splash so it doesn't interfere with X if GPU enabled and to save CPU
|
||||
plymouth quit
|
||||
|
||||
# Start X in /home/pi
|
||||
cd /home/pi
|
||||
sudo -u pi startx
|
||||
@@ -1,25 +0,0 @@
|
||||
#!/bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: resize2fs_once
|
||||
# Required-Start:
|
||||
# Required-Stop:
|
||||
# Default-Start: 3
|
||||
# Default-Stop:
|
||||
# Short-Description: Resize the root filesystem to fill partition
|
||||
# Description:
|
||||
### END INIT INFO
|
||||
. /lib/lsb/init-functions
|
||||
case "$1" in
|
||||
start)
|
||||
log_daemon_msg "Starting resize2fs_once"
|
||||
ROOT_DEV=$(findmnt / -o source -n) &&
|
||||
resize2fs $ROOT_DEV &&
|
||||
update-rc.d resize2fs_once remove &&
|
||||
rm /etc/init.d/resize2fs_once &&
|
||||
log_end_msg $?
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 start" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
@@ -1,79 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Used by the OneFinity firmware to determine if the root filesystem
|
||||
# needs to be enlarged to maximize usage of the SD card.
|
||||
#
|
||||
# The majority of this code originates from /usr/lib/raspi-config/init_resize.sh
|
||||
|
||||
get_fs_resize_variables () {
|
||||
ROOT_PART_DEV=$(findmnt / -o source -n)
|
||||
ROOT_PART_NAME=$(echo "$ROOT_PART_DEV" | cut -d "/" -f 3)
|
||||
ROOT_DEV_NAME=$(echo /sys/block/*/"${ROOT_PART_NAME}" | cut -d "/" -f 4)
|
||||
ROOT_DEV="/dev/${ROOT_DEV_NAME}"
|
||||
ROOT_PART_NUM=$(cat "/sys/block/${ROOT_DEV_NAME}/${ROOT_PART_NAME}/partition")
|
||||
BOOT_PART_DEV=$(findmnt /boot -o source -n)
|
||||
BOOT_PART_NAME=$(echo "$BOOT_PART_DEV" | cut -d "/" -f 3)
|
||||
BOOT_DEV_NAME=$(echo /sys/block/*/"${BOOT_PART_NAME}" | cut -d "/" -f 4)
|
||||
ROOT_DEV_SIZE=$(cat "/sys/block/${ROOT_DEV_NAME}/size")
|
||||
TARGET_END=$((ROOT_DEV_SIZE - 1))
|
||||
PARTITION_TABLE=$(parted -m "$ROOT_DEV" unit s print | tr -d 's')
|
||||
LAST_PART_NUM=$(echo "$PARTITION_TABLE" | tail -n 1 | cut -d ":" -f 1)
|
||||
ROOT_PART_LINE=$(echo "$PARTITION_TABLE" | grep -e "^${ROOT_PART_NUM}:")
|
||||
ROOT_PART_END=$(echo "$ROOT_PART_LINE" | cut -d ":" -f 3)
|
||||
}
|
||||
|
||||
should_resize_root_partition() {
|
||||
get_fs_resize_variables
|
||||
|
||||
if [ "$BOOT_DEV_NAME" != "$ROOT_DEV_NAME" ]; then
|
||||
FAIL_REASON="Boot and root partitions are on different devices"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ "$ROOT_PART_NUM" -ne "$LAST_PART_NUM" ]; then
|
||||
FAIL_REASON="Root partition should be last partition"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ "$ROOT_PART_END" -gt "$TARGET_END" ]; then
|
||||
FAIL_REASON="Root partition runs past the end of device"
|
||||
echo $FAIL_REASON
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! -b "$ROOT_DEV" ] || [ ! -b "$ROOT_PART_DEV" ] || [ ! -b "$BOOT_PART_DEV" ] ; then
|
||||
FAIL_REASON="Could not determine partitions"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ "$ROOT_PART_END" -eq "$TARGET_END" ]; then
|
||||
FAIL_REASON="Root partition is already expanded"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
if should_resize_root_partition; then
|
||||
grep "init_resize" /boot/cmdline.txt >/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
# On the next boot, init_resize.sh will:
|
||||
# Resize the root partition to use the rest of the SD card
|
||||
# Remove itself from /boot/cmdline.txt
|
||||
# Reboot the machine
|
||||
sudo mount /boot -o rw,remount
|
||||
sed -i 's/\(.*\)/\1 init=\/usr\/lib\/raspi-config\/init_resize.sh/' /boot/cmdline.txt
|
||||
fi
|
||||
|
||||
# On the first boot after init_resize, resize2fs_once will:
|
||||
# Resize the root fs to fill its partition
|
||||
# Remove itself from the registered systemd services
|
||||
# Delete itself from the filesystem
|
||||
# Therefore, never run again
|
||||
cp scripts/resize2fs_once /etc/init.d/resize2fs_once
|
||||
chmod +x /etc/init.d/resize2fs_once
|
||||
systemctl enable resize2fs_once
|
||||
|
||||
exit 0
|
||||
else
|
||||
echo "Not resizing root partition: $FAIL_REASON"
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,26 +0,0 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
HOSTNAME="$(echo "$1" | tr '[:upper:]' '[:lower:]')"
|
||||
|
||||
if [ "$HOSTNAME" == "" ]; then
|
||||
echo "Usage: $0 <hostname>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$HOSTNAME" == "localhost" ]; then
|
||||
echo "Cannot set hostname to 'localhost'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$HOSTNAME" =~ ^.*\.local$ ]; then
|
||||
echo "Hostname cannot end with '.local'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! "$HOSTNAME" =~ ^[a-zA-Z][a-zA-Z0-9-]{0,62}$ ]]; then
|
||||
echo "Invalid hostname '$HOSTNAME'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sed -i "s/^127.0.1.1\([[:space:]]*\).*$/127.0.1.1\1$HOSTNAME/" /etc/hosts
|
||||
echo "$HOSTNAME" > /etc/hostname
|
||||
@@ -1,27 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
(
|
||||
flock -n 9
|
||||
|
||||
UPDATE=/var/lib/bbctrl/firmware/update.tar.bz2
|
||||
|
||||
if [ ! -e "$UPDATE" ]; then
|
||||
echo "Missing $UPDATE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
systemctl stop bbctrl
|
||||
|
||||
rm -rf /tmp/update
|
||||
mkdir /tmp/update
|
||||
cd /tmp/update
|
||||
|
||||
LOG=/var/log/bbctrl.$(date +%Y%m%d-%H%M%S).install
|
||||
tar xf "$UPDATE"
|
||||
cd *
|
||||
./scripts/install.sh "$*" 2>&1 > $LOG
|
||||
|
||||
cd -
|
||||
rm -rf /tmp/update $UPDATE
|
||||
|
||||
) 9> /var/lock/bbctrl.update.lock
|
||||
@@ -1,25 +0,0 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
(
|
||||
flock -n 9
|
||||
|
||||
VERSION=$(curl -s https://raw.githubusercontent.com/OneFinityCNC/onefinity-release/master/latest.txt)
|
||||
PKG_NAME=onefinity-$VERSION
|
||||
PKG=/var/lib/bbctrl/firmware/update.tar.bz2
|
||||
PKG_URL=https://raw.githubusercontent.com/OneFinityCNC/onefinity-release/master/$PKG_NAME.tar.bz2
|
||||
|
||||
logger Installing onefinity firmware $VERSION
|
||||
|
||||
cd /var/lib/bbctrl
|
||||
mkdir -p firmware
|
||||
|
||||
echo Downloading $PKG_URL
|
||||
curl -s $PKG_URL > $PKG
|
||||
|
||||
/usr/local/bin/update-bbctrl
|
||||
|
||||
echo Success
|
||||
|
||||
logger bbctrl firmware $VERSION installed
|
||||
|
||||
) 9> /var/lock/bbctrl.upgrade.lock
|
||||
@@ -1,23 +0,0 @@
|
||||
ratpoison &
|
||||
|
||||
xset -dpms
|
||||
xset s off
|
||||
xset s noblank
|
||||
|
||||
while true; do
|
||||
tvservice -s 2>&1 | grep "state 0x40001" >/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
# Clear browser errors
|
||||
PREFS='/home/pi/.config/chromium/Default/Preferences'
|
||||
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' $PREFS
|
||||
sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' $PREFS
|
||||
|
||||
xrdb /home/pi/.Xresources
|
||||
|
||||
# Start browser
|
||||
/usr/local/bin/browser --no-first-run --disable-infobars \
|
||||
--noerrdialogs --disable-3d-apis http://localhost/
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
@@ -1,3 +0,0 @@
|
||||
Section "ServerFlags"
|
||||
Option "DontVTSwitch" "on"
|
||||
EndSection
|
||||
Reference in New Issue
Block a user