Skip to content

Commit

Permalink
Fix install of config files in /boot and /data/config
Browse files Browse the repository at this point in the history
  • Loading branch information
tve committed Nov 24, 2021
1 parent 8fb8f2c commit 0861e4a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
27 changes: 12 additions & 15 deletions DEBIAN/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions gen-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0861e4a

Please sign in to comment.