forked from learningequality/ka-lite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_unix.sh
executable file
·72 lines (69 loc) · 2.5 KB
/
setup_unix.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
#!/bin/bash
current_dir=`dirname "${BASH_SOURCE[0]}"`
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )/scripts"
pyexec=`"$SCRIPT_DIR"/python.sh`
"$pyexec" "$current_dir/kalite/manage.py" setup
# TODO: make a check to see if we're running the rpi
we_are_rpi=""
if [[ $we_are_rpi = "True" ]]; then
while true
do
echo
echo "Do you wish to configure the Raspberry Pi optimizations for this server?"
echo "You will need root/sudo privileges and an Internet connection."
echo
echo -n "Optimize now? [Y/N] "
read CONFIRM
case $CONFIRM in
y|Y)
echo "Optimize will start the KA Lite server now, "
echo " and automatically on every system boot."
echo
sudo "$SCRIPT_DIR/runatboot.sh"
sudo "$SCRIPT_DIR/optimizerpi.sh"
echo
exit
;;
n|N)
echo "To optimize later, run ./scripts/optimizerpi.sh"
echo
break
;;
esac
done
fi
# Check if we have init.d for Linux or LaunchAgents for OSX so we can setup auto-start services.
if [ -d "/etc/init.d" ] || [ -d "/Library/LaunchAgents" ]; then
while true
do
PLIST=/$HOME/Library/LaunchAgents/org.learningequality.kalite.plist
echo
echo "Do you wish to set the KA Lite server to run in the background automatically"
echo -n "when you start this computer (you will need root/sudo privileges) [Y/N]? "
read CONFIRM
case $CONFIRM in
y|Y)
echo
sudo "$SCRIPT_DIR/runatboot.sh"
if [ -e $PLIST ]; then
launchctl load -w $PLIST
echo "KA Lite server will now run automatically on login."
fi
break
;;
n|N)
echo
# Make sure we unload so plist doesn't run on login. This might throw an
# exception but cannot seem to suppress it even with a redirect to /dev/null
# so we use the `launchctl list` to check if the plist is loaded.
if [ -e $PLIST ]; then
plist_loaded=`launchctl list | grep org.learningequality.kalite`;
if [[ ! -z "$plist_loaded" ]]; then
launchctl unload -w $PLIST
fi
fi
break
;;
esac
done
fi