Parcourir la source

Merge branch 'master' of https://tree.clementinecomputing.com/clementinecomputing/popufare

clementinecomputing il y a 6 ans
Parent
commit
211bbcd215

+ 1 - 1
.gitignore

@@ -7,7 +7,6 @@ diu_minder
 client_supervisor
 
 piu_minder
-showmessage
 
 billdb
 !*billdb/
@@ -40,3 +39,4 @@ libtool
 *.gp
 *.ngc
 
+server/diu_packager/site

+ 16 - 9
aux/deploy-busunit-interactive

@@ -176,18 +176,23 @@ tc=/home/bus/popufare/busunit/testing/config
 sudo cp -R $repolocation /home/bus
 sudo chown -R bus:bus /home/bus/popufare
 sudo bash -c " su - bus -c ' cd /home/bus/popufare/busunit ; ./build_all.sh native ; ' "
-sudo bash -c " cd /home/bus/bin ; ln -s $d/avls . ; ln -s $d/billdb . ; ln -s $d/client_supervisor . ; ln -s $d/debug_client . ; ln -s $d/diu_minder . ; ln -s $d/ipc_server . "
-sudo bash -c " cd /home/bus/bin ; ln -s $d/paddlemgr . ; ln -s $d/passdb . ; ln -s $d/piu_minder . ; ln -s $d/send_billing_record . ; ln -s $d/send_magstripe . "
-sudo bash -c " cd /home/bus/bin ; ln -s $d/gps_minder . "
+sudo bash -c " cd /home/bus/bin ; ln -sf $d/avls . ; ln -sf $d/billdb . ; ln -sf $d/client_supervisor . ; ln -sf $d/debug_client . ; ln -sf $d/diu_minder . ; ln -sf $d/ipc_server . "
+sudo bash -c " cd /home/bus/bin ; ln -sf $d/paddlemgr . ; ln -sf $d/passdb . ; ln -sf $d/piu_minder . ; ln -sf $d/send_billing_record . ; ln -sf $d/send_magstripe . "
+sudo bash -c " cd /home/bus/bin ; ln -sf $d/gps_minder . "
 
-sudo bash -c " cd /home/bus/bin ; ln -s $bd/DIUv2/diu_kiosk . "
+sudo bash -c " cd /home/bus/bin ; ln -sf $bd/DIUv2/diu_kiosk . "
 
-sudo bash -c " cd /home/bus/bin ; ln -s $bd/scripts/init_bus.sh . ; ln -s $bd/scripts/update_loop.sh . ; ln -s $bd/scripts/setup-serial.py . ; ln -s $bd/scripts/get_net_ids.sh . "
-sudo bash -c " cd /home/bus/bin ; ln -s $bd/scripts/connection_tether.sh . ; ln -s $bd/scripts/reset-gps.py ./reset-gps "
+sudo bash -c " cd /home/bus/bin ; ln -sf $bd/scripts/init_bus.sh . ; ln -sf $bd/scripts/update_loop.sh . ; ln -sf $bd/scripts/setup-serial.py . ; ln -sf $bd/scripts/get_net_ids.sh . "
+sudo bash -c " cd /home/bus/bin ; ln -sf $bd/scripts/connection_tether.sh . ; ln -sf $bd/scripts/reset-gps.py ./reset-gps "
 
-sudo bash -c " cd /home/bus/config ; ln -s $diudir/html . ; "
-sudo bash -c " cd /home/bus/config ; cp $bd/passdb/init.scm . ; cp $bd/passdb/rfid_patterns.txt . "
-sudo bash -c " cp $tc/equipnum.txt . ; cp $tc/config.tgz.checksum . ; cp $tc/config.tgz.version . ; cp $tc/firmware.tgz.checksum . ; cp $tc/firmware.tgz.version . ; cp $tc/serial.txt serial_num "
+sudo bash -c " cd /home/bus/bin ; ln -sf $bd/scripts/apply_update.sh . ; ln -sf $bd/scripts/apply_update_legacy.sh . ; ln -sf $bd/scripts/apply_update_popufare.sh "
+sudo bash -c " cd /home/bus/bin ; ln -sf $bd/scripts/fix_pkg_perm.sh . "
+
+sudo bash -c " cd /home/bus/config ; ln -sf $diudir/html . ; "
+sudo bash -c " cd /home/bus/config ; cp $bd/passdb/init.scm . ; cp $bd/passdb/rfid_patterns.txt . ; cp $bd/avls/avls_freq.txt . "
+sudo bash -c " cd /home/bus/config ; cp $bd/passdb/init.scm . ; cp $bd/passdb/rfid_patterns.txt . ; cp $bd/avls/avls_freq.txt . "
+
+sudo bash -c " cd /home/bus/config ; cp $tc/equipnum.txt . ; cp $tc/serial.txt serial_num "
 
 sudo bash -c " rm -f /home/bus/bin/common_values.sh ; cp $bd/scripts/common_values.sh /home/bus/bin "
 
@@ -198,6 +203,8 @@ sudo cp /home/bus/popufare/busunit/testing/config/config.tgz.checksum /home/bus/
 sudo cp /home/bus/popufare/busunit/testing/config/config.tgz.version /home/bus/config/config.tgz.version
 sudo cp /home/bus/popufare/busunit/testing/config/firmware.tgz.checksum /home/bus/config/firmware.tgz.checksum
 sudo cp /home/bus/popufare/busunit/testing/config/firmware.tgz.version /home/bus/config/firmware.tgz.version
+sudo cp /home/bus/popufare/busunit/testing/config/package.tgz.checksum /home/bus/config/package.tgz.checksum
+sudo cp /home/bus/popufare/busunit/testing/config/package.tgz.version /home/bus/config/package.tgz.version
 
 sudo mkdir -p /home/bus/config/server
 

+ 36 - 0
busunit/scripts/apply_update.sh

@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# Copyright (c) 2019 Clementine Computing LLC.
+# 
+# This file is part of PopuFare.
+# 
+# PopuFare is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# PopuFare is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+# 
+# You should have received a copy of the GNU Affero General Public License
+# along with PopuFare.  If not, see <https://www.gnu.org/licenses/>.
+#
+
+## Wrapper script to handle legacy updates if need be.
+##
+
+update_file="$1"
+update_checksum="$2"
+file_size="$3"
+server_path="$4"
+file_version="$5"
+
+if tar -tf $update_file popufare.witness > /dev/null 2>&1 ; then
+  echo "apply_update.sh: Found popufare.witness in $update_file, assuming a Popufare installation tarball..."
+  /home/bus/bin/apply_update_popufare.sh $update_file $update_checksum $file_size $server_path $file_version
+else
+  echo "apply_update.sh: Could not find popufare.witness in $update_file, assuming a legacy install..."
+  /home/bus/bin/apply_update_legacy.sh $update_file $update_checksum $file_size $server_path $file_version
+fi

+ 94 - 0
busunit/scripts/apply_update_legacy.sh

@@ -0,0 +1,94 @@
+#!/bin/bash
+#
+# Copyright (c) 2019 Clementine Computing LLC.
+# 
+# This file is part of PopuFare.
+# 
+# PopuFare is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# PopuFare is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+# 
+# You should have received a copy of the GNU Affero General Public License
+# along with PopuFare.  If not, see <https://www.gnu.org/licenses/>.
+#
+
+update_file="$1"
+update_checksum="$2"
+file_size="$3"
+server_path="$4"
+file_version="$5"
+
+. /home/bus/bin/common_values.sh
+
+# Confirm we have a checksum that differs from our existing checksum
+#
+if [[ -f /home/bus/config/$update_file.checksum ]] ; then
+  existing_checksum=`cat /home/bus/config/$update_file.checksum`
+  if [[ "$update_checksum" == "$existing_checksum" ]] ; then
+    echo "We already HAVE an update $update_file with checksum $update_checksum, aborting install"
+    exit 1
+  fi
+fi
+
+local_checksum=`md5sum $update_file | cut -d' ' -f1`
+
+# We are doing a 'legacy' install, so unpack the package locally and only
+# check for appropriate files in the 'config' directory.
+#
+if [[ "$update_checksum" == "$local_checksum" ]] ; then
+
+  echo "$local_checksum" > /home/bus/config/$update_file.checksum
+  echo "$file_version" > /home/bus/config/$update_file.version
+
+  tar -zxf $update_file
+
+  if [[ ! -d ./mnt/data2/config ]] ; then
+    echo "Legacy update did not find 'mnt/data2/config', not going further"
+    exit 0
+  fi
+
+  # We are specifically only interested in:
+  # - *.paddle
+  # - avls_freq.txt
+  # - drivers.txt
+  # - init.scm
+  # - rules.scm
+  # - rfid_patterns.txt
+  #
+  # only look for those files and deposit them in the appropriate place
+  #
+
+  find ./mnt/data2/config -name '*.paddle' -type f | \
+    xargs -n1 -I{} cp -f {} /home/bus/config
+
+  if [[ -e ./mnt/data2/config/avls_freq.txt ]] ; then
+    cp -f ./mnt/data2/config/avls_freq.txt /home/bus/config/avls_freq.txt
+  fi
+
+  if [[ -e ./mnt/data2/config/drivers.txt ]] ; then
+    cp -f ./mnt/data2/config/drivers.txt /home/bus/config/drivers.txt
+  fi
+
+  if [[ -e ./mnt/data2/config/init.scm ]] ; then
+    cp -f ./mnt/data2/config/init.scm /home/bus/config/init.scm
+  fi
+
+  if [[ -e ./mnt/data2/config/rules.scm ]] ; then
+    cp -f ./mnt/data2/config/rules.scm /home/bus/config/rules.scm
+  fi
+
+  if [[ -e ./mnt/data2/config/rfid_patterns.txt ]] ; then
+    cp -f ./mnt/data2/config/rfid_patterns.txt /home/bus/config/rfid_patterns.txt
+  fi
+
+
+  exit 0
+fi
+
+exit 1

+ 94 - 0
busunit/scripts/apply_update_popufare.sh

@@ -0,0 +1,94 @@
+#!/bin/bash
+#
+# Copyright (c) 2019 Clementine Computing LLC.
+# 
+# This file is part of PopuFare.
+# 
+# PopuFare is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# PopuFare is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+# 
+# You should have received a copy of the GNU Affero General Public License
+# along with PopuFare.  If not, see <https://www.gnu.org/licenses/>.
+#
+
+update_file="$1"
+update_checksum="$2"
+file_size="$3"
+server_path="$4"
+file_version="$5"
+
+. /home/bus/bin/common_values.sh
+
+# Confirm we have a checksum that differs from our existing checksum
+#
+if [[ -f /home/bus/config/$update_file.checksum ]] ; then
+  existing_checksum=`cat /home/bus/config/$update_file.checksum`
+  if [[ "$update_checksum" == "$existing_checksum" ]] ; then
+    echo "We already HAVE an update $update_file with checksum $update_checksum, aborting install"
+    exit 1
+  fi
+fi
+
+local_checksum=`md5sum $update_file | cut -d' ' -f1`
+
+# We are doing a 'legacy' install, so unpack the package locally and only
+# check for appropriate files in the 'config' directory.
+#
+if [[ "$update_checksum" == "$local_checksum" ]] ; then
+
+  tar -zxf $update_file install.sh
+
+  if [ -n "$PACKAGE_OWNER_STRING" ]; then
+    chown $PACKAGE_OWNER_STRING install.sh
+  fi
+
+  chmod $PACKAGE_BIN_PERMISSIONS install.sh
+
+  if (./install.sh); then
+    echo "$local_checksum" > /home/bus/config/$update_file.checksum
+    echo "$file_version" > /home/bus/config/$update_file.version
+
+    if [ "$FIX_PACKAGE_PERMS" -ne "0" ]; then
+
+      if [ -f $EXTRACT_PATH_FILE ]; then
+        pkg_path="`cat $EXTRACT_PATH_FILE`"
+        echo "Fixing permissions from package specified path $pkg_path";
+      else
+        pkg_path="$DEFAULT_EXTRACT_PATH"
+        echo "Fixing permissions from default path $pkg_path";
+      fi
+
+      /home/bus/bin/fix_pkg_perm.sh $update_file $pkg_path
+    fi
+
+    echo "Update $update_file successfully installed"
+    rm -f $update_file
+    rm -f $EXTRACT_PATH_FILE
+    if [ -f /tmp/reboot_flag ]; then
+      killall diu_minder
+      echo "Tearing down network connection"
+      if [ -f $SSH_TUNNEL_PIDFILE ]; then kill `cat $SSH_TUNNEL_PIDFILE`; sleep 30; fi
+      /usr/bin/poff gprs
+      shutdown -r now;
+      sleep 1000;
+    fi
+    exit 0
+  else
+    echo "Update $update_file failed"
+    rm -f $update_file
+    exit 1
+  fi
+else
+  echo "Update $update_file appears to be BOGUS:  Server MD5=$update_checksum Local MD5=$local_checksum"
+  rm -f $update_file
+  exit 1
+fi
+
+exit 1

+ 88 - 0
busunit/scripts/fix_pkg_perm.sh

@@ -0,0 +1,88 @@
+#!/bin/sh
+#
+# Copyright (c) 2019 Clementine Computing LLC.
+#
+# This file is part of PopuFare.
+#
+# PopuFare is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# PopuFare is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with PopuFare.  If not, see <https://www.gnu.org/licenses/>.
+#
+
+. /home/bus/bin/common_values.sh
+
+#    This script takes two parameters, first is a tarball, and the second is the target directory it was extracted to.
+#when supplied with this information, this script updates the ownership and permissions on everything to be correct.  This
+#is pretty much only done for things which live in /home/bus/bin/ and for special SSH related files and directores.
+#
+#    See common_values.sh:
+#       PACKAGE_*_PATTERN, PACKAGE_*_PERMISSIONS contain regexes to match each filespec from the
+#     tarball against.  If they match, the matching _PERMISSIONS variable holds the permissions that will
+#     be set.  Also, each file coming out of the tarball is given (with chown) to the user and group specified
+#     by PACKAGE_OWNER_STRING.
+#
+# When called with parameters, it processes the tarball first, and even without parameters it will examine the environment
+#and iterate through any existing files defined in ALWAYS_*_LIST and apply PACKAGE_*_PERMISSIONS to them.  This is an insurance
+#policy against forgotten execute bits and overly permissive settings on directories containing ssh authorized_keys or id_rsa 
+#files which might cause ssh or sshd to refuse to allow us to make or accept connections (bye-bye updates!).  Thus we want to
+#be extremely careful to prevent this snafu and have the scripts fix it right away if it occurs.
+
+tarball="$1"
+reldir="$2"
+
+olddir="`pwd`"
+
+pat_vars="`set | egrep '^PACKAGE_[A-Z_]+_PATTERN=' | sed -r 's/^PACKAGE_([A-Z_]+)_PATTERN=.*$/\1/'`"
+always_vars="`set | egrep '^ALWAYS_[A-Z_]+_LIST=' | sed -r 's/^ALWAYS_([A-Z_]+)_LIST=.*$/\1/'`"
+
+if [ -f "$olddir/$tarball" ]; then
+
+  cd $reldir
+  tar -ztf $olddir/$tarball |
+  while read filespec; do
+
+    if [ -n "$PACKAGE_OWNER_STRING" ]; then
+      chown $PACKAGE_OWNER_STRING $filespec
+    fi
+
+    for i in $pat_vars; do
+      patvar="PACKAGE_${i}_PATTERN";
+      permvar="PACKAGE_${i}_PERMISSIONS";
+
+      if (echo "$filespec" | egrep -q "${!patvar}"); then
+        chmod ${!permvar} $filespec
+      fi
+    done
+  done
+fi
+
+cd /
+
+for grp in $always_vars; do
+  filesvar="ALWAYS_${grp}_LIST";
+  permvar="PACKAGE_${grp}_PERMISSIONS";
+
+  for fil in ${!filesvar}; do
+
+    if [ -e "$fil" ]; then
+      if [ -n "$PACKAGE_OWNER_STRING" ]; then
+        chown $PACKAGE_OWNER_STRING $fil
+      fi
+
+      chmod ${!permvar} $fil
+    fi
+
+  done
+
+done
+
+cd $olddir

+ 98 - 0
busunit/scripts/package_install.sh

@@ -0,0 +1,98 @@
+#!/bin/bash
+#
+# Copyright (c) 2019 Clementine Computing LLC.
+#
+# This file is part of PopuFare.
+#
+# PopuFare is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# PopuFare is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with PopuFare.  If not, see <https://www.gnu.org/licenses/>.
+#
+
+echo "# Popufare DIU package installer script"
+
+tarball="package.tgz"
+
+BINDIR="/home/bus/bin"
+CONFIGDIR="/home/bus/config"
+BINLIST="avls billdb client_supervisor debug_client diu_minder gps_minder ipc_server paddlemgr passdb piu_minder send_billing_record send_magstrip"
+SCRIPTLIST="apply_update.sh apply_update_legacy.sh apply_update_popufare.sh common_values.sh connection_tether.sh fix_pkg_perm.sh get_net_ids.sh init_bus.sh update_loop.sh showmessage setup-serial.py"
+
+if [[ ! -e /home/bus/config/popufare.witness ]] ; then
+  echo "# Popufare system is not detected! Assuming legacy system and aborting install but populating checksum and version files"
+  exit 0
+fi
+
+killall client_supervisor ; sleep 5 ;
+
+tmpdir=`mktemp -d`
+tar -C $tmpdir -zxf $tarball
+pushd $tmpdir > /dev/null
+
+  if [[ ! -e ./popufare.witness ]] ; then
+    echo "# Could not find local 'popufare.witness'. Are you sure you're installing this from a package?"
+    echo ""
+
+    popd > /dev/null
+
+    rm -rf $tmpdir
+    exit 1
+  fi
+
+  ./build_all.sh native
+
+  # These represent the most common files that are going to need to be
+  # updated.
+  # Other system files, like rc.local, the PPP config files, etc.
+  # can also be updated as needed, but for now the focus is on
+  # the binaries and scripts located in /home/bus/.
+  #
+  for binfn in $BINDLIST ; do
+    rm -f $BINDIR/$binfn
+    cp -L bin/native/$binfn $BINDIR/$binfn
+  done
+
+  for scriptfn in $SCRIPTLIST ; do
+    rm -f $BINDIR/$scriptfn
+    cp -L scripts/$scriptfn $BINDIR/$scriptfn
+  done
+
+  rm -rf $CONFIGDIR/html
+  cp -L -R DIUv2/html $CONFIGDIR/
+
+  # Misc. scripts/programs missed by the above
+  #
+  rm -f $BINDIR/diu_kiosk
+  cp -L DIUv2/diu_kiosk $BINDIR/
+
+  rm -f $BINDIR/reset-gps
+  cp -L scripts/reset-gps.py $BINDIR/reset-gps
+
+  # Indicate we have a Popufare installation
+  #
+  touch $CONFIGDIR/popufare.witness
+
+  # install site specific files
+  #
+  for fn in `find site -type f` ; do
+    dstfn=`echo $fn | sed 's;^site;;'`
+    cp -L $fn $dstfn
+  done
+
+popd > /dev/null
+
+sleep 1
+touch /tmp/reboot_flag
+
+echo "Done."
+
+exit 0

+ 24 - 0
busunit/scripts/showmessage

@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# Copyright (c) 2019 Clementine Computing LLC.
+#
+# This file is part of PopuFare.
+#
+# PopuFare is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# PopuFare is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with PopuFare.  If not, see <https://www.gnu.org/licenses/>.
+#
+
+msg="$@"
+dt=`date '+%Y-%m-%d_%H:%M:%S'`
+
+echo -e "$dt\t$msg" > /tmp/showmessage.txt

+ 0 - 4
busunit/scripts/update_loop.sh

@@ -121,10 +121,6 @@ while true; do
     (
       while read client_file checksum file_size server_path file_version; do
 
-        ## DEBUG
-        echo "# UPDATES DISABLED TEMPORARILY"
-        break;
-
         # If we've been asked to abort this update, do so before we start downloading if possible
         #
         if [ -f $UPDATE_ABORT_DROPFILE ]; then

+ 1 - 0
busunit/testing/config/package.tgz.checksum

@@ -0,0 +1 @@
+0

+ 1 - 0
busunit/testing/config/package.tgz.version

@@ -0,0 +1 @@
+0.0

+ 54 - 0
experiment/production/Deploy-Install-Notes.md

@@ -0,0 +1,54 @@
+Deploy Install Notes
+===
+
+There is a facility to update the buses deployed in the fleet with updates.
+This is necessary as routes, drivers, etc. change.
+
+As the system changes over to a newer version, there will be some legacy system
+infrastructure to deal with making sure legacy systems aren't updated with new
+code and the new systems aren't running legacy update scripts.
+
+Legacy System Overview
+---
+
+The script `update_loop.sh` looks at the list of package checksums and sends them
+to the server.
+The server responds with updated packages, including the checksum, file size and server side
+location.
+
+If the DIU receives this information, `update_loop.sh` then proceeds to:
+
+* Confirms the reported package is different from the local version
+* Checks to make sure the process hasn't been flagged for being aborted (presence of a drop file)
+* Generates expected information into temporary files
+* `scp` the remote file locally
+* Checks again for an abort drop file
+* Runs `apply_update.sh` with the file, checksum, size, path and package version
+* Cleans up
+
+The `apply_update.sh` script
+
+* Loads `common_values.sh`
+* Confirms checksums are different, aborting install if they are the same
+* Proceeds only if the reported checksum is the same as the actual checksum
+* Extracts the `install.sh` script from the downloaded tar.gz package
+* Runs `install.sh`
+* `fix_pkg_perms.sh` as ssh will start to fail when keys or directories the keys are in
+  don't have proper permissions or if executable bits on binaries aren't set properly
+  will cause other processes to fail.
+
+From what I can tell, the following is noteworthy:
+
+* `install.sh` needs to return a proper value to indicate to `apply_update.sh` it's been successful
+* `/tmp/reboot_flag` file will be touched if the system needs a reboot
+
+Popufare Installation
+---
+
+Here's my suggestion on how to proceed:
+
+* Popufare will ignore the `firmware.tgz` package updates
+* Popufare will only extract config files (paddles, etc.) from the `config.tgz` packages and deposits
+  them in the appropriate place
+* Popufare will use a new package, `popufare_package.tgz`, that checks for a "magic" file (`/home/bus/config/popufare.witness`)
+  and only proceeds if this file is present

+ 24 - 0
server/diu_packager/README.md

@@ -0,0 +1,24 @@
+DIU Packager
+===
+
+These are a set of script that will get a Popufare
+package ready for DIU deployment.
+
+There is a legacy system in place so the install script
+needs to be careful about how it interacts with the
+system so as not to interfere with a legacy system
+if one is detected but also do normal installation
+if we're on a newer Popufare system.
+
+This packager is meant mostly for reference.
+Site specific files will need to be added to the packager
+for use in the install script deployed to the DIU.
+
+Notes
+---
+
+* The installer script puts packages in the `package` directory.
+* The install script creates a `witness` file to indicate it's a Popufare installation
+
+
+

+ 64 - 0
server/diu_packager/create_popufare_package.sh

@@ -0,0 +1,64 @@
+#!/bin/bash
+#
+# Copyright (c) 2019 Clementine Computing LLC.
+#
+# This file is part of PopuFare.
+#
+# PopuFare is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# PopuFare is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with PopuFare.  If not, see <https://www.gnu.org/licenses/>.
+#
+
+VERBOSE=0
+
+mkdir -p stage
+mkdir -p package
+
+pkgver=`date '+%Y%m%d-%H-%M-%S'`
+
+DIUDIR=`realpath ../../busunit`
+
+pkgfile="package-$pkgver.tgz"
+pkgdir="package-$pkgver"
+
+mkdir -p stage/$pkgdir
+
+pushd stage/$pkgdir > /dev/null
+
+  if [[ "$VERBOSE" == 1 ]] ; then
+    echo  "# Creating $pkgfile in './stage/'"
+  fi
+  cp -R $DIUDIR/. .
+
+  cp $DIUDIR/scripts/package_install.sh install.sh
+  touch popufare.witness
+
+  # copy over site specific files that overwrite default
+  # files.
+  #
+  cp -R ../../site .
+
+  tar -czf ../$pkgfile *
+
+popd > /dev/null
+
+rm -rf stage/$pkgdir
+
+if [[ "$VERBOSE" == 1 ]] ; then
+  echo "# done"
+fi
+
+if [[ "$VERBOSE" == 1 ]] ; then
+  echo "# putting package '$pkgfile' in ./package"
+fi
+
+mv stage/$pkgfile package