This repository has been archived by the owner on Oct 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sensorplatform.sh
executable file
·114 lines (107 loc) · 3.71 KB
/
sensorplatform.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/sh
username=administrator
case $1 in
"dependencies")
# install dependencies
mkdir /home/${username}/Downloads
echo "Install dependencies"
sh Resources/Firmware/RaspberryPi3/Programs/install_java_maven.sh
sh Resources/Firmware/RaspberryPi3/Programs/install_bluez.sh
sh Resources/Firmware/RaspberryPi3/Programs/install_surfstick_drivers.sh
sh -c "echo 'dtoverlay=i2c-rtc,ds3231\n' >> /boot/config.txt"
cp Resources/Firmware/RaspberryPi3/System/wlanConfig.sh /home/${username}/wlanConfig.sh
chmod +x /home/${username}/wlanConfig.sh
echo "Please reboot the system NOW before going on with the installation guide!"
;;
"export")
# delete old files
if [ -d /home/${username}/export ]
then
echo "Stop any running sensorplatform application"
/etc/init.d/sensorplatform stop > /dev/null 2>&1
echo "delete old files and folders"
rm -r /home/${username}/export
else
echo "no previous installation found"
fi
# create folders
echo "Create folders"
mkdir -p /home/${username}/export/bin
mkdir /home/${username}/export/staticResources
mkdir /home/${username}/export/db
# copy files
echo "Copy files"
cp -r SensorplatformApp/staticResources ../../export
cp -r SensorplatformApp/db ../../export
cp SensorplatformApp/target/resources/* ../../export/bin
# make scp able to overwrite them when copied from windows for testing
echo "Setting permissions"
chmod -R 777 ../../export/bin
chmod -R 777 ../../export/db
chmod -R 777 ../../export/staticResources
# copy start script for remote debugger
cp Resources/Firmware/RaspberryPi3/System/debug.sh ../../export
echo "configure autostart"
# setup systemd service for sensorplatform (autostart)
cp Resources/Firmware/RaspberryPi3/System/sensorplatform /etc/init.d
chmod +x /etc/init.d/sensorplatform
update-rc.d sensorplatform defaults
;;
"time")
echo "Configuring time and date"
echo "Remove fake-hwclock"
apt purge -y fake-hwclock
echo "Remove ntp from autostart"
update-rc.d -f ntp remove
hwclock
echo "Assuming the current time is set correctly by NTP"
echo "Using system time to set hardware clock"
hwclock -w
echo "System time set"
;;
"start")
# run this to see the log output in real time
echo "Stop any running sensorplatform application"
/etc/init.d/sensorplatform stop > /dev/null 2>&1
cd /home/${username}/export
echo "Start the sensorplatform application"
sudo /lib/jvm/jdk1.8.0_101/bin/java -cp "bin/*" de.fhg.fit.biomos.sensorplatform.main.Main
;;
"startbackground")
echo "Stop any running sensorplatform application"
/etc/init.d/sensorplatform stop > /dev/null 2>&1
echo "Starting the sensorplattform application as background service"
/etc/init.d/sensorplatform start
;;
"stop")
echo "Stop any running sensorplatform application"
/etc/init.d/sensorplatform stop > /dev/null 2>&1
;;
"reset")
# delete old files
if [ -d /home/${username}/export ]
then
echo "Stop any running sensorplatform application"
/etc/init.d/sensorplatform stop > /dev/null 2>&1
echo "delete old binary files in export directory"
rm -r /home/${username}/export
else
echo "no previous installation found"
fi
# create folders
echo "Create folders"
mkdir -p /home/${username}/export/bin
mkdir /home/${username}/export/staticResources
mkdir /home/${username}/export/db
chmod -R 777 ../../export/bin
chmod -R 777 ../../export/db
chmod -R 777 ../../export/staticResources
;;
*)
echo "This is the Sensorplatform script for working with the application. It is intended to be executed only on the sensorplatform linux system. Always run this script with sudo!"
echo ""
echo "Valid commands: (dependencies|export|time|start|startbackground|stop|reset)"
echo ""
;;
esac
exit 0