-
Notifications
You must be signed in to change notification settings - Fork 21
/
jpyserver.sh
executable file
·61 lines (57 loc) · 1.6 KB
/
jpyserver.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
#! /bin/sh
# /etc/init.d/jpyserver.sh
### BEGIN INIT INFO
# Provides: jpyserver
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: false
# Short-Description: jpyserver - starts a jupyter notebook for students to play with locally
### END INIT INFO
HOME=/home/pi
DOSENET=$HOME/dosenet-raspberrypi
LOG=$HOME/jpyserver.log
case "$1" in
start)
# make sure webserver environment is configured properly
echo "checking that error log can write" > $LOG
if [ ! -d "/var/log/lighttpd" ]; then
sudo mkdir /var/log/lighttpd
sudo chown -R www-data /var/log/lighttpd
fi
sudo chown www-data:www-data /var/run/lighttpd.pid
echo "Starting web-server" >> $LOG
echo "Starting web-server"
sudo /etc/init.d/lighttpd start
echo "Updating web code" >> $LOG
echo "Updating web code"
cd $HOME/dosenet-web
sudo -u pi git pull --ff-only
sudo cp $HOME/dosenet-web/sample_device.html /var/www/html/index.html
echo "Updating analysis code" >> $LOG
echo "Updating analysis code"
cd $HOME/dosenet-analysis
sudo -u pi git pull --ff-only
echo "Starting jupyter notebook" >> $LOG
echo "Starting jupyter notebook"
sudo -u pi screen -dm jupyter notebook
date >> $LOG
;;
stop)
echo "Stopping jupyter-notebook" >> $LOG
echo "Stopping jupyter-notebook"
date >> $LOG
sudo killall jupyter-notebook
;;
test)
echo "Testing web-server script" >> $LOG
echo "Testing web-server script"
date >> $LOG
;;
*)
echo "Usage: /etc/init.d/jpyserver.sh {start|test|stop}"
exit 1
;;
esac
exit 0