This repository has been archived by the owner on Jan 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
install
executable file
·139 lines (113 loc) · 3.76 KB
/
install
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
pkgdeplist7=( "libboost-system1.50.0" "libboost-filesystem1.50.0" "libboost-program-options1.50.0" ) # list of the dependencies for Wheezy
pkgdeplist8=( "libboost-system1.50.0" "libboost-filesystem1.50.0" "libboost-program-options1.50.0" ) # list of the dependencies for Jessie
pkgdeplist9=( "libboost-system1.58.0" "libboost-filesystem1.58.0" "libboost-program-options1.58.0" "libboost-date-time1.58.0" ) # list of the dependencies for Stretch
pkgdeplist10=( "libboost-system1.58.0" "libboost-filesystem1.58.0" "libboost-program-options1.58.0" "libboost-date-time1.58.0" ) # list of the dependencies for Buster
HOME=/home/$SUDO_USER
RELEASE=$(lsb_release -sr)
DIST=$(lsb_release -si)
apt_pkg_req () {
APT_CHK=$(dpkg-query -W --showformat='${Status}\n' $1|grep "install ok installed")
if [ "" == "$APT_CHK" ]; then
true
else
false
fi
}
if [ $(id -u) -ne 0 ]; then
printf "Install must be run as root. Try 'sudo ./install'\n"
exit 1
fi
if [ ! "$DIST" == "Raspbian" ]; then
printf "This installer is only intended for Raspbian\n"
exit 1
fi
if [ -f $HOME/.config/autostart/flotilla.desktop ]; then
printf "Removing redundant file $HOME/.config/autostart/flotilla.desktop\n"
rm -f $HOME/.config/autostart/flotilla.desktop
fi
printf "Installing dependencies...\n"
updatedb=false
case "$RELEASE" in
"10")
printf "Detected Raspbian Buster...\n"
pkgdeplist=${pkgdeplist10[@]}
flotilla_binary="flotilla-stretch"
;;
"9.0" | "9.1" | "9.2" | "9.3" | "9.4" | "9.5" | "9.6" | "9.7" | "9.8" | "9.9" | "9.10" | "9.11")
printf "Detected Raspbian Stretch...\n"
pkgdeplist=${pkgdeplist9[@]}
flotilla_binary="flotilla-stretch"
;;
"8.0")
printf "Detected Raspbian Jessie...\n"
pkgdeplist=${pkgdeplist8[@]}
flotilla_binary="flotilla"
;;
"7.0")
printf "Detected Raspbian Wheezy...\n"
pkgdeplist=${pkgdeplist7[@]}
flotilla_binary="flotilla-wheezy"
;;
*)
printf "Unsupported version of Raspbian!\n"
exit 1
;;
esac
for pkgdep in ${pkgdeplist[@]}
do
if apt_pkg_req "$pkgdep" ; then
updatedb=true
fi
done
if $updatedb ; then
printf "\nUpdating package indexes..."
sudo apt-get update
fi
for pkgdep in ${pkgdeplist[@]}
do
printf "Checking for $pkgdep...\n"
if apt_pkg_req "$pkgdep" ; then
sudo apt-get --yes --force-yes install "$pkgdep"
fi
done
if [ -f /usr/local/lib/libserialport.so.0.0.0 ]; then
printf "libserialport already installed. Updating...\n"
fi
cp ./dependencies/libs/libserialport* /usr/local/lib/
if [ ! -f /usr/local/lib/libserialport.so.0 ]; then
ln -s /usr/local/lib/libserialport.so.0.0.0 /usr/local/lib/libserialport.so.0
fi
if [ ! -f /usr/local/lib/libserialport.so ]; then
ln -s /usr/local/lib/libserialport.so.0.0.0 /usr/local/lib/libserialport.so
fi
chown root:staff /usr/local/lib/libserialport*
ldconfig
if [ ! -f /usr/bin/flotilla ]; then
printf "Installing Flotilla daemon...\n"
else
printf "Flotilla already installed. Updating...\n"
fi
cp $flotilla_binary /usr/bin/flotilla
chmod +x /usr/bin/flotilla
if [ ! -f /etc/init.d/flotillad ]; then
printf "Setting up init script...\n"
cp dependencies/flotillad /etc/init.d/
chmod +x /etc/init.d/flotillad
update-rc.d flotillad defaults
/etc/init.d/flotillad start &
else
printf "Init script already on system. Updating...\n"
cp dependencies/flotillad /etc/init.d/
chmod +x /etc/init.d/flotillad
update-rc.d flotillad defaults
/etc/init.d/flotillad restart &
fi
printf "Installing Rockpool...\n"
cp -r rockpool /opt
cp dependencies/rockpool /usr/sbin/
chmod +x /usr/sbin/rockpool
cp dependencies/rockpool.png /usr/share/pixmaps/
cp dependencies/rockpool.desktop /usr/share/applications/
printf "\nAll done! Time to set sail.\n"
exit 0