forked from MagicCube/rpi-man
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpi-man-get
executable file
·78 lines (66 loc) · 1.67 KB
/
rpi-man-get
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
#!/bin/sh
name="rpi-man-get"
path="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
bin_path="/usr/local/bin"
init_d_path="/etc/init.d"
install()
{
echo "Installing rpi-man..."
install_dependencies
echo "Make rpi-man-server as global command..."
ln -s $path/bin/rpi-man-server $bin_path
echo "Make rpi-man-server run at startup..."
ln -s $path/bin/rpi-man-server $init_d_path
echo "rpi-man is now installed on your Raspberry PI."
echo "Type 'sudo rpi-man-server start' to start."
}
install_dependencies()
{
echo "Installing dependencies..."
npm install --production
}
uninstall()
{
if rpi-man-server status; then
rpi-man-server stop
fi
echo "Uninstalling rpi-man..."
echo "Removing rpi-man-server from global commands and startup..."
rm $bin_path/rpi-man-server
rm $init_d_path/rpi-man-server
echo "Now it is safe to remove rpi-man by delete this folder."
echo "See you next time ;)"
}
upgrade()
{
is_running=0
if rpi-man-server status; then
echo "$name detects that rpi-man-server is now running."
is_running=1
rpi-man-server stop
echo "$name will restart rpi-man-server immediately after upgrade completes."
fi
echo "Upgrading rpi-man..."
echo "Pulling the latest rpi-man from Github..."
git pull origin master
install_dependencies
if [ $is_running = 1 ]; then
rpi-man-server start
fi
echo "rpi-man is now up-to-date."
}
case $1 in
install)
install
;;
uninstall)
uninstall
;;
upgrade)
upgrade
;;
*)
echo "Usage: $name {install|uninstall|upgrade}"
;;
esac
exit 0