diff --git a/DEBIAN/postinst b/DEBIAN/postinst index 113e2e7..30925a8 100755 --- a/DEBIAN/postinst +++ b/DEBIAN/postinst @@ -2,21 +2,18 @@ echo "Running sg-control postinst in $(pwd)" SG=/opt/sensorgnome # would be nice to derive that from some env var... -# install the default deployment.txt if there is none -# some trickery to get a case-insensitive match of deployment.txt -DC=/data/config -if ! echo $DC/* | egrep -iq /deployment.txt; then - echo "Installing default deployment.txt" - mkdir -p $DC - cp $SG/templates/deployment.txt $DC/deployment.txt -fi - -# install the default tag database if there is none -if [[ ! -f $DC/SG_tag_database.sqlite ]]; then - echo "Installing default tag database" - mkdir -p $DC - cp $SG/templates/SG_tag_database.sqlite $DC -fi +# install deployment.txt and tag database if not there +SRC=$SG/templates +for f in deployment.txt SG_tag_database.sqlite; do + if [[ -f $SRC/$f ]]; then + # $SRC/$f exists, so this must be an update, put it there unless it exists + [[ -f /data/config/$f ]] || cp $SRC/$f /data/config + else + # $SRC/$f does not exist, so this must be a fresh install, put it into /boot + # it will be copied to $SRC on first boot + [[ -f /boot/$f ]] || cp $SRC/$f /boot + fi +done # enable and start/restart units for U in sg-control; do diff --git a/gen-package.sh b/gen-package.sh index c2bbf64..7832a67 100755 --- a/gen-package.sh +++ b/gen-package.sh @@ -12,10 +12,9 @@ install -d $SG/control cp -r src/* $SG/control sudo chown -R 1000:1000 $SG/control -# install default deployment file into templates dir -# (can't install to /data/config 'cause that may be on FAT32 and dpkg will fail setting perms) +# install default deployment file and tag database into templates dir sudo install -d $DESTDIR/opt/sensorgnome/templates -o 1000 -g 1000 -sudo install -o 1000 -g 1000 -m 644 deployment.txt SG_tag_database.sqlite $DESTDIR/opt/sensorgnome/templates +sudo install -m 644 deployment.txt SG_tag_database.sqlite $DESTDIR/opt/sensorgnome/templates # service file should be owned by root sudo install -d $DESTDIR/etc/systemd/system -o 0 -g 0