forked from GridSpace/grid-bot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
executable file
·108 lines (87 loc) · 2.69 KB
/
setup.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
#!/bin/bash
[ `whoami` == 'root' ] && echo "run this script as the user 'pi'" && exit
# require some packages
sudo apt update
sudo apt -y install automake avrdude g++ git unclutter vim wget
[ -z "${HOME}" ] && echo "HOME not set" && exit
cd ${HOME}
# quietly remove all empty directories
rmdir * >/dev/null 2>&1
export ROOT="${HOME}/grid-bot"
# install grid-bot package if missing
[ ! -d "${ROOT}" ] && {
echo "fetching grid-bot"
git clone https://github.com/GridSpace/grid-bot.git
}
# update grid-bot
cd "${ROOT}"
git pull
# uploads dir, remove legacy port link
cd ${ROOT}
rm port
mkdir -p uploads
# setup graphical interface boot
export LXDIR=${HOME}/.config/lxsession/LXDE-pi
mkdir -p "${LXDIR}"
cp "${ROOT}/bin/pi-ui-autostart" "${LXDIR}/autostart"
chmod 755 "${LXDIR}/autostart"
# download, expand, link node
if [ ! -d node ]; then
echo "downloading nodejs"
# for pi zero
grep ARMv6 /proc/cpuinfo && {
wget https://unofficial-builds.nodejs.org/download/release/v14.16.0/node-v14.16.0-linux-armv6l.tar.xz
tar xf node-v14.16.0-linux-armv6l.tar.xz
ln -sf node-v14.16.0-linux-armv6l node
#wget https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-armv6l.tar.xz
#tar xf node-v10.15.3-linux-armv6l.tar.xz
#ln -sf node-v10.15.3-linux-armv6l node
}
# for pi 3
grep ARMv7 /proc/cpuinfo && {
wget https://nodejs.org/dist/latest-v14.x/node-v14.16.0-linux-armv7l.tar.xz
tar xf node-v14.16.0-linux-armv7l.tar.xz
ln -sf node-v14.16.0-linux-armv7l node
#wget https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-armv7l.tar.xz
#tar xf node-v10.15.3-linux-armv7l.tar.xz
#ln -sf node-v10.15.3-linux-armv7l node
}
fi
# ensure node in path
grep node ${HOME}/.bashrc || {
echo "export PATH=\${PATH}:${ROOT}/node/bin" >> ${HOME}/.bashrc
}
# make sure npm will work
export PATH=${PATH}:${ROOT}/node/bin
# update grid-bot post-node install (to get npm)
cd ${ROOT}
npm i
# install grid-host
[ ! -d "${HOME}/grid-host" ] && {
echo "installing grid-host"
cd ${HOME}
git clone https://github.com/GridSpace/grid-host.git grid-host
}
# update grid-host modules
cd "${HOME}/grid-host"
git pull
npm i
# install grid-apps
[ ! -d "${HOME}/grid-apps" ] && {
echo "installing grid-apps"
cd ${HOME}
git clone https://github.com/GridSpace/grid-apps.git grid-apps
}
# update grid-apps modules
cd "${HOME}/grid-apps"
git pull
npm i
# do required root setups
[ ! -d "${HOME}/.grid" ] && sudo ${ROOT}/bin/setup-root.sh && mkdir "${HOME}/.grid"
# ssh setup/trust if desired
[ ! -d "${HOME}/.ssh" ] && {
mkdir -p "${HOME}/.ssh"
chmod 700 "${HOME}/.ssh"
}
echo "change pi user password"
echo "reboot required"