Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric Verstraeten committed Jul 15, 2017
2 parents 296fd68 + 6ec849b commit 865bd7d
Show file tree
Hide file tree
Showing 37 changed files with 452 additions and 738 deletions.
12 changes: 6 additions & 6 deletions board/common/overlay/etc/init.d/S35wifi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ iface=wlan0
driver=wext

sys_watch_conf="/etc/watch.conf"
watch_conf="/etc/watch.conf"
watch_conf="/data/etc/watch.conf"

link_watch=no
link_watch_timeout=20
Expand Down Expand Up @@ -66,7 +66,7 @@ start() {
return 1
fi
done

module=$(basename $(readlink /sys/class/net/$iface/device/driver/module 2>/dev/null) 2>/dev/null)

iwconfig $iface power off &> /dev/null
Expand Down Expand Up @@ -105,21 +105,21 @@ case "$1" in
start)
start
;;

stop)
stop
;;

restart)
stop
start
;;

*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac

# continue after an unsuccessfull wifi start
# as we may still have an ethernet connection available
exit 0
exit 0
29 changes: 20 additions & 9 deletions board/common/overlay/etc/init.d/S41netwatch
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,44 @@ netwatch_interval=20

test -f $watch_conf && source $watch_conf || exit 0

test -z "$netwatch_host" || -z "$netwatch_port" && exit 0

test -n "$os_version" || source /etc/init.d/base
if [ -z "$netwatch_host" ] || [ -z "$netwatch_port" ]; then
exit 0
fi

watch() {
count=0
netwatch_retries=$(($netwatch_retries - 1))
while true; do
if nc -z -w $netwatch_timeout $netwatch_host $netwatch_port </dev/null >/dev/null 2>&1; then
sleep $netwatch_interval

haveInternet=true
case "$(curl -s --max-time 2 -I $netwatch_host | sed 's/^[^ ]* *\([0-9]\).*/\1/; 1q')" in
[23]) haveInternet=true;;
5) haveInternet=true;;
*) haveInternet=false;;
esac

if [ "$haveInternet" = "true" ] ; then
count=0
else
if [ $count -lt $netwatch_retries ]; then
logger -t netwatch -s "cannot connect to $netwatch_host"
count=$(($count + 1))
continue
else
logger -t netwatch -s "cannot connect to $netwatch_host:$netwatch_port, rebooting"
logger -t netwatch -s "cannot connect to $netwatch_host, rebooting"
reboot
fi
fi
sleep $netwatch_interval
done
}

case "$1" in
start)
msg_begin "Starting netwatch"
watch &
if [ "$netwatch_enable" == "yes" ]; then
watch &
fi
msg_done
;;

Expand All @@ -46,11 +58,10 @@ case "$1" in
stop
start
;;

*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac

exit $?

19 changes: 17 additions & 2 deletions board/common/overlay/etc/init.d/S85machinery
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

sys_conf="/etc/opt/kerberosio/config/config.xml"
conf="/data/machinery/config/config.xml"
watch_conf="/data/etc/watch.conf"

if [ -f $sys_conf ] && ! [ -f $conf ]; then
mkdir -p /data/machinery/config
Expand All @@ -14,20 +15,30 @@ if [ -f $sys_conf ] && ! [ -f $conf ]; then
chmod -R 777 /data/machinery/logs
mkdir -p /data/machinery/capture
chmod -R 777 /data/machinery/capture
mkdir -p /data/machinery/h264
chmod -R 777 /data/machinery/h264
fi

test -f $watch_conf && source $watch_conf || exit 0

watch() {
while true; do
sleep 3

pid=$(pgrep -l kerberosio | cut -d ' ' -f 1)
if [ "$pid" = "" ]; then
echo "Starting kerberos.io machinery"
sleep 1
pkill -f kerberosio
kerberosio --config $conf &
fi

done
}

autoremoval() {
while true; do
sleep 60

if [[ $(df -h | grep /dev/mmcblk0p3 | head -1 | awk -F' ' '{ print $5/1 }' | tr ['%'] ["0"]) -gt 90 ]];
then
echo "Cleaning disk"
Expand All @@ -39,6 +50,10 @@ watch() {
start() {
echo "Starting kerberos.io machinery"
watch &

if [ "$autoremoval" == "yes" ]; then
autoremoval &
fi
}

stop() {
Expand Down
18 changes: 11 additions & 7 deletions board/common/overlay/etc/init.d/S86web
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
#!/bin/bash

sys_conf="/var/www/web"
conf="/data/web/app"
conf="/data/web/storage"

start() {
echo "Configuring kerberos.io web"

if [ -d $sys_conf ] && ! [ -d $conf ]; then
mkdir -p /data/web/app
cp -R /var/www/web/app/storage /data/web/app
cp -R /var/www/web/app/config /data/web/app
sed -i "s#__DIR__.'/../views'#'/var/www/web/app/views'#g" /data/web/app/config/view.php
chmod -R 777 /data/web/app

cp -R /var/www/web/storage /data/web/
chmod -R 777 /data/web/storage

cp -R /var/www/web/config /data/web/
chmod -R 777 /data/web/config/kerberos.php

cp -R /var/www/web/bootstrap /data/web/
chmod -R 777 /data/web/bootstrap/cache
fi
}

Expand Down
2 changes: 1 addition & 1 deletion board/common/overlay/etc/version
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
os_name="Kerberos.io OS"
os_short_name="kios"
os_prefix="kios"
os_version="2.3.1"
os_version="2.4.0"
11 changes: 7 additions & 4 deletions board/common/overlay/etc/watch.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ link_watch_timeout=20
ip_watch=no
ip_watch_timeout=40

#netwatch_host=www.google.com
#netwatch_port=80
netwatch_retries=3
netwatch_host=www.google.com
netwatch_port=80
netwatch_retries=10
netwatch_timeout=5
netwatch_interval=20
netwatch_interval=30
netwatch_enable=no

autoremoval=yes
80 changes: 80 additions & 0 deletions board/common/overlay/usr/share/post-upgrade/2.4.0.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash

##########################################
#
# Update configuration files for machinery
#

KERBEROS_CONFIG_DIR="/etc/opt/kerberosio/config"
DATA_CONFIG_DIR="/data/machinery/config"
TEMP_CONFIG_DIR="/tmp/config"

# Copy files to tmp folder and overwrite data config files

rm -rf $TEMP_CONFIG_DIR
mkdir -p $TEMP_CONFIG_DIR
cp -r $DATA_CONFIG_DIR/* $TEMP_CONFIG_DIR
cp -r $KERBEROS_CONFIG_DIR/* $DATA_CONFIG_DIR

# Loop over old config files and adjust new configuration
# with previous values.

for oldfile in $TEMP_CONFIG_DIR/*
do
for newfile in $DATA_CONFIG_DIR/*
do
if [ ${oldfile#$TEMP_CONFIG_DIR} == ${newfile#$DATA_CONFIG_DIR} ]
then
lineNumber=1

while read p
do
name=`echo $p | grep -E "\<(.*?)\>(.*?)<(.*?)\>" | cut -d ">" -f1 | cut -d "<" -f2 | cut -d " " -f1`
value=`echo $p | grep -E "\<(.*?)\>(.*?)<(.*?)\>" | cut -d ">" -f2 | cut -d "<" -f1`

if [ -n "$name" ]
then
#echo "looking for " $name " in " $newfile " with old value " $value

while read -r line ; do
number=`echo $line | cut -d ':' -f1`
if [[ $lineNumber -le $number ]]
then
newvalue=`echo $line | sed -e "s/^$number:[ \t]*//"`
if [[ "$p" != "$newvalue" ]]
then
sed $number"s#$newvalue#$p#" $newfile > $newfile"_"
mv $newfile"_" $newfile
fi
lineNumber=$number
break
fi
done <<< "$(grep -n "$name " $newfile)"
fi

done < $oldfile
fi
done
done

chmod -R 777 $DATA_CONFIG_DIR

mkdir -p /data/machinery/h264
chmod -R 777 /data/machinery/h264

##########################################
#
# Update configuration files for web
#

cp -R /var/www/web/storage /data/web/
chmod -R 777 /data/web/storage

cp -R /var/www/web/config /data/web/
mv /data/web/app/config/kerberos.php /data/web/config/kerberos.php
chmod 777 /data/web/config/kerberos.php

cp -R /var/www/web/bootstrap /data/web/
chmod -R 777 /data/web/bootstrap/cache

rm -rf /data/web/app
4 changes: 2 additions & 2 deletions configs/raspberrypi2_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ BR2_PACKAGE_LIBCURL=y
BR2_PACKAGE_CURL=y
BR2_PACKAGE_LIBCAP=y
BR2_PACKAGE_PCRE=y
BR2_PACKAGE_PCRE_UTF=y
BR2_PACKAGE_PCRE_UCP=y
BR2_PACKAGE_CRDA=y
BR2_PACKAGE_DHCP=y
BR2_PACKAGE_DHCP_CLIENT=y
Expand Down Expand Up @@ -158,5 +160,3 @@ BR2_PACKAGE_EIGEN=y
BR2_PACKAGE_KERBEROSIO_WEB=y
BR2_PACKAGE_KERBEROSIO_MACHINERY=y
BR2_PACKAGE_KERBEROSIO_MACHINERY_RPI=y
BR2_PACKAGE_GDB=y
BR2_PACKAGE_GDB_DEBUGGER=y
4 changes: 2 additions & 2 deletions configs/raspberrypi3_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ BR2_PACKAGE_LIBCURL=y
BR2_PACKAGE_CURL=y
BR2_PACKAGE_LIBCAP=y
BR2_PACKAGE_PCRE=y
BR2_PACKAGE_PCRE_UTF=y
BR2_PACKAGE_PCRE_UCP=y
BR2_PACKAGE_CRDA=y
BR2_PACKAGE_DHCP=y
BR2_PACKAGE_DHCP_CLIENT=y
Expand Down Expand Up @@ -159,5 +161,3 @@ BR2_PACKAGE_EIGEN=y
BR2_PACKAGE_KERBEROSIO_WEB=y
BR2_PACKAGE_KERBEROSIO_MACHINERY=y
BR2_PACKAGE_KERBEROSIO_MACHINERY_RPI=y
BR2_PACKAGE_GDB=y
BR2_PACKAGE_GDB_DEBUGGER=y
4 changes: 2 additions & 2 deletions configs/raspberrypi_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ BR2_PACKAGE_LIBCURL=y
BR2_PACKAGE_CURL=y
BR2_PACKAGE_LIBCAP=y
BR2_PACKAGE_PCRE=y
BR2_PACKAGE_PCRE_UTF=y
BR2_PACKAGE_PCRE_UCP=y
BR2_PACKAGE_CRDA=y
BR2_PACKAGE_DHCP=y
BR2_PACKAGE_DHCP_CLIENT=y
Expand Down Expand Up @@ -158,5 +160,3 @@ BR2_PACKAGE_EIGEN=y
BR2_PACKAGE_KERBEROSIO_WEB=y
BR2_PACKAGE_KERBEROSIO_MACHINERY=y
BR2_PACKAGE_KERBEROSIO_MACHINERY_RPI=y
BR2_PACKAGE_GDB=y
BR2_PACKAGE_GDB_DEBUGGER=y
11 changes: 8 additions & 3 deletions mkrelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,23 @@ echo "Preparing release for Raspberry Pi board"
mkdir -p $DIR/releases/rpi/$DATE
cp $DIR/kios-raspberrypi-* $DIR/releases/rpi/$DATE
for file in $DIR/output/raspberrypi/build/kerberosio-machinery*/kerberosio*; do cp -v -- "$file" "$DIR/releases/rpi/$DATE/rpi1-machinery-${file##*/}"; done
cd $DIR/output/raspberrypi/target/var/www/web && rm -rf app/storage && mkdir -p app/storage/cache && mkdir -p app/storage/logs && mkdir -p app/storage/meta && mkdir -p app/storage/sessions && mkdir -p app/storage/views && sed -i 's/\/data\/machinery\/config/\/\etc\/opt\/kerberosio\/config/g' app/config/app.php && sed -i "s#'/data/web/app/config'#\$this\['path'\] . '/config'#g" bootstrap/compiled.php && sed -i "s#'/data/web/app/storage'#__DIR__.'/../app/storage'#g" bootstrap/paths.php && sed -i "s#'/data/web/app/config'#app_path() . '/config'#g" app/controllers/UserController.php && sed -i "s#'/data/web/app/config'#app_path() . '/config'#g" app/controllers/SettingsController.php && tar czf $DIR/releases/rpi/$DATE/web.tar.gz .
cd $DIR/output/raspberrypi/target/var/www/web && sed -i 's/\/data\/machinery\/config/\/\etc\/opt\/kerberosio\/config/g' config/app.php && tar czf $DIR/releases/rpi/$DATE/web.tar.gz .

echo "Preparing release for Raspberry Pi2 board"

mkdir -p $DIR/releases/rpi2/$DATE
cp $DIR/kios-raspberrypi2-* $DIR/releases/rpi2/$DATE
for file in $DIR/output/raspberrypi2/build/kerberosio-machinery*/kerberosio*; do cp -v -- "$file" "$DIR/releases/rpi2/$DATE/rpi2-machinery-${file##*/}"; done
cd $DIR/output/raspberrypi2/target/var/www/web && rm -rf app/storage && mkdir -p app/storage/cache && mkdir -p app/storage/logs && mkdir -p app/storage/meta && mkdir -p app/storage/sessions && mkdir -p app/storage/views && sed -i 's/\/data\/machinery\/config/\/\etc\/opt\/kerberosio\/config/g' app/config/app.php && sed -i "s#'/data/web/app/config'#\$this\['path'\] . '/config'#g" bootstrap/compiled.php && sed -i "s#'/data/web/app/storage'#__DIR__.'/../app/storage'#g" bootstrap/paths.php && sed -i "s#'/data/web/app/config'#app_path() . '/config'#g" app/controllers/UserController.php && sed -i "s#'/data/web/app/config'#app_path() . '/config'#g" app/controllers/SettingsController.php && tar czf $DIR/releases/rpi2/$DATE/web.tar.gz .
cd $DIR/output/raspberrypi2/target/var/www/web && sed -i 's/\/data\/machinery\/config/\/\etc\/opt\/kerberosio\/config/g' config/app.php && tar czf $DIR/releases/rpi2/$DATE/web.tar.gz .

echo "Preparing release for Raspberry Pi3 board"

mkdir -p $DIR/releases/rpi3/$DATE
cp $DIR/kios-raspberrypi3-* $DIR/releases/rpi3/$DATE
for file in $DIR/output/raspberrypi3/build/kerberosio-machinery*/kerberosio*; do cp -v -- "$file" "$DIR/releases/rpi3/$DATE/rpi3-machinery-${file##*/}"; done
cd $DIR/output/raspberrypi3/target/var/www/web && rm -rf app/storage && mkdir -p app/storage/cache && mkdir -p app/storage/logs && mkdir -p app/storage/meta && mkdir -p app/storage/sessions && mkdir -p app/storage/views && sed -i 's/\/data\/machinery\/config/\/\etc\/opt\/kerberosio\/config/g' app/config/app.php && sed -i "s#'/data/web/app/config'#\$this\['path'\] . '/config'#g" bootstrap/compiled.php && sed -i "s#'/data/web/app/storage'#__DIR__.'/../app/storage'#g" bootstrap/paths.php && sed -i "s#'/data/web/app/config'#app_path() . '/config'#g" app/controllers/UserController.php && sed -i "s#'/data/web/app/config'#app_path() . '/config'#g" app/controllers/SettingsController.php && tar czf $DIR/releases/rpi3/$DATE/web.tar.gz .
cd $DIR/output/raspberrypi3/target/var/www/web && sed -i 's/\/data\/machinery\/config/\/\etc\/opt\/kerberosio\/config/g' config/app.php && tar czf $DIR/releases/rpi3/$DATE/web.tar.gz .

echo "Uploading last release to Github (cedricve/kios)"

cd $DIR
python uploadrelease.py
Loading

0 comments on commit 865bd7d

Please sign in to comment.