-
Notifications
You must be signed in to change notification settings - Fork 3
/
configure_pi.fedora.sh
executable file
·58 lines (51 loc) · 1.4 KB
/
configure_pi.fedora.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
#!/bin/bash
if [ $(id -u) != 0 ]
then
echo "requires root/sudo" >&2
exit 1
fi
PUBLIC_KEY=$1
mnt_dir="/var/run/media/${SUDO_USER}"
boot_dir="${mnt_dir}/boot"
root_dir="${mnt_dir}/rootfs"
if [ ! -d ${boot_dir} ]
then
echo "${boot_dir} not found" >&2
exit 1
fi
if [ ! -f wpa_supplicant.conf ]
then
echo "wpa_supplicant.conf not found" >&2
exit 1
fi
echo "Configuring SSH" >&2
cp wpa_supplicant.conf ${boot_dir}
touch ${boot_dir}/ssh
if [ -d ${root_dir} ]
then
if [ -f "${PUBLIC_KEY}" ]
then
echo "setting up ${PUBLIC_KEY}" >&2
mkdir ${root_dir}/home/pi/.ssh
chmod 700 ${root_dir}/home/pi/.ssh
cp ${PUBLIC_KEY} ${root_dir}/home/pi/.ssh/authorized_keys
chown -R 1000:1000 ${root_dir}/home/pi/.ssh
fi
echo "Installing Software" >&2
cp requirements.txt ${root_dir}/home/pi/
chown 1000:1000 ${root_dir}/home/pi/requirements.txt
cp run_lights.py ${root_dir}/home/pi/
cp simpletest.py ${root_dir}/home/pi/
chown 1000:1000 ${root_dir}/home/pi/*py
cp launch*sh lights_down.sh ${root_dir}/home/pi/
chown 1000:1000 ${root_dir}/home/pi/*sh
cp -R lib ${root_dir}/home/pi/
chown -R 1000:1000 ${root_dir}/home/pi/lib
cp -R neopix_controller ${root_dir}/home/pi/
chown -R 1000:1000 ${root_dir}/home/pi/neopix_controller
cp *json ${root_dir}/home/pi/
chown 1000:1000 ${root_dir}/home/pi/*json
else
echo "Use ssh over wifi to install requirements and ssh public key" >&2d
fi
exit