Merge pull request #1 from cyoung/master

Merge Cyoung
pull/585/head
kjablonski 2017-04-03 14:17:27 -05:00 zatwierdzone przez GitHub
commit 64dca38480
3 zmienionych plików z 11 dodań i 102 usunięć

Wyświetl plik

@ -15,103 +15,3 @@ if [ -e /root/update*stratux*v*.sh ] ; then
fi
fi
get_init_sys() {
if command -v systemctl > /dev/null && systemctl | grep -q '\-\.mount'; then
SYSTEMD=1
elif [ -f /etc/init.d/cron ] && [ ! -h /etc/init.d/cron ]; then
SYSTEMD=0
else
echo "Unrecognised init system" >>/tmp/err
return 1
fi
}
do_expand_rootfs() {
get_init_sys
if [ $SYSTEMD -eq 1 ]; then
ROOT_PART=$(mount | sed -n 's|^/dev/\(.*\) on / .*|\1|p')
else
if ! [ -h /dev/root ]; then
echo "/dev/root does not exist or is not a symlink. Don't know how to expand" >>/tmp/err
return 0
fi
ROOT_PART=$(readlink /dev/root)
fi
PART_NUM=${ROOT_PART#mmcblk0p}
if [ "$PART_NUM" = "$ROOT_PART" ]; then
echo "$ROOT_PART is not an SD card. Don't know how to expand" >>/tmp/err
return 0
fi
# NOTE: the NOOBS partition layout confuses parted. For now, let's only
# agree to work with a sufficiently simple partition layout
if [ "$PART_NUM" -ne 2 ]; then
echo "Your partition layout is not currently supported by this tool. You are probably using NOOBS, in which case your root filesystem is already expanded anyway." >>/tmp/err
return 0
fi
LAST_PART_NUM=$(parted /dev/mmcblk0 -ms unit s p | tail -n 1 | cut -f 1 -d:)
if [ $LAST_PART_NUM -ne $PART_NUM ]; then
echo "$ROOT_PART is not the last partition. Don't know how to expand" >>/tmp/err
return 0
fi
# Get the starting offset of the root partition
PART_START=$(parted /dev/mmcblk0 -ms unit s p | grep "^${PART_NUM}" | cut -f 2 -d: | sed 's/[^0-9]//g')
[ "$PART_START" ] || return 1
# Return value will likely be error for fdisk as it fails to reload the
# partition table because the root fs is mounted
fdisk /dev/mmcblk0 <<EOF
p
d
$PART_NUM
n
p
$PART_NUM
$PART_START
p
w
EOF
# now set up an init.d script
cat <<EOF > /etc/init.d/resize2fs_once &&
#!/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" &&
resize2fs /dev/$ROOT_PART &&
update-rc.d resize2fs_once remove &&
rm /etc/init.d/resize2fs_once &&
log_end_msg \$?
;;
*)
echo "Usage: \$0 start" >&2
exit 3
;;
esac
EOF
chmod +x /etc/init.d/resize2fs_once &&
update-rc.d resize2fs_once defaults
}
if [ ! -f /etc/stratux.firstboot ]; then
echo "expanding filesystem (first boot)" >>/tmp/err
do_expand_rootfs
touch /etc/stratux.firstboot
fi

Wyświetl plik

@ -134,7 +134,12 @@ apt-get install -y libjpeg-dev i2c-tools python-smbus python-pip python-dev pyth
pip install wiringpi
cd /root
git clone https://github.com/rm-hull/ssd1306
cd ssd1306 && python setup.py install
cd ssd1306
# Force an older version of ssd1306, since recent changes have caused a lot of compatibility issues.
git reset --hard 232fc801b0b8bd551290e26a13122c42d628fd39
python setup.py install
cp /root/stratux/test/screen/screen.py /usr/bin/stratux-screen.py
mkdir -p /etc/stratux-screen/
cp -f /root/stratux/test/screen/stratux-logo-64x64.bmp /etc/stratux-screen/stratux-logo-64x64.bmp

Wyświetl plik

@ -43,7 +43,11 @@ class StratuxScreen():
response = urllib2.urlopen('http://localhost/getTowers')
getTowersHTML = response.read()
getTowersData = json.loads(getTowersHTML)
NumTowers = len(getTowersData)
NumTowers = 0
for towerLatLng in getTowersData:
print getTowersData[towerLatLng]["Messages_last_minute"]
if (getTowersData[towerLatLng]["Messages_last_minute"] > 0):
NumTowers += 1
with canvas(oled) as draw:
pad = 2 # Two pixels on the left and right.