Skip to content

Commit 28ba066

Browse files
committed
Fix install of config files in /boot and /data/config
1 parent 8fb8f2c commit 28ba066

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

DEBIAN/postinst

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,18 @@
22
echo "Running sg-control postinst in $(pwd)"
33
SG=/opt/sensorgnome # would be nice to derive that from some env var...
44

5-
# install the default deployment.txt if there is none
6-
# some trickery to get a case-insensitive match of deployment.txt
7-
DC=/data/config
8-
if ! echo $DC/* | egrep -iq /deployment.txt; then
9-
echo "Installing default deployment.txt"
10-
mkdir -p $DC
11-
cp $SG/templates/deployment.txt $DC/deployment.txt
12-
fi
13-
14-
# install the default tag database if there is none
15-
if [[ ! -f $DC/SG_tag_database.sqlite ]]; then
16-
echo "Installing default tag database"
17-
mkdir -p $DC
18-
cp $SG/templates/SG_tag_database.sqlite $DC
19-
fi
5+
# install deployment.txt and tag database if not there
6+
SRC=$SG/templates
7+
for f in deployment.txt SG_tag_database.sqlite; do
8+
if [[ -d /data/config ]]; then
9+
# $SRC/$f exists, so this must be an update, put it there unless it exists
10+
[[ -f /data/config/$f ]] || cp $SRC/$f /data/config
11+
else
12+
# $SRC/$f does not exist, so this must be a fresh install, put it into /boot
13+
# it will be copied to $SRC on first boot
14+
[[ -f /boot/$f ]] || cp $SRC/$f /boot
15+
fi
16+
done
2017

2118
# enable and start/restart units
2219
for U in sg-control; do

gen-package.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ install -d $SG/control
1212
cp -r src/* $SG/control
1313
sudo chown -R 1000:1000 $SG/control
1414

15-
# install default deployment file into templates dir
16-
# (can't install to /data/config 'cause that may be on FAT32 and dpkg will fail setting perms)
15+
# install default deployment file and tag database into templates dir
1716
sudo install -d $DESTDIR/opt/sensorgnome/templates -o 1000 -g 1000
18-
sudo install -o 1000 -g 1000 -m 644 deployment.txt SG_tag_database.sqlite $DESTDIR/opt/sensorgnome/templates
17+
sudo install -m 644 deployment.txt SG_tag_database.sqlite $DESTDIR/opt/sensorgnome/templates
1918

2019
# service file should be owned by root
2120
sudo install -d $DESTDIR/etc/systemd/system -o 0 -g 0

0 commit comments

Comments
 (0)