This repository has been archived by the owner on Dec 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup.sh
176 lines (140 loc) · 4.62 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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/bin/bash
set -eu
source /etc/os-release
t=`date '+%H:%M:%S'`
# Check we're on Raspbian Stretch (Debian 9)
if [ $VERSION_ID -eq 9 ]; then
echo "$t You are running Raspbian Stretch. Starting Astro Pi setup..."
else
echo "You seem to be using {$PRETTY_NAME}. This installer is for Raspbian Stretch. Please download Raspbian Stretch from the Raspberry Pi website http://rpf.io/raspbian"
exit 1
fi
# Enable the camera
t=`date '+%H:%M:%S'`
echo "$t Enabling the camera interface"
sudo raspi-config nonint do_camera 0
# apt update
t=`date '+%H:%M:%S'`
echo "$t Updating and upgrading your apt packages"
t=`date '+%H:%M:%S'`
echo "$t Running update"
sudo apt-get -qq update > /dev/null
# Check if git was already installed
git=`dpkg -l | grep "ii git" | wc -l`
if [ $git -gt 0 ]; then
git_installed=true
else
git_installed=false
t=`date '+%H:%M:%S'`
echo "$t Installing git"
sudo apt-get install git -qqy > /dev/null
fi
# Clone this repo to have access to test files and desktop backgrounds
t=`date '+%H:%M:%S'`
echo "$t Cloning installation repository"
rm -rf astro-pi-stretch-installer || true # delete if it's already there
git clone -q https://github.com/astro-pi/astro-pi-stretch-installer
cd astro-pi-stretch-installer
# Check we're on desktop or lite
chromium=`dpkg -l | grep chromium | wc -l`
if [ $chromium -gt 0 ]; then
desktop=true
t=`date '+%H:%M:%S'`
echo "$t It looks like you are running Raspbian Desktop"
# Set Chromium homepage and bookmarks
echo "$t Setting your Chromium homepage and bookmarks..."
sudo python3 chromium.py
else
desktop=false
t=`date '+%H:%M:%S'`
echo "$t It looks like you are running Raspbian Lite"
fi
# Install apt packages
t=`date '+%H:%M:%S'`
echo "$t Running upgrade"
sudo apt-get -qqy upgrade > /dev/null
t=`date '+%H:%M:%S'`
echo "$t Running dist-upgrade"
sudo apt-get -qqy dist-upgrade > /dev/null
mapfile -t packages < packages.txt
t=`date '+%H:%M:%S'`
echo "$t Installing new apt packages..."
for package in "${packages[@]}"; do
t=`date '+%H:%M:%S'`
echo "$t Installing $package..."
sudo apt-get install $package -qqy > /dev/null
done
# Remove git if it wasn't installed before
if ! $git_installed; then
t=`date '+%H:%M:%S'`
echo "$t Removing git"
sudo apt-get -y purge git > /dev/null
sudo apt-get -y autoremove > /dev/null
fi
# Install Python packages
t=`date '+%H:%M:%S'`
echo "$t Installing Python packages..."
# Install Python packages from PyPI/piwheels - versions specified in requirements.txt
mapfile -t packages < requirements.txt
for package in "${packages[@]}"; do
t=`date '+%H:%M:%S'`
echo "$t Installing $package..."
sudo pip3 install -q $package > /dev/null
done
# Install Armv6 versions of opencv/tensorflow/grpcio from wheel files
cd wheels
for f in *armv6l.whl; # rename armv6 wheels to armv7
do cp $f ${f%armv6l.whl}armv7l.whl;
done
cd ../
packages=(
opencv-contrib-python-headless
grpcio
tensorflow
)
for package in "${packages[@]}"; do
t=`date '+%H:%M:%S'`
echo "$t Installing $package..."
sudo pip3 install $package --find-links=wheels --no-index > /dev/null
done
# Test Python imports
t=`date '+%H:%M:%S'`
echo "$t Testing importing your Python packages..."
if python3 -W ignore test.py; then
t=`date '+%H:%M:%S'`
echo "$t All Python libraries imported ok"
else
t=`date '+%H:%M:%S'`
echo "$t There were errors with the Python libraries. See above for more information."
fi
t=`date '+%H:%M:%S'`
if $desktop; then
echo "$t Installing desktop backgrounds"
sudo cp desktop-backgrounds/* /usr/share/rpd-wallpaper/
# Set the desktop background to MSL
global_config_dir="/etc/xdg/pcmanfm/LXDE-pi"
local_config_dir="/home/pi/.config/pcmanfm"
local_config="/home/pi/.config/pcmanfm/LXDE-pi/desktop-items-0.conf"
if [ ! -e $local_config ]; then
mkdir -p $local_config_dir
cp -r $global_config_dir $local_config_dir
fi
sed -i -e 's/road.jpg/mission-space-lab.jpg/g' $local_config
t=`date '+%H:%M:%S'`
echo "$t Installing Mu editor..."
sudo apt-get install mu-editor -qqy > /dev/null
else
echo "$t Setting MOTD"
sudo /bin/sh motd.sh /etc/motd
t=`date '+%H:%M:%S'`
echo "$t Implementing performance throttling"
sudo cp astropiconfig.txt /boot/
echo "include astropiconfig.txt" | sudo tee --append /boot/config.txt > /dev/null
if ! grep -q 'maxcpus=1' /boot/cmdline.txt; then
sudo sed -i -e 's/rootwait/rootwait maxcpus=1/g' /boot/cmdline.txt
fi
fi
cd ../
sudo rm -rf astro-pi-stretch-installer
t=`date '+%H:%M:%S'`
echo "$t Astro Pi Installation complete! Run 'sudo reboot' to restart."