Skip to content

Commit 5cf5e4d

Browse files
committed
Fix packaging and service scripts
1 parent 65282e2 commit 5cf5e4d

File tree

6 files changed

+83
-67
lines changed

6 files changed

+83
-67
lines changed

DEBIAN/control

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Package: sg-control
2-
Version: 1.0
2+
Version: 0
33
Architecture: armhf
44
Essential: no
5-
Depends:
6-
Homepage: https://github.com/sensorgnome-control
5+
Depends: nodejs
6+
Homepage: https://github.com/sensorgnome/sensorgnome-control
77
Maintainer: TvE ([email protected])
88
Description: Sensorgnome main control process
99
Orchestrates all tag detection, processing, transmission and web activities.

DEBIAN/postinst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
#! /bin/bash -ex
22
echo "Running sg-control postinst in $(pwd)"
3-
MISC=/opt/sensorgnome/control # would be nice to derive that from some env var...
3+
SG=/opt/sensorgnome # would be nice to derive that from some env var...
4+
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+
cp $SG/templates/deployment.txt $DC/deployment.txt
11+
fi
412

513
# enable and start/restart units
614
for U in sg-control; do
File renamed without changes.

gen-package.sh

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
#! /bin/bash -e
22
DESTDIR=build-temp
3-
rm -rf $DESTDIR
3+
sudo rm -rf $DESTDIR
44
mkdir $DESTDIR
55

6-
(cd src; npm update)
6+
# npm update to pull in the latest versions of all dependencies
7+
(cd src; npm --no-fund update)
78

8-
DEST=$DESTDIR/opt/sensorgnome/control
9-
install -d $DEST
10-
cp -r src $DEST
9+
# install the control application files as user pi=1000
10+
SG=$DESTDIR/opt/sensorgnome
11+
install -d $SG/control
12+
cp -r src/* $SG/control
13+
sudo chown -R 1000:1000 $SG/control
1114

12-
install -d $DESTDIR/data/config
13-
install -m 644 defaultDeployment.txt $DESTDIR/data/config/DEPLOYMENT.TXT
14-
install -d $DESTDIR/etc/systemd/system
15-
install -m 644 *.service $DESTDIR/etc/systemd/system
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)
17+
sudo install -d $DESTDIR/opt/sensorgnome/templates -o 1000 -g 1000
18+
sudo install -o 1000 -g 1000 -m 644 default-deployment.txt $DESTDIR/opt/sensorgnome/templates/deployment.txt
19+
20+
# service file should be owned by root
21+
sudo install -d $DESTDIR/etc/systemd/system -o 0 -g 0
22+
sudo install -m 644 -o 0 -g 0 *.service $DESTDIR/etc/systemd/system
1623

1724
cp -r DEBIAN $DESTDIR
25+
sed -e "/^Version/s/:.*/: $(date +%Y.%j)/" -i $DESTDIR/DEBIAN/control # set version: YYYY.DDD
1826
mkdir -p packages
19-
dpkg-deb -v --build $DESTDIR packages/sg-control.deb
20-
# dpkg-deb --contents packages/sg-control.deb
21-
ls -lh packages/sg-control.deb
27+
dpkg-deb --build $DESTDIR packages
28+
# dpkg-deb --contents packages
29+
ls -lh packages

sg-control.service

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
[Unit]
22
Description=Sensorgnome main control process.
3-
WorkingDirectory=/opt/sensorgnome/control
4-
After=sg-boot, sg-gps-link, chrony, sg-usb-init, sg-wifi-init, gestures
3+
After=sg-boot sg-gps-link chronyd sg-usb-init
4+
Requires=sg-boot sg-gps-link chronyd sg-usb-init
55

66
[Service]
77
Type=exec
8-
#FIXME: if ! grep -q NO_AUTO_FCD_UPDATE /data/config/deployment.txt; then
9-
#ExecStartPre=/opt/sensorgnome/fcd/update_fcd_firmware.sh
10-
ExecStartPre=/bin/bash -c 'echo "*** Starting sensorgnome control app $(date)" >/var/log/nodelog.txt'
8+
WorkingDirectory=/opt/sensorgnome/control
119
Environment=NODE_ENV=production
12-
Environment=VAMP_PATH=/opt/vamp
10+
Environment=NODE_PATH=/opt/sensorgnome/control
1311
Environment=LC_ALL="C.UTF-8"
14-
ExecStart=/usr/bin/nice -n -15 "/usr/bin/node ./main.js >>/var/log/nodelog.txt 2>&1"
15-
ExecStartPost=/usr/bin/killall -KILL rtl_tcp vamp-alsa-host chronyc
12+
ExecStartPre=/bin/bash -c 'echo "*** Starting sensorgnome control app $(date)" >/var/log/nodelog.txt'
13+
ExecStartPre=-/usr/bin/ln -s /data/SGdata /media/SD_card
14+
ExecStart=/bin/bash -c "nice -n -15 node main >>/var/log/nodelog.txt 2>&1"
15+
ExecStartPost=-/usr/bin/killall -KILL rtl_tcp vamp-alsa-host chronyc
1616
Restart=always
17-
RestartSec=60
17+
RestartSec=60s
1818

1919
[Install]
2020
WantedBy=multi-user.target

src/package-lock.json

Lines changed: 42 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)